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,53 @@
1
+ # Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
2
+ #
3
+ # Purpose: Return various facts about the PE state of the system
4
+ #
5
+ # Resolution: Uses a regex match against puppetversion to determine whether the
6
+ # machine has Puppet Enterprise installed, and what version (overall, major,
7
+ # minor, patch) is installed.
8
+ #
9
+ # Caveats:
10
+ #
11
+ Facter.add("pe_version") do
12
+ setcode do
13
+ pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
14
+ pe_ver[1] if pe_ver
15
+ end
16
+ end
17
+
18
+ Facter.add("is_pe") do
19
+ setcode do
20
+ if Facter.value(:pe_version).to_s.empty? then
21
+ false
22
+ else
23
+ true
24
+ end
25
+ end
26
+ end
27
+
28
+ Facter.add("pe_major_version") do
29
+ confine :is_pe => true
30
+ setcode do
31
+ if pe_version = Facter.value(:pe_version)
32
+ pe_version.to_s.split('.')[0]
33
+ end
34
+ end
35
+ end
36
+
37
+ Facter.add("pe_minor_version") do
38
+ confine :is_pe => true
39
+ setcode do
40
+ if pe_version = Facter.value(:pe_version)
41
+ pe_version.to_s.split('.')[1]
42
+ end
43
+ end
44
+ end
45
+
46
+ Facter.add("pe_patch_version") do
47
+ confine :is_pe => true
48
+ setcode do
49
+ if pe_version = Facter.value(:pe_version)
50
+ pe_version.to_s.split('.')[2]
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,26 @@
1
+ # This facter fact returns the value of the Puppet vardir setting for the node
2
+ # running puppet or puppet agent. The intent is to enable Puppet modules to
3
+ # automatically have insight into a place where they can place variable data,
4
+ # regardless of the node's platform.
5
+ #
6
+ # The value should be directly usable in a File resource path attribute.
7
+
8
+
9
+ begin
10
+ require 'facter/util/puppet_settings'
11
+ rescue LoadError => e
12
+ # puppet apply does not add module lib directories to the $LOAD_PATH (See
13
+ # #4248). It should (in the future) but for the time being we need to be
14
+ # defensive which is what this rescue block is doing.
15
+ rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
16
+ load rb_file if File.exists?(rb_file) or raise e
17
+ end
18
+
19
+ Facter.add(:puppet_vardir) do
20
+ setcode do
21
+ # This will be nil if Puppet is not available.
22
+ Facter::Util::PuppetSettings.with_puppet do
23
+ Puppet[:vardir]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ # A facter fact to determine the root home directory.
2
+ # This varies on PE supported platforms and may be
3
+ # reconfigured by the end user.
4
+
5
+ module Facter::Util::RootHome
6
+ class << self
7
+ def get_root_home
8
+ root_ent = Facter::Util::Resolution.exec("getent passwd root")
9
+ # The home directory is the sixth element in the passwd entry
10
+ # If the platform doesn't have getent, root_ent will be nil and we should
11
+ # return it straight away.
12
+ root_ent && root_ent.split(":")[5]
13
+ end
14
+ end
15
+ end
16
+
17
+ Facter.add(:root_home) do
18
+ setcode { Facter::Util::RootHome.get_root_home }
19
+ end
20
+
21
+ Facter.add(:root_home) do
22
+ confine :kernel => :darwin
23
+ setcode do
24
+ str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
25
+ hash = {}
26
+ str.split("\n").each do |pair|
27
+ key,value = pair.split(/:/)
28
+ hash[key] = value
29
+ end
30
+ hash['dir'].strip
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ module Facter
2
+ module Util
3
+ module PuppetSettings
4
+ # This method is intended to provide a convenient way to evaluate a
5
+ # Facter code block only if Puppet is loaded. This is to account for the
6
+ # situation where the fact happens to be in the load path, but Puppet is
7
+ # not loaded for whatever reason. Perhaps the user is simply running
8
+ # facter without the --puppet flag and they happen to be working in a lib
9
+ # directory of a module.
10
+ def self.with_puppet
11
+ begin
12
+ Module.const_get("Puppet")
13
+ rescue NameError
14
+ nil
15
+ else
16
+ yield
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,36 @@
1
+ #
2
+ # abs.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:abs, :type => :rvalue, :doc => <<-EOS
7
+ Returns the absolute value of a number, for example -34.56 becomes
8
+ 34.56. Takes a single integer and float value as an argument.
9
+ EOS
10
+ ) do |arguments|
11
+
12
+ raise(Puppet::ParseError, "abs(): Wrong number of arguments " +
13
+ "given (#{arguments.size} for 1)") if arguments.size < 1
14
+
15
+ value = arguments[0]
16
+
17
+ # Numbers in Puppet are often string-encoded which is troublesome ...
18
+ if value.is_a?(String)
19
+ if value.match(/^-?(?:\d+)(?:\.\d+){1}$/)
20
+ value = value.to_f
21
+ elsif value.match(/^-?\d+$/)
22
+ value = value.to_i
23
+ else
24
+ raise(Puppet::ParseError, 'abs(): Requires float or ' +
25
+ 'integer to work with')
26
+ end
27
+ end
28
+
29
+ # We have numeric value to handle ...
30
+ result = value.abs
31
+
32
+ return result
33
+ end
34
+ end
35
+
36
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,33 @@
1
+ #
2
+ # any2array.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
7
+ This converts any object to an array containing that object. Empty argument
8
+ lists are converted to an empty array. Arrays are left untouched. Hashes are
9
+ converted to arrays of alternating keys and values.
10
+ EOS
11
+ ) do |arguments|
12
+
13
+ if arguments.empty?
14
+ return []
15
+ end
16
+
17
+ if arguments.length == 1
18
+ if arguments[0].kind_of?(Array)
19
+ return arguments[0]
20
+ elsif arguments[0].kind_of?(Hash)
21
+ result = []
22
+ arguments[0].each do |key, value|
23
+ result << key << value
24
+ end
25
+ return result
26
+ end
27
+ end
28
+
29
+ return arguments
30
+ end
31
+ end
32
+
33
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,37 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
4
+
5
+ Base64 encode or decode a string based on the command and the string submitted
6
+
7
+ Usage:
8
+
9
+ $encodestring = base64('encode','thestring')
10
+ $decodestring = base64('decode','dGhlc3RyaW5n')
11
+
12
+ ENDHEREDOC
13
+
14
+ require 'base64'
15
+
16
+ raise Puppet::ParseError, ("base64(): Wrong number of arguments (#{args.length}; must be = 2)") unless args.length == 2
17
+
18
+ actions = ['encode','decode']
19
+
20
+ unless actions.include?(args[0])
21
+ raise Puppet::ParseError, ("base64(): the first argument must be one of 'encode' or 'decode'")
22
+ end
23
+
24
+ unless args[1].is_a?(String)
25
+ raise Puppet::ParseError, ("base64(): the second argument must be a string to base64")
26
+ end
27
+
28
+ case args[0]
29
+ when 'encode'
30
+ result = Base64.encode64(args[1])
31
+ when 'decode'
32
+ result = Base64.decode64(args[1])
33
+ end
34
+
35
+ return result
36
+ end
37
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # bool2num.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
7
+ Converts a boolean to a number. Converts the values:
8
+ false, f, 0, n, and no to 0
9
+ true, t, 1, y, and yes to 1
10
+ Requires a single boolean or string as an input.
11
+ EOS
12
+ ) do |arguments|
13
+
14
+ raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " +
15
+ "given (#{arguments.size} for 1)") if arguments.size < 1
16
+
17
+ value = arguments[0]
18
+ klass = value.class
19
+
20
+ # We can have either true or false, or string which resembles boolean ...
21
+ unless [FalseClass, TrueClass, String].include?(klass)
22
+ raise(Puppet::ParseError, 'bool2num(): Requires either ' +
23
+ 'boolean or string to work with')
24
+ end
25
+
26
+ if value.is_a?(String)
27
+ # We consider all the yes, no, y, n and so on too ...
28
+ value = case value
29
+ #
30
+ # This is how undef looks like in Puppet ...
31
+ # We yield 0 (or false if you wish) in this case.
32
+ #
33
+ when /^$/, '' then false # Empty string will be false ...
34
+ when /^(1|t|y|true|yes)$/ then true
35
+ when /^(0|f|n|false|no)$/ then false
36
+ when /^(undef|undefined)$/ then false # This is not likely to happen ...
37
+ else
38
+ raise(Puppet::ParseError, 'bool2num(): Unknown type of boolean given')
39
+ end
40
+ end
41
+
42
+ # We have real boolean values as well ...
43
+ result = value ? 1 : 0
44
+
45
+ return result
46
+ end
47
+ end
48
+
49
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,34 @@
1
+ #
2
+ # capitalize.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
7
+ Capitalizes the first letter of a string or array of strings.
8
+ Requires either a single string or an array as an input.
9
+ EOS
10
+ ) do |arguments|
11
+
12
+ raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " +
13
+ "given (#{arguments.size} for 1)") if arguments.size < 1
14
+
15
+ value = arguments[0]
16
+ klass = value.class
17
+
18
+ unless [Array, String].include?(klass)
19
+ raise(Puppet::ParseError, 'capitalize(): Requires either ' +
20
+ 'array or string to work with')
21
+ end
22
+
23
+ if value.is_a?(Array)
24
+ # Numbers in Puppet are often string-encoded which is troublesome ...
25
+ result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
26
+ else
27
+ result = value.capitalize
28
+ end
29
+
30
+ return result
31
+ end
32
+ end
33
+
34
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,35 @@
1
+ #
2
+ # chomp.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
7
+ Removes the record separator from the end of a string or an array of
8
+ strings, for example `hello\n` becomes `hello`.
9
+ Requires a single string or array as an input.
10
+ EOS
11
+ ) do |arguments|
12
+
13
+ raise(Puppet::ParseError, "chomp(): 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, 'chomp(): 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) ? i.chomp : i }
27
+ else
28
+ result = value.chomp
29
+ end
30
+
31
+ return result
32
+ end
33
+ end
34
+
35
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,37 @@
1
+ #
2
+ # chop.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
7
+ Returns a new string with the last character removed. If the string ends
8
+ with `\r\n`, both characters are removed. Applying chop to an empty
9
+ string returns an empty string. If you wish to merely remove record
10
+ separators then you should use the `chomp` function.
11
+ Requires a string or array of strings as input.
12
+ EOS
13
+ ) do |arguments|
14
+
15
+ raise(Puppet::ParseError, "chop(): Wrong number of arguments " +
16
+ "given (#{arguments.size} for 1)") if arguments.size < 1
17
+
18
+ value = arguments[0]
19
+ klass = value.class
20
+
21
+ unless [Array, String].include?(klass)
22
+ raise(Puppet::ParseError, 'chop(): Requires either an ' +
23
+ 'array or string to work with')
24
+ end
25
+
26
+ if value.is_a?(Array)
27
+ # Numbers in Puppet are often string-encoded which is troublesome ...
28
+ result = value.collect { |i| i.is_a?(String) ? i.chop : i }
29
+ else
30
+ result = value.chop
31
+ end
32
+
33
+ return result
34
+ end
35
+ end
36
+
37
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,41 @@
1
+ #
2
+ # concat.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:concat, :type => :rvalue, :doc => <<-EOS
7
+ Appends the contents of array 2 onto array 1.
8
+
9
+ *Example:*
10
+
11
+ concat(['1','2','3'],['4','5','6'])
12
+
13
+ Would result in:
14
+
15
+ ['1','2','3','4','5','6']
16
+ EOS
17
+ ) do |arguments|
18
+
19
+ # Check that 2 arguments have been given ...
20
+ raise(Puppet::ParseError, "concat(): Wrong number of arguments " +
21
+ "given (#{arguments.size} for 2)") if arguments.size != 2
22
+
23
+ a = arguments[0]
24
+ b = arguments[1]
25
+
26
+ # Check that the first parameter is an array
27
+ unless a.is_a?(Array)
28
+ raise(Puppet::ParseError, 'concat(): Requires array to work with')
29
+ end
30
+
31
+ if b.is_a?(Array)
32
+ result = a.concat(b)
33
+ else
34
+ result = a << b
35
+ end
36
+
37
+ return result
38
+ end
39
+ end
40
+
41
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,22 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
3
+ Takes an array as first argument and an optional second argument.
4
+ Count the number of elements in array that matches second argument.
5
+ If called with only an array it counts the number of elements that are not nil/undef.
6
+ EOS
7
+ ) do |args|
8
+
9
+ if (args.size > 2) then
10
+ raise(ArgumentError, "count(): Wrong number of arguments "+
11
+ "given #{args.size} for 1 or 2.")
12
+ end
13
+
14
+ collection, item = args
15
+
16
+ if item then
17
+ collection.count item
18
+ else
19
+ collection.count { |obj| obj != nil && obj != :undef && obj != '' }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
3
+ Recursively merges two or more hashes together and returns the resulting hash.
4
+
5
+ For example:
6
+
7
+ $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
8
+ $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
9
+ $merged_hash = deep_merge($hash1, $hash2)
10
+ # The resulting hash is equivalent to:
11
+ # $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
12
+
13
+ When there is a duplicate key that is a hash, they are recursively merged.
14
+ When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
15
+
16
+ ENDHEREDOC
17
+
18
+ if args.length < 2
19
+ raise Puppet::ParseError, ("deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)")
20
+ end
21
+
22
+ deep_merge = Proc.new do |hash1,hash2|
23
+ hash1.merge(hash2) do |key,old_value,new_value|
24
+ if old_value.is_a?(Hash) && new_value.is_a?(Hash)
25
+ deep_merge.call(old_value, new_value)
26
+ else
27
+ new_value
28
+ end
29
+ end
30
+ end
31
+
32
+ result = Hash.new
33
+ args.each do |arg|
34
+ next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
35
+ # If the argument was not a hash, skip it.
36
+ unless arg.is_a?(Hash)
37
+ raise Puppet::ParseError, "deep_merge: unexpected argument type #{arg.class}, only expects hash arguments"
38
+ end
39
+
40
+ result = deep_merge.call(result, arg)
41
+ end
42
+ return( result )
43
+ end
44
+ end
@@ -0,0 +1,35 @@
1
+ # Test whether a given class or definition is defined
2
+ require 'puppet/parser/functions'
3
+
4
+ Puppet::Parser::Functions.newfunction(:defined_with_params,
5
+ :type => :rvalue,
6
+ :doc => <<-'ENDOFDOC'
7
+ Takes a resource reference and an optional hash of attributes.
8
+
9
+ Returns true if a resource with the specified attributes has already been added
10
+ to the catalog, and false otherwise.
11
+
12
+ user { 'dan':
13
+ ensure => present,
14
+ }
15
+
16
+ if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
17
+ user { 'dan': ensure => present, }
18
+ }
19
+ ENDOFDOC
20
+ ) do |vals|
21
+ reference, params = vals
22
+ raise(ArgumentError, 'Must specify a reference') unless reference
23
+ if (! params) || params == ''
24
+ params = {}
25
+ end
26
+ ret = false
27
+ if resource = findresource(reference.to_s)
28
+ matches = params.collect do |key, value|
29
+ resource[key] == value
30
+ end
31
+ ret = params.empty? || !matches.include?(false)
32
+ end
33
+ Puppet.debug("Resource #{reference} was not determined to be defined")
34
+ ret
35
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # delete.rb
3
+ #
4
+
5
+ # TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
6
+
7
+ module Puppet::Parser::Functions
8
+ newfunction(:delete, :type => :rvalue, :doc => <<-EOS
9
+ Deletes all instances of a given element from an array, substring from a
10
+ string, or key from a hash.
11
+
12
+ *Examples:*
13
+
14
+ delete(['a','b','c','b'], 'b')
15
+ Would return: ['a','c']
16
+
17
+ delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
18
+ Would return: {'a'=>1,'c'=>3}
19
+
20
+ delete('abracadabra', 'bra')
21
+ Would return: 'acada'
22
+ EOS
23
+ ) do |arguments|
24
+
25
+ if (arguments.size != 2) then
26
+ raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
27
+ "given #{arguments.size} for 2.")
28
+ end
29
+
30
+ collection = arguments[0].dup
31
+ item = arguments[1]
32
+
33
+ case collection
34
+ when Array, Hash
35
+ collection.delete item
36
+ when String
37
+ collection.gsub! item, ''
38
+ else
39
+ raise(TypeError, "delete(): First argument must be an Array, " +
40
+ "String, or Hash. Given an argument of class #{collection.class}.")
41
+ end
42
+ collection
43
+ end
44
+ end
45
+
46
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,49 @@
1
+ #
2
+ # delete_at.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
7
+ Deletes a determined indexed value from an array.
8
+
9
+ *Examples:*
10
+
11
+ delete_at(['a','b','c'], 1)
12
+
13
+ Would return: ['a','c']
14
+ EOS
15
+ ) do |arguments|
16
+
17
+ raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " +
18
+ "given (#{arguments.size} for 2)") if arguments.size < 2
19
+
20
+ array = arguments[0]
21
+
22
+ unless array.is_a?(Array)
23
+ raise(Puppet::ParseError, 'delete_at(): Requires array to work with')
24
+ end
25
+
26
+ index = arguments[1]
27
+
28
+ if index.is_a?(String) and not index.match(/^\d+$/)
29
+ raise(Puppet::ParseError, 'delete_at(): You must provide ' +
30
+ 'non-negative numeric index')
31
+ end
32
+
33
+ result = array.clone
34
+
35
+ # Numbers in Puppet are often string-encoded which is troublesome ...
36
+ index = index.to_i
37
+
38
+ if index > result.size - 1 # First element is at index 0 is it not?
39
+ raise(Puppet::ParseError, 'delete_at(): Given index ' +
40
+ 'exceeds size of array given')
41
+ end
42
+
43
+ result.delete_at(index) # We ignore the element that got deleted ...
44
+
45
+ return result
46
+ end
47
+ end
48
+
49
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,34 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS
3
+ Returns a copy of input hash or array with all undefs deleted.
4
+
5
+ *Examples:*
6
+
7
+ $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
8
+
9
+ Would return: {a => 'A', b => '', d => false}
10
+
11
+ $array = delete_undef_values(['A','',undef,false])
12
+
13
+ Would return: ['A','',false]
14
+
15
+ EOS
16
+ ) do |args|
17
+
18
+ raise(Puppet::ParseError,
19
+ "delete_undef_values(): Wrong number of arguments given " +
20
+ "(#{args.size})") if args.size < 1
21
+
22
+ unless args[0].is_a? Array or args[0].is_a? Hash
23
+ raise(Puppet::ParseError,
24
+ "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ")
25
+ end
26
+ result = args[0].dup
27
+ if result.is_a?(Hash)
28
+ result.delete_if {|key, val| val.equal? :undef}
29
+ elsif result.is_a?(Array)
30
+ result.delete :undef
31
+ end
32
+ result
33
+ end
34
+ end