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,81 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:validate_augeas, :doc => <<-'ENDHEREDOC') do |args|
3
+ Perform validation of a string using an Augeas lens
4
+ The first argument of this function should be a string to
5
+ test, and the second argument should be the name of the Augeas lens to use.
6
+ If Augeas fails to parse the string with the lens, the compilation will
7
+ abort with a parse error.
8
+
9
+ A third argument can be specified, listing paths which should
10
+ not be found in the file. The `$file` variable points to the location
11
+ of the temporary file being tested in the Augeas tree.
12
+
13
+ For example, if you want to make sure your passwd content never contains
14
+ a user `foo`, you could write:
15
+
16
+ validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
17
+
18
+ Or if you wanted to ensure that no users used the '/bin/barsh' shell,
19
+ you could use:
20
+
21
+ validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
22
+
23
+ If a fourth argument is specified, this will be the error message raised and
24
+ seen by the user.
25
+
26
+ A helpful error message can be returned like this:
27
+
28
+ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
29
+
30
+ ENDHEREDOC
31
+ unless Puppet.features.augeas?
32
+ raise Puppet::ParseError, ("validate_augeas(): this function requires the augeas feature. See http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Augeas#Pre-requisites for how to activate it.")
33
+ end
34
+
35
+ if (args.length < 2) or (args.length > 4) then
36
+ raise Puppet::ParseError, ("validate_augeas(): wrong number of arguments (#{args.length}; must be 2, 3, or 4)")
37
+ end
38
+
39
+ msg = args[3] || "validate_augeas(): Failed to validate content against #{args[1].inspect}"
40
+
41
+ require 'augeas'
42
+ aug = Augeas::open(nil, nil, Augeas::NO_MODL_AUTOLOAD)
43
+ begin
44
+ content = args[0]
45
+
46
+ # Test content in a temporary file
47
+ tmpfile = Tempfile.new("validate_augeas")
48
+ begin
49
+ tmpfile.write(content)
50
+ ensure
51
+ tmpfile.close
52
+ end
53
+
54
+ # Check for syntax
55
+ lens = args[1]
56
+ aug.transform(
57
+ :lens => lens,
58
+ :name => 'Validate_augeas',
59
+ :incl => tmpfile.path
60
+ )
61
+ aug.load!
62
+
63
+ unless aug.match("/augeas/files#{tmpfile.path}//error").empty?
64
+ error = aug.get("/augeas/files#{tmpfile.path}//error/message")
65
+ msg += " with error: #{error}"
66
+ raise Puppet::ParseError, (msg)
67
+ end
68
+
69
+ # Launch unit tests
70
+ tests = args[2] || []
71
+ aug.defvar('file', "/files#{tmpfile.path}")
72
+ tests.each do |t|
73
+ msg += " testing path #{t}"
74
+ raise Puppet::ParseError, (msg) unless aug.match(t).empty?
75
+ end
76
+ ensure
77
+ aug.close
78
+ tmpfile.unlink
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,34 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args|
4
+ Validate that all passed values are either true or false. Abort catalog
5
+ compilation if any value fails this check.
6
+
7
+ The following values will pass:
8
+
9
+ $iamtrue = true
10
+ validate_bool(true)
11
+ validate_bool(true, true, false, $iamtrue)
12
+
13
+ The following values will fail, causing compilation to abort:
14
+
15
+ $some_array = [ true ]
16
+ validate_bool("false")
17
+ validate_bool("true")
18
+ validate_bool($some_array)
19
+
20
+ ENDHEREDOC
21
+
22
+ unless args.length > 0 then
23
+ raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)")
24
+ end
25
+
26
+ args.each do |arg|
27
+ unless function_is_bool([arg])
28
+ raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}")
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,48 @@
1
+ require 'puppet/util/execution'
2
+
3
+ module Puppet::Parser::Functions
4
+ newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args|
5
+ Perform validation of a string with an external command.
6
+ The first argument of this function should be a string to
7
+ test, and the second argument should be a path to a test command
8
+ taking a file as last argument. If the command, launched against
9
+ a tempfile containing the passed string, returns a non-null value,
10
+ compilation will abort with a parse error.
11
+
12
+ If a third argument is specified, this will be the error message raised and
13
+ seen by the user.
14
+
15
+ A helpful error message can be returned like this:
16
+
17
+ Example:
18
+
19
+ validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
20
+
21
+ ENDHEREDOC
22
+ if (args.length < 2) or (args.length > 3) then
23
+ raise Puppet::ParseError, ("validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)")
24
+ end
25
+
26
+ msg = args[2] || "validate_cmd(): failed to validate content with command #{args[1].inspect}"
27
+
28
+ content = args[0]
29
+ checkscript = args[1]
30
+
31
+ # Test content in a temporary file
32
+ tmpfile = Tempfile.new("validate_cmd")
33
+ begin
34
+ tmpfile.write(content)
35
+ tmpfile.close
36
+ if Puppet::Util::Execution.respond_to?('execute')
37
+ Puppet::Util::Execution.execute("#{checkscript} #{tmpfile.path}")
38
+ else
39
+ Puppet::Util.execute("#{checkscript} #{tmpfile.path}")
40
+ end
41
+ rescue Puppet::ExecutionFailure => detail
42
+ msg += "\n#{detail}"
43
+ raise Puppet::ParseError, msg
44
+ ensure
45
+ tmpfile.unlink
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,33 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args|
4
+ Validate that all passed values are hash data structures. Abort catalog
5
+ compilation if any value fails this check.
6
+
7
+ The following values will pass:
8
+
9
+ $my_hash = { 'one' => 'two' }
10
+ validate_hash($my_hash)
11
+
12
+ The following values will fail, causing compilation to abort:
13
+
14
+ validate_hash(true)
15
+ validate_hash('some_string')
16
+ $undefined = undef
17
+ validate_hash($undefined)
18
+
19
+ ENDHEREDOC
20
+
21
+ unless args.length > 0 then
22
+ raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)")
23
+ end
24
+
25
+ args.each do |arg|
26
+ unless arg.is_a?(Hash)
27
+ raise Puppet::ParseError, ("#{arg.inspect} is not a Hash. It looks to be a #{arg.class}")
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,48 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_ipv4_address, :doc => <<-ENDHEREDOC
4
+ Validate that all values passed are valid IPv4 addresses.
5
+ Fail compilation if any value fails this check.
6
+
7
+ The following values will pass:
8
+
9
+ $my_ip = "1.2.3.4"
10
+ validate_ipv4_address($my_ip)
11
+ validate_bool("8.8.8.8", "172.16.0.1", $my_ip)
12
+
13
+ The following values will fail, causing compilation to abort:
14
+
15
+ $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
16
+ validate_ipv4_address($some_array)
17
+
18
+ ENDHEREDOC
19
+ ) do |args|
20
+
21
+ require "ipaddr"
22
+ rescuable_exceptions = [ ArgumentError ]
23
+
24
+ if defined?(IPAddr::InvalidAddressError)
25
+ rescuable_exceptions << IPAddr::InvalidAddressError
26
+ end
27
+
28
+ unless args.length > 0 then
29
+ raise Puppet::ParseError, ("validate_ipv4_address(): wrong number of arguments (#{args.length}; must be > 0)")
30
+ end
31
+
32
+ args.each do |arg|
33
+ unless arg.is_a?(String)
34
+ raise Puppet::ParseError, "#{arg.inspect} is not a string."
35
+ end
36
+
37
+ begin
38
+ unless IPAddr.new(arg).ipv4?
39
+ raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv4 address."
40
+ end
41
+ rescue *rescuable_exceptions
42
+ raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv4 address."
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,49 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_ipv6_address, :doc => <<-ENDHEREDOC
4
+ Validate that all values passed are valid IPv6 addresses.
5
+ Fail compilation if any value fails this check.
6
+
7
+ The following values will pass:
8
+
9
+ $my_ip = "3ffe:505:2"
10
+ validate_ipv6_address(1)
11
+ validate_ipv6_address($my_ip)
12
+ validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip)
13
+
14
+ The following values will fail, causing compilation to abort:
15
+
16
+ $some_array = [ true, false, "garbage string", "1.2.3.4" ]
17
+ validate_ipv6_address($some_array)
18
+
19
+ ENDHEREDOC
20
+ ) do |args|
21
+
22
+ require "ipaddr"
23
+ rescuable_exceptions = [ ArgumentError ]
24
+
25
+ if defined?(IPAddr::InvalidAddressError)
26
+ rescuable_exceptions << IPAddr::InvalidAddressError
27
+ end
28
+
29
+ unless args.length > 0 then
30
+ raise Puppet::ParseError, ("validate_ipv6_address(): wrong number of arguments (#{args.length}; must be > 0)")
31
+ end
32
+
33
+ args.each do |arg|
34
+ unless arg.is_a?(String)
35
+ raise Puppet::ParseError, "#{arg.inspect} is not a string."
36
+ end
37
+
38
+ begin
39
+ unless IPAddr.new(arg).ipv6?
40
+ raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv6 address."
41
+ end
42
+ rescue *rescuable_exceptions
43
+ raise Puppet::ParseError, "#{arg.inspect} is not a valid IPv6 address."
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,40 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:validate_re, :doc => <<-'ENDHEREDOC') do |args|
3
+ Perform simple validation of a string against one or more regular
4
+ expressions. The first argument of this function should be a string to
5
+ test, and the second argument should be a stringified regular expression
6
+ (without the // delimiters) or an array of regular expressions. If none
7
+ of the regular expressions match the string passed in, compilation will
8
+ abort with a parse error.
9
+
10
+ If a third argument is specified, this will be the error message raised and
11
+ seen by the user.
12
+
13
+ The following strings will validate against the regular expressions:
14
+
15
+ validate_re('one', '^one$')
16
+ validate_re('one', [ '^one', '^two' ])
17
+
18
+ The following strings will fail to validate, causing compilation to abort:
19
+
20
+ validate_re('one', [ '^two', '^three' ])
21
+
22
+ A helpful error message can be returned like this:
23
+
24
+ validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
25
+
26
+ ENDHEREDOC
27
+ if (args.length < 2) or (args.length > 3) then
28
+ raise Puppet::ParseError, ("validate_re(): wrong number of arguments (#{args.length}; must be 2 or 3)")
29
+ end
30
+
31
+ msg = args[2] || "validate_re(): #{args[0].inspect} does not match #{args[1].inspect}"
32
+
33
+ # We're using a flattened array here because we can't call String#any? in
34
+ # Ruby 1.9 like we can in Ruby 1.8
35
+ raise Puppet::ParseError, (msg) unless [args[1]].flatten.any? do |re_str|
36
+ args[0] =~ Regexp.compile(re_str)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,71 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args|
4
+ Validate that the first argument is a string (or an array of strings), and
5
+ less/equal to than the length of the second argument. An optional third
6
+ parameter can be given a the minimum length. It fails if the first
7
+ argument is not a string or array of strings, and if arg 2 and arg 3 are
8
+ not convertable to a number.
9
+
10
+ The following values will pass:
11
+
12
+ validate_slength("discombobulate",17)
13
+ validate_slength(["discombobulate","moo"],17)
14
+ validate_slength(["discombobulate","moo"],17,3)
15
+
16
+ The following valueis will not:
17
+
18
+ validate_slength("discombobulate",1)
19
+ validate_slength(["discombobulate","thermometer"],5)
20
+ validate_slength(["discombobulate","moo"],17,10)
21
+
22
+ ENDHEREDOC
23
+
24
+ raise Puppet::ParseError, "validate_slength(): Wrong number of arguments (#{args.length}; must be 2 or 3)" unless args.length == 2 or args.length == 3
25
+
26
+ input, max_length, min_length = *args
27
+
28
+ begin
29
+ max_length = Integer(max_length)
30
+ raise ArgumentError if max_length <= 0
31
+ rescue ArgumentError, TypeError
32
+ raise Puppet::ParseError, "validate_slength(): Expected second argument to be a positive Numeric, got #{max_length}:#{max_length.class}"
33
+ end
34
+
35
+ if min_length
36
+ begin
37
+ min_length = Integer(min_length)
38
+ raise ArgumentError if min_length < 0
39
+ rescue ArgumentError, TypeError
40
+ raise Puppet::ParseError, "validate_slength(): Expected third argument to be unset or a positive Numeric, got #{min_length}:#{min_length.class}"
41
+ end
42
+ else
43
+ min_length = 0
44
+ end
45
+
46
+ if min_length > max_length
47
+ raise Puppet::ParseError, "validate_slength(): Expected second argument to be larger than third argument"
48
+ end
49
+
50
+ validator = lambda do |str|
51
+ unless str.length <= max_length and str.length >= min_length
52
+ raise Puppet::ParseError, "validate_slength(): Expected length of #{input.inspect} to be between #{min_length} and #{max_length}, was #{input.length}"
53
+ end
54
+ end
55
+
56
+ case input
57
+ when String
58
+ validator.call(input)
59
+ when Array
60
+ input.each_with_index do |arg, pos|
61
+ if arg.is_a? String
62
+ validator.call(arg)
63
+ else
64
+ raise Puppet::ParseError, "validate_slength(): Expected element at array position #{pos} to be a String, got #{arg.class}"
65
+ end
66
+ end
67
+ else
68
+ raise Puppet::ParseError, "validate_slength(): Expected first argument to be a String or Array, got #{input.class}"
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,33 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args|
4
+ Validate that all passed values are string data structures. Abort catalog
5
+ compilation if any value fails this check.
6
+
7
+ The following values will pass:
8
+
9
+ $my_string = "one two"
10
+ validate_string($my_string, 'three')
11
+
12
+ The following values will fail, causing compilation to abort:
13
+
14
+ validate_string(true)
15
+ validate_string([ 'some', 'array' ])
16
+ $undefined = undef
17
+ validate_string($undefined)
18
+
19
+ ENDHEREDOC
20
+
21
+ unless args.length > 0 then
22
+ raise Puppet::ParseError, ("validate_string(): wrong number of arguments (#{args.length}; must be > 0)")
23
+ end
24
+
25
+ args.each do |arg|
26
+ unless arg.is_a?(String)
27
+ raise Puppet::ParseError, ("#{arg.inspect} is not a string. It looks to be a #{arg.class}")
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # values.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:values, :type => :rvalue, :doc => <<-EOS
7
+ When given a hash this function will return the values of that hash.
8
+
9
+ *Examples:*
10
+
11
+ $hash = {
12
+ 'a' => 1,
13
+ 'b' => 2,
14
+ 'c' => 3,
15
+ }
16
+ values($hash)
17
+
18
+ This example would return:
19
+
20
+ [1,2,3]
21
+ EOS
22
+ ) do |arguments|
23
+
24
+ raise(Puppet::ParseError, "values(): Wrong number of arguments " +
25
+ "given (#{arguments.size} for 1)") if arguments.size < 1
26
+
27
+ hash = arguments[0]
28
+
29
+ unless hash.is_a?(Hash)
30
+ raise(Puppet::ParseError, 'values(): Requires hash to work with')
31
+ end
32
+
33
+ result = hash.values
34
+
35
+ return result
36
+ end
37
+ end
38
+
39
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,98 @@
1
+ #
2
+ # values_at.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:values_at, :type => :rvalue, :doc => <<-EOS
7
+ Finds value inside an array based on location.
8
+
9
+ The first argument is the array you want to analyze, and the second element can
10
+ be a combination of:
11
+
12
+ * A single numeric index
13
+ * A range in the form of 'start-stop' (eg. 4-9)
14
+ * An array combining the above
15
+
16
+ *Examples*:
17
+
18
+ values_at(['a','b','c'], 2)
19
+
20
+ Would return ['c'].
21
+
22
+ values_at(['a','b','c'], ["0-1"])
23
+
24
+ Would return ['a','b'].
25
+
26
+ values_at(['a','b','c','d','e'], [0, "2-3"])
27
+
28
+ Would return ['a','c','d'].
29
+ EOS
30
+ ) do |arguments|
31
+
32
+ raise(Puppet::ParseError, "values_at(): Wrong number of " +
33
+ "arguments given (#{arguments.size} for 2)") if arguments.size < 2
34
+
35
+ array = arguments.shift
36
+
37
+ unless array.is_a?(Array)
38
+ raise(Puppet::ParseError, 'values_at(): Requires array to work with')
39
+ end
40
+
41
+ indices = [arguments.shift].flatten() # Get them all ... Pokemon ...
42
+
43
+ if not indices or indices.empty?
44
+ raise(Puppet::ParseError, 'values_at(): You must provide ' +
45
+ 'at least one positive index to collect')
46
+ end
47
+
48
+ result = []
49
+ indices_list = []
50
+
51
+ indices.each do |i|
52
+ if m = i.match(/^(\d+)(\.\.\.?|\-)(\d+)$/)
53
+ start = m[1].to_i
54
+ stop = m[3].to_i
55
+
56
+ type = m[2]
57
+
58
+ if start > stop
59
+ raise(Puppet::ParseError, 'values_at(): Stop index in ' +
60
+ 'given indices range is smaller than the start index')
61
+ elsif stop > array.size - 1 # First element is at index 0 is it not?
62
+ raise(Puppet::ParseError, 'values_at(): Stop index in ' +
63
+ 'given indices range exceeds array size')
64
+ end
65
+
66
+ range = case type
67
+ when /^(\.\.|\-)$/ then (start .. stop)
68
+ when /^(\.\.\.)$/ then (start ... stop) # Exclusive of last element ...
69
+ end
70
+
71
+ range.each { |i| indices_list << i.to_i }
72
+ else
73
+ # Only positive numbers allowed in this case ...
74
+ if not i.match(/^\d+$/)
75
+ raise(Puppet::ParseError, 'values_at(): Unknown format ' +
76
+ 'of given index')
77
+ end
78
+
79
+ # In Puppet numbers are often string-encoded ...
80
+ i = i.to_i
81
+
82
+ if i > array.size - 1 # Same story. First element is at index 0 ...
83
+ raise(Puppet::ParseError, 'values_at(): Given index ' +
84
+ 'exceeds array size')
85
+ end
86
+
87
+ indices_list << i
88
+ end
89
+ end
90
+
91
+ # We remove nil values as they make no sense in Puppet DSL ...
92
+ result = indices_list.collect { |i| array[i] }.compact
93
+
94
+ return result
95
+ end
96
+ end
97
+
98
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,65 @@
1
+ #
2
+ # zip.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:zip, :type => :rvalue, :doc => <<-EOS
7
+ Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments.
8
+
9
+ *Example:*
10
+
11
+ zip(['1','2','3'],['4','5','6'])
12
+
13
+ Would result in:
14
+
15
+ ["1", "4"], ["2", "5"], ["3", "6"]
16
+ EOS
17
+ ) do |arguments|
18
+
19
+ # Technically we support three arguments but only first is mandatory ...
20
+ raise(Puppet::ParseError, "zip(): 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
+ unless a.is_a?(Array) and b.is_a?(Array)
27
+ raise(Puppet::ParseError, 'zip(): Requires array to work with')
28
+ end
29
+
30
+ flatten = arguments[2] if arguments[2]
31
+
32
+ if flatten
33
+ klass = flatten.class
34
+
35
+ # We can have either true or false, or string which resembles boolean ...
36
+ unless [FalseClass, TrueClass, String].include?(klass)
37
+ raise(Puppet::ParseError, 'zip(): Requires either ' +
38
+ 'boolean or string to work with')
39
+ end
40
+
41
+ if flatten.is_a?(String)
42
+ # We consider all the yes, no, y, n and so on too ...
43
+ flatten = case flatten
44
+ #
45
+ # This is how undef looks like in Puppet ...
46
+ # We yield false in this case.
47
+ #
48
+ when /^$/, '' then false # Empty string will be false ...
49
+ when /^(1|t|y|true|yes)$/ then true
50
+ when /^(0|f|n|false|no)$/ then false
51
+ when /^(undef|undefined)$/ then false # This is not likely to happen ...
52
+ else
53
+ raise(Puppet::ParseError, 'zip(): Unknown type of boolean given')
54
+ end
55
+ end
56
+ end
57
+
58
+ result = a.zip(b)
59
+ result = flatten ? result.flatten : result
60
+
61
+ return result
62
+ end
63
+ end
64
+
65
+ # vim: set ts=2 sw=2 et :