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
data/lib/bebox/node.rb ADDED
@@ -0,0 +1,308 @@
1
+ require 'tilt'
2
+ require 'bebox/logger'
3
+
4
+ module Bebox
5
+ class Node
6
+
7
+ include Bebox::Logger
8
+
9
+ attr_accessor :environment, :project_root, :hostname, :ip, :created_at, :started_at, :finished_at
10
+
11
+ def initialize(environment, project_root, hostname, ip)
12
+ self.environment = environment
13
+ self.project_root = project_root
14
+ self.hostname = hostname
15
+ self.ip = ip
16
+ end
17
+
18
+ # Create all files and directories related to an node
19
+ def create
20
+ create_hiera_template
21
+ create_manifests_node
22
+ create_node_checkpoint
23
+ end
24
+
25
+ # Delete all files and directories related to an node
26
+ def remove
27
+ remove_vagrant_box if self.environment == 'vagrant' && prepared_nodes_count > 0
28
+ remove_checkpoints
29
+ remove_hiera_template
30
+ remove_manifests_node
31
+ end
32
+
33
+ # List existing nodes for environment and type (nodes, prepared_nodes)
34
+ def self.list(project_root, environment, node_type)
35
+ Dir["#{environments_path(project_root)}/#{environment}/#{node_type}/*"].map { |f| File.basename(f, ".*") }
36
+ end
37
+
38
+ # Get node checkpoint parameter from the yml file
39
+ def checkpoint_parameter_from_file(node_type, parameter)
40
+ Bebox::Node.checkpoint_parameter_from_file(self.project_root, self.environment, self.hostname, node_type, parameter)
41
+ end
42
+
43
+ # Get node checkpoint parameter from the yml file
44
+ def self.checkpoint_parameter_from_file(project_root, environment, hostname, node_type, parameter)
45
+ node_config = YAML.load_file("#{environments_path(project_root)}/#{environment}/#{node_type}/#{hostname}.yml")
46
+ node_config[parameter]
47
+ end
48
+
49
+ # Prepare the configured nodes
50
+ def prepare
51
+ started_at = DateTime.now.to_s
52
+ prepare_deploy
53
+ prepare_common_installation
54
+ puppet_installation
55
+ create_prepare_checkpoint(started_at)
56
+ end
57
+
58
+ # Deploy the puppet prepare directory
59
+ def prepare_deploy
60
+ `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy:setup -S phase=node_prepare HOSTS=#{self.hostname}`
61
+ `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy -S phase=node_prepare HOSTS=#{self.hostname}`
62
+ end
63
+
64
+ # Execute through capistrano the common development installation packages
65
+ def prepare_common_installation
66
+ `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy:prepare_installation:common -S phase=node_prepare HOSTS=#{self.hostname}`
67
+ end
68
+
69
+ # Execute through capistrano the puppet installation
70
+ def puppet_installation
71
+ `cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} deploy:prepare_installation:puppet -S phase=node_prepare HOSTS=#{self.hostname}`
72
+ end
73
+
74
+ # Create the checkpoints for the prepared nodes
75
+ def create_prepare_checkpoint(started_at)
76
+ self.started_at = started_at
77
+ self.finished_at = DateTime.now.to_s
78
+ node_template = Tilt::ERBTemplate.new("#{Bebox::Node::templates_path}/node/prepared_node.yml.erb")
79
+ File.open("#{self.project_root}/.checkpoints/environments/#{self.environment}/prepared_nodes/#{self.hostname}.yml", 'w') do |f|
80
+ f.write node_template.render(nil, :node => self)
81
+ end
82
+ end
83
+
84
+ # Create the puppet hiera template file
85
+ def create_hiera_template
86
+ options = {}
87
+ options[:ssh_key] = Bebox::Project.public_ssh_key_from_file(self.project_root, self.environment)
88
+ options[:project_name] = Bebox::Project.shortname_from_file(self.project_root)
89
+ Bebox::Provision.generate_hiera_for_steps(self.project_root, "node.yaml.erb", self.hostname, options)
90
+ end
91
+
92
+ # Create the node in the puppet manifests file
93
+ def create_manifests_node
94
+ Bebox::Provision.add_node_to_step_manifests(self.project_root, self)
95
+ end
96
+
97
+ # Prepare the vagrant nodes
98
+ def prepare_vagrant
99
+ project_name = Bebox::Project.name_from_file(self.project_root)
100
+ vagrant_box_base = Bebox::Project.vagrant_box_base_from_file(self.project_root)
101
+ configure_local_hosts(project_name)
102
+ add_vagrant_node(project_name, vagrant_box_base)
103
+ end
104
+
105
+ # Add the boxes to vagrant for each node
106
+ def add_vagrant_node(project_name, vagrant_box_base)
107
+ already_installed_boxes = installed_vagrant_box_names
108
+ box_name = "#{project_name}-#{self.hostname}"
109
+ info "Adding server to vagrant: #{self.hostname}..."
110
+ `cd #{self.project_root} && vagrant box add #{box_name} #{vagrant_box_base}` unless already_installed_boxes.include? box_name
111
+ end
112
+
113
+ # Up the vagrant boxes in Vagrantfile
114
+ def self.up_vagrant_nodes(project_root)
115
+ `cd #{project_root} && vagrant up --provision`
116
+ end
117
+
118
+ # Halt the vagrant boxes running
119
+ def self.halt_vagrant_nodes(project_root)
120
+ `cd #{project_root} && vagrant halt`
121
+ end
122
+
123
+ # return an Array with the names of the currently installed vagrant boxes
124
+ # @returns Array
125
+ def installed_vagrant_box_names
126
+ (`cd #{self.project_root} && vagrant box list`).split("\n").map{|vagrant_box| vagrant_box.split(' ').first}
127
+ end
128
+
129
+ # returns an Array of the Node objects for an environment
130
+ # @returns Array
131
+ def self.nodes_in_environment(project_root, environment, node_type)
132
+ node_objects = []
133
+ nodes = Bebox::Node.list(project_root, environment, node_type)
134
+ nodes.each do |hostname|
135
+ ip = Bebox::Node.checkpoint_parameter_from_file(project_root, environment, hostname, node_type, 'ip')
136
+ node_objects << Bebox::Node.new(environment, project_root, hostname, ip)
137
+ end
138
+ node_objects
139
+ end
140
+
141
+ # Generate the Vagrantfile
142
+ def self.generate_vagrantfile(project_root, nodes)
143
+ template = Tilt::ERBTemplate.new("#{templates_path}/node/Vagrantfile.erb")
144
+ network_interface = RUBY_PLATFORM =~ /darwin/ ? 'en0' : 'eth0'
145
+ project_name = Bebox::Project.name_from_file(project_root)
146
+ vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(project_root)
147
+ File.open("#{project_root}/Vagrantfile", 'w') do |f|
148
+ f.write template.render(nil, :nodes => nodes, :project_name => project_name,
149
+ :vagrant_box_provider => vagrant_box_provider, :network_interface => network_interface)
150
+ end
151
+ end
152
+
153
+ # Backup and add the vagrant hosts to local hosts file
154
+ def configure_local_hosts(project_name)
155
+ info "\nPlease provide your account password, if ask you, to configure the local hosts file."
156
+ backup_local_hosts(project_name)
157
+ add_to_local_hosts
158
+ end
159
+
160
+ # Add the vagrant hosts to the local hosts file
161
+ def add_to_local_hosts
162
+ # Get the content of the hosts file
163
+ hosts_content = File.read("#{local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
164
+ # Put the node lines in hosts file if not exist
165
+ line = "#{self.ip} #{self.hostname}"
166
+ node_present = (hosts_content =~ /#{self.ip}\s+#{self.hostname}/) ? true : false
167
+ `echo '#{line} # Added by bebox' >> #{local_hosts_path}/hosts` unless node_present
168
+ end
169
+
170
+ # Backup the local hosts file
171
+ def backup_local_hosts(project_name)
172
+ # Make a backup of hosts file
173
+ hosts_backup_file = "#{local_hosts_path}/hosts_before_#{project_name}"
174
+ `sudo cp #{local_hosts_path}/hosts #{hosts_backup_file}` unless File.exist?(hosts_backup_file)
175
+ end
176
+
177
+ # Obtain the local hosts file for the OS
178
+ def local_hosts_path
179
+ RUBY_PLATFORM =~ /darwin/ ? '/private/etc' : '/etc'
180
+ end
181
+
182
+ # Create checkpoint for node
183
+ def create_node_checkpoint
184
+ # Set the creation time for the node
185
+ self.created_at = DateTime.now.to_s
186
+ # Create the checkpoint file from template
187
+ node_template = Tilt::ERBTemplate.new("#{Bebox::Node::templates_path}/node/node.yml.erb")
188
+ File.open("#{self.project_root}/.checkpoints/environments/#{self.environment}/nodes/#{self.hostname}.yml", 'w') do |f|
189
+ f.write node_template.render(nil, :node => self)
190
+ end
191
+ end
192
+
193
+ # Remove checkpoints for node
194
+ def remove_checkpoints
195
+ `cd #{self.project_root} && rm -rf .checkpoints/environments/#{self.environment}/{nodes,prepared_nodes,steps/step-{0..3}}/#{self.hostname}.yml`
196
+ end
197
+
198
+ # Remove puppet hiera template file
199
+ def remove_hiera_template
200
+ Bebox::Provision.remove_hiera_for_steps(self.project_root, self.hostname)
201
+ end
202
+
203
+ # Remove node from puppet manifests
204
+ def remove_manifests_node
205
+ Bebox::Provision.remove_node_for_steps(self.project_root, self.hostname)
206
+ end
207
+
208
+ # Remove the specified boxes from vagrant
209
+ def remove_vagrant_box
210
+ project_name = Bebox::Project.name_from_file(self.project_root)
211
+ vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(self.project_root)
212
+ `cd #{self.project_root} && vagrant destroy -f #{self.hostname}`
213
+ `cd #{self.project_root} && vagrant box remove #{project_name}-#{self.hostname} --provider #{vagrant_box_provider}`
214
+ end
215
+
216
+ # Get the templates path inside the gem
217
+ def self.templates_path
218
+ File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
219
+ end
220
+
221
+ # Get the environments path for project
222
+ def self.environments_path(project_root)
223
+ "#{project_root}/.checkpoints/environments"
224
+ end
225
+
226
+ # Regenerate the deploy file for the environment
227
+ def self.regenerate_deploy_file(project_root, environment, nodes)
228
+ template_name = (environment == 'vagrant') ? 'vagrant' : "environment"
229
+ config_deploy_template = Tilt::ERBTemplate.new("#{templates_path}/project/config/deploy/#{template_name}.erb")
230
+ File.open("#{project_root}/config/deploy/#{environment}.rb", 'w') do |f|
231
+ f.write config_deploy_template.render(nil, :nodes => nodes, :environment => environment)
232
+ end
233
+ end
234
+
235
+ # Return the running status of vagrant node
236
+ def vagrant_box_running?
237
+ status = `cd #{self.project_root} && vagrant status`
238
+ (status =~ /#{self.hostname}\s+running/) ? true : false
239
+ end
240
+
241
+ # Return the existence status of vagrant node
242
+ def vagrant_box_exist?
243
+ vagrant_boxes = `cd #{project_root} && vagrant box list`
244
+ project_name = Bebox::Project.name_from_file(self.project_root)
245
+ vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(self.project_root)
246
+ (vagrant_boxes =~ /#{project_name}-#{self.hostname}\s+\(#{vagrant_box_provider}/) ? true : false
247
+ end
248
+
249
+ # Count the number of prepared nodes
250
+ def prepared_nodes_count
251
+ Bebox::Node.list(self.project_root, self.environment, 'prepared_nodes').count
252
+ end
253
+
254
+ # Return a description string for the node provision state
255
+ def self.node_provision_state(project_root, environment, node)
256
+ provision_state = ''
257
+ checkpoint_directories = %w{nodes prepared_nodes steps/step-0 steps/step-1 steps/step-2 steps/step-3}
258
+ checkpoint_directories.each do |checkpoint_directory|
259
+ checkpoint_directory_path = "#{project_root}/.checkpoints/environments/#{environment}/#{checkpoint_directory}/#{node}.yml"
260
+ if File.exist?(checkpoint_directory_path)
261
+ creation_date = Bebox::Node.node_creation_date(project_root, environment, checkpoint_directory, node)
262
+ provision_state = "#{state_from_checkpoint(checkpoint_directory)} at #{creation_date}"
263
+ end
264
+ end
265
+ provision_state
266
+ end
267
+
268
+ # Get the corresponding state from checkpoint directory
269
+ def self.state_from_checkpoint(checkpoint)
270
+ case checkpoint
271
+ when 'nodes'
272
+ 'Allocated'
273
+ when 'prepared_nodes'
274
+ 'Prepared'
275
+ when 'steps/step-0'
276
+ 'Provisioned Fundamental step-0'
277
+ when 'steps/step-1'
278
+ 'Provisioned Users layer step-1'
279
+ when 'steps/step-2'
280
+ 'Provisioned Services layer step-2'
281
+ when 'steps/step-3'
282
+ 'Provisioned Security layer step-3'
283
+ end
284
+ end
285
+
286
+ # Obtain the node creation_at of finished_at parameter of a node
287
+ def self.node_creation_date(project_root, environment, node_type, node)
288
+ node_config = YAML.load_file("#{project_root}/.checkpoints/environments/#{environment}/#{node_type}/#{node}.yml")
289
+ (node_type == 'nodes') ? node_config['created_at'] : node_config['finished_at']
290
+ end
291
+
292
+ # Count the number of nodes in all environments
293
+ def self.count_all_nodes_by_type(project_root, node_type)
294
+ nodes_count = 0
295
+ environments = Bebox::Environment.list(project_root)
296
+ environments.each do |environment|
297
+ nodes_count += Bebox::Node.list(project_root, environment, node_type).count
298
+ end
299
+ nodes_count
300
+ end
301
+
302
+ # Restore the previous local hosts file
303
+ def restore_local_hosts(project_name)
304
+ `sudo cp #{local_hosts_path}/hosts_before_#{project_name} #{local_hosts_path}/hosts`
305
+ `sudo rm #{local_hosts_path}/hosts_before_#{project_name}`
306
+ end
307
+ end
308
+ end
@@ -0,0 +1,102 @@
1
+ require 'tilt'
2
+
3
+ module Bebox
4
+ class Profile
5
+
6
+ attr_accessor :project_root, :name, :path
7
+
8
+ def initialize(name, project_root, path)
9
+ self.project_root = project_root
10
+ self.name = name
11
+ self.path = path
12
+ end
13
+
14
+ # Create all files and directories related to a profile
15
+ def create
16
+ create_profile_directory
17
+ generate_manifests_file
18
+ generate_puppetfile
19
+ end
20
+
21
+ # Delete all files and directories related to a profile
22
+ def remove
23
+ `cd #{self.project_root} && rm -r puppet/profiles/#{relative_path}`
24
+ end
25
+
26
+ # Lists existing profiles
27
+ def self.list(project_root)
28
+ Dir.chdir("#{project_root}/puppet/profiles") { Dir.glob("**/manifests").map{ |f| File.dirname(f) } }
29
+ # Dir["#{project_root}/puppet/profiles/*"].map { |f| File.basename(f) }
30
+ end
31
+
32
+ # Create the directories for the profile
33
+ def create_profile_directory
34
+ `cd #{self.project_root} && mkdir -p puppet/profiles/#{relative_path}/manifests`
35
+ end
36
+
37
+ # Generate the manifests init.pp file
38
+ def generate_manifests_file
39
+ manifests_template = Tilt::ERBTemplate.new("#{templates_path}/puppet/profiles/manifests/init.pp.erb")
40
+ File.open("#{absolute_path}/manifests/init.pp", 'w') do |f|
41
+ f.write manifests_template.render(nil, :profile => self)
42
+ end
43
+ end
44
+
45
+ # Generate the Puppetfile
46
+ def generate_puppetfile
47
+ puppetfile_template = Tilt::ERBTemplate.new("#{templates_path}/puppet/profiles/Puppetfile.erb")
48
+ File.open("#{absolute_path}/Puppetfile", 'w') do |f|
49
+ f.write puppetfile_template.render(nil)
50
+ end
51
+ end
52
+
53
+ # Path to the templates directory in the gem
54
+ def templates_path
55
+ File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
56
+ end
57
+
58
+ # Path to the profile directory in the project
59
+ def absolute_path
60
+ "#{self.project_root}/puppet/profiles/#{relative_path}"
61
+ end
62
+
63
+ # Counts existing profiles
64
+ def self.profiles_count(project_root)
65
+ Bebox::Profile.list(project_root).count
66
+ end
67
+
68
+ # Check if the profile has a valid name
69
+ def self.valid_name?(name)
70
+ valid_name = (name =~ /\A[a-z][a-z0-9_]*\Z/).nil? ? false : true
71
+ valid_name && !Bebox::RESERVED_WORDS.include?(name)
72
+ end
73
+
74
+ # Check if the profile has a valid path name
75
+ def self.valid_pathname?(pathname)
76
+ #Split the name and validate each path part
77
+ pathname.split('/').each do |path_child|
78
+ valid_name = (path_child =~ /\A[a-z][a-z0-9_]*\Z/).nil? ? false : true
79
+ valid_name && !Bebox::RESERVED_WORDS.include?(path_child)
80
+ return false unless valid_name
81
+ end
82
+ # Return true if all parts are valid
83
+ true
84
+ end
85
+
86
+ # Clean a path to make it valid
87
+ def self.cleanpath(path_name)
88
+ valid_path = Pathname.new(path_name).cleanpath.to_path.split('/').reject{|c| c.empty? }
89
+ return valid_path.nil? ? '' : valid_path.join('/')
90
+ end
91
+
92
+ # Create the profile path relative to the project
93
+ def relative_path
94
+ File.join("#{self.path}", "#{self.name}")
95
+ end
96
+
97
+ # Generate the namespace name from the profile relative path
98
+ def namespace_name
99
+ relative_path.gsub('/','::')
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,259 @@
1
+ require 'tilt'
2
+ require 'bebox/environment'
3
+ require 'bebox/provision'
4
+ require 'bebox/logger'
5
+
6
+ module Bebox
7
+ class Project
8
+
9
+ include Bebox::Logger
10
+
11
+ attr_accessor :name, :vagrant_box_base, :parent_path, :vagrant_box_provider, :environments, :path, :created_at
12
+
13
+ def initialize(name, vagrant_box_base, parent_path, vagrant_box_provider, default_environments = [])
14
+ self.name = name
15
+ self.vagrant_box_base = vagrant_box_base
16
+ self.parent_path = parent_path
17
+ self.vagrant_box_provider = vagrant_box_provider
18
+ self.environments = []
19
+ self.path = "#{self.parent_path}/#{self.name}"
20
+ default_environments.each do |env|
21
+ self.environments << Bebox::Environment.new(env, self.path)
22
+ end
23
+ end
24
+
25
+ # Project creation phase
26
+ def create
27
+ create_project_directory
28
+ create_puppet_base
29
+ create_project_config
30
+ create_checkpoints
31
+ info "Bundle project ..."
32
+ bundle_project
33
+ end
34
+
35
+ # Obtain the project name without 'bebox-' prefix
36
+ def shortname
37
+ self.name.gsub("bebox-", "")
38
+ end
39
+
40
+ # Create project directory
41
+ def create_project_directory
42
+ `mkdir -p #{self.parent_path}/#{self.name}`
43
+ end
44
+
45
+ # Generate project config files
46
+ def create_project_config
47
+ # Create deploy directories
48
+ create_config_deploy_directories
49
+ # Generate dot files
50
+ generate_dot_bebox_file
51
+ generate_gitignore_file
52
+ # Generate ruby version file
53
+ generate_ruby_version
54
+ # Generate Capfile and deploy files
55
+ create_capfile
56
+ generate_deploy_file
57
+ # Generate Gemfile
58
+ create_gemfile
59
+ # Create the default environments
60
+ create_default_environments
61
+ end
62
+
63
+ # Get Project vagrant box provider from the .bebox file
64
+ def self.vagrant_box_provider_from_file(project_root)
65
+ project_config = YAML.load_file("#{project_root}/.bebox")
66
+ project_config['vagrant_box_provider']
67
+ end
68
+
69
+ # Get Project vagrant box base from the .bebox file
70
+ def self.vagrant_box_base_from_file(project_root)
71
+ project_config = YAML.load_file("#{project_root}/.bebox")
72
+ project_config['vagrant_box_base']
73
+ end
74
+
75
+ # Get short project name from the .bebox file
76
+ def self.shortname_from_file(project_root)
77
+ project_name = self.name_from_file(project_root)
78
+ project_name.gsub("bebox-", "")
79
+ end
80
+
81
+ # Get Project name from the .bebox file
82
+ def self.name_from_file(project_root)
83
+ project_config = YAML.load_file("#{project_root}/.bebox")
84
+ project_config['project']
85
+ end
86
+
87
+ # Create rbenv local
88
+ def generate_ruby_version
89
+ File.open("#{self.path}/.ruby-version", 'w') do |f|
90
+ f.write RUBY_VERSION
91
+ end
92
+ end
93
+
94
+ # Generate .bebox file
95
+ def generate_dot_bebox_file
96
+ # Set the creation time for the project
97
+ self.created_at = DateTime.now.to_s
98
+ # Create the .bebox file from template
99
+ dotbebox_template = Tilt::ERBTemplate.new("#{Bebox::Project.templates_path}/project/dot_bebox.erb")
100
+ File.open("#{self.path}/.bebox", 'w') do |f|
101
+ f.write dotbebox_template.render(nil, project: self)
102
+ end
103
+ end
104
+
105
+ # Generate .gitignore file
106
+ def generate_gitignore_file
107
+ gitignore_template = Tilt::ERBTemplate.new("#{Bebox::Project.templates_path}/project/gitignore.erb")
108
+ File.open("#{self.path}/.gitignore", 'w') do |f|
109
+ f.write gitignore_template.render(nil, steps: Bebox::PROVISION_STEP_NAMES)
110
+ end
111
+ end
112
+
113
+ # Create templates directories
114
+ def create_templates_directories
115
+ `cd #{self.path} && mkdir -p templates/{roles,profiles}`
116
+ end
117
+
118
+ # Create the default base roles and profiles in the project
119
+ def copy_default_roles_profiles
120
+ # Copy default roles and profiles to project templates directory
121
+ `cp -R #{Bebox::Project.templates_path}/puppet/default_roles/* #{self.path}/templates/roles/`
122
+ `cp -R #{Bebox::Project.templates_path}/puppet/default_profiles/* #{self.path}/templates/profiles/`
123
+ # Copy default roles and profiles to project roles and profiles available
124
+ `cp -R #{Bebox::Project.templates_path}/puppet/default_roles/* #{self.path}/puppet/roles/`
125
+ `cp -R #{Bebox::Project.templates_path}/puppet/default_profiles/* #{self.path}/puppet/profiles/`
126
+ end
127
+
128
+ # Create config deploy and keys directories
129
+ def create_config_deploy_directories
130
+ `cd #{self.path} && mkdir -p config/{deploy,keys/environments}`
131
+ end
132
+
133
+ # Create the default environments
134
+ def create_default_environments
135
+ self.environments.map{|environment| environment.create}
136
+ end
137
+
138
+ # Create Capfile for the project
139
+ def create_capfile
140
+ capfile_content = File.read("#{Bebox::Project.templates_path}/project/Capfile.erb")
141
+ File::open("#{self.path}/Capfile", "w")do |f|
142
+ f.write(capfile_content)
143
+ end
144
+ end
145
+
146
+ # Create Gemfile for the project
147
+ def create_gemfile
148
+ gemfile_content = File.read("#{Bebox::Project.templates_path}/project/Gemfile.erb")
149
+ File::open("#{self.path}/Gemfile", "w")do |f|
150
+ f.write(gemfile_content)
151
+ end
152
+ end
153
+
154
+ # Create puppet base directories and files
155
+ def create_puppet_base
156
+ # Create templates directories
157
+ create_templates_directories
158
+ # Generate SO dependencies files
159
+ generate_so_dependencies_files
160
+ # Copy puppet install files
161
+ copy_puppet_install_files
162
+ # Generate steps directories
163
+ generate_steps_directories
164
+ # Generate steps templates
165
+ generate_steps_templates
166
+ # Copy the default_roles and default_profiles to project
167
+ copy_default_roles_profiles
168
+ end
169
+
170
+ # Generate steps directories
171
+ def generate_steps_directories
172
+ Bebox::PROVISION_STEP_NAMES.each{|step| `cd #{self.path} && mkdir -p puppet/steps/#{step}/{hiera/data,manifests,modules}`}
173
+ `cd #{self.path} && mkdir -p puppet/{roles,profiles}`
174
+ end
175
+
176
+ # Generate steps templates for hiera and manifests files
177
+ def generate_steps_templates
178
+ Bebox::PROVISION_STEPS.each do |step|
179
+ ssh_key = ''
180
+ step_dir = Bebox::Provision.step_name(step)
181
+ templates_path = Bebox::Project::templates_path
182
+ # Generate site.pp template
183
+ manifest_template = Tilt::ERBTemplate.new("#{templates_path}/puppet/#{step}/manifests/site.pp.erb")
184
+ File.open("#{self.path}/puppet/steps/#{step_dir}/manifests/site.pp", 'w') do |f|
185
+ f.write manifest_template.render(nil, :nodes => [])
186
+ end
187
+ # Generate hiera.yaml template
188
+ hiera_template = Tilt::ERBTemplate.new("#{templates_path}/puppet/#{step}/hiera/hiera.yaml.erb")
189
+ File.open("#{self.path}/puppet/steps/#{step_dir}/hiera/hiera.yaml", 'w') do |f|
190
+ f.write hiera_template.render(nil, :step_dir => step_dir)
191
+ end
192
+ # Generate common.yaml template
193
+ hiera_template = Tilt::ERBTemplate.new("#{templates_path}/puppet/#{step}/hiera/data/common.yaml.erb")
194
+ File.open("#{self.path}/puppet/steps/#{step_dir}/hiera/data/common.yaml", 'w') do |f|
195
+ f.write hiera_template.render(nil, :step_dir => step_dir, :ssh_key => ssh_key, :project_name => self.shortname)
196
+ end
197
+ end
198
+ end
199
+
200
+ # Copy puppet install files
201
+ def copy_puppet_install_files
202
+ `cd #{self.path} && mkdir -p puppet/lib/deb`
203
+ `cp -R #{lib_path}/deb/* #{self.path}/puppet/lib/deb/`
204
+ end
205
+
206
+ # Generate SO dependencies files
207
+ def generate_so_dependencies_files
208
+ `cd #{self.path} && mkdir -p puppet/prepare/dependencies/ubuntu`
209
+ ubuntu_dependencies_content = File.read("#{Bebox::Project.templates_path}/project/ubuntu_dependencies")
210
+ File::open("#{self.path}/puppet/prepare/dependencies/ubuntu/packages", "w")do |f|
211
+ f.write(ubuntu_dependencies_content)
212
+ end
213
+ end
214
+
215
+ def self.so_dependencies
216
+ File.read("#{Bebox::Project.templates_path}/project/ubuntu_dependencies").gsub(/\s+/, ' ')
217
+ end
218
+
219
+ # Create checkpoints base directories
220
+ def create_checkpoints
221
+ `cd #{self.path} && mkdir -p .checkpoints/environments`
222
+ end
223
+
224
+ # Bundle install packages for project
225
+ def bundle_project
226
+ system("cd #{self.path} && BUNDLE_GEMFILE=Gemfile bundle install")
227
+ end
228
+
229
+ # Generate the deploy file for the project
230
+ def generate_deploy_file
231
+ config_deploy_template = Tilt::ERBTemplate.new("#{Bebox::Project.templates_path}/project/config/deploy.erb")
232
+ File.open("#{self.path}/config/deploy.rb", 'w') do |f|
233
+ f.write config_deploy_template.render(nil, project: self)
234
+ end
235
+ end
236
+
237
+ # Path to the lib directory in the gem
238
+ def lib_path
239
+ File.expand_path '..', File.dirname(__FILE__)
240
+ end
241
+
242
+ # Path to the templates directory in the gem
243
+ def self.templates_path
244
+ # File.expand_path(File.join(File.dirname(__FILE__), "..", "gems/bundler/lib/templates"))
245
+ File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
246
+ end
247
+
248
+ # Obtain the ssh public key from file in environment
249
+ def self.public_ssh_key_from_file(project_root, environment)
250
+ ssh_key_path = "#{project_root}/config/keys/environments/#{environment}/id_rsa.pub"
251
+ return (File.exist?(ssh_key_path)) ? File.read(ssh_key_path).strip : ''
252
+ end
253
+
254
+ # Delete all files referent to a project
255
+ def destroy
256
+ `cd #{self.parent_path} && rm -rf #{self.name}`
257
+ end
258
+ end
259
+ end