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,175 @@
1
+ require 'bebox/project'
2
+ require 'net/http'
3
+ require 'uri'
4
+
5
+ module Bebox
6
+ class ProjectWizard
7
+ include Bebox::Logger
8
+ # Bebox boxes directory
9
+ BEBOX_BOXES_PATH = '~/.bebox/boxes'
10
+
11
+ # Asks for the project parameters and create the project skeleton
12
+ def create_new_project(project_name)
13
+ # Check project existence
14
+ return error('Project not created. There is already a project with that name in the current directory.') if project_exists?(Dir.pwd, project_name)
15
+ # Setup the bebox boxes directory
16
+ bebox_boxes_setup
17
+ # Asks to choose an existing box
18
+ current_box = choose_box(get_existing_boxes)
19
+ # If choose to download/select new box
20
+ if current_box.nil?
21
+ # Keep asking for valid uri or overwriting until confirmation
22
+ confirm = false
23
+ begin
24
+ # Asks vagrant box location to user if not choose an existing box
25
+ valid_box_uri = ask_uri
26
+ # Confirm if the box already exist
27
+ confirm = box_exists?(valid_box_uri) ? confirm_overwrite? : true
28
+ end while !confirm
29
+ # Setup the box with the valid uri
30
+ set_box(valid_box_uri)
31
+ else
32
+ valid_box_uri = current_box
33
+ end
34
+ vagrant_box_base = "#{BEBOX_BOXES_PATH}/#{valid_box_uri}"
35
+ # Asks user to choose vagrant box provider
36
+ vagrant_box_provider = ask_box_provider
37
+ # Set default environments
38
+ default_environments = %w{vagrant staging production}
39
+ # Project creation
40
+ project = Bebox::Project.new(project_name, vagrant_box_base, Dir.pwd, vagrant_box_provider, default_environments)
41
+ project.create
42
+ ok "Project '#{project_name}' created!.\nMake: cd #{project_name}\nNow you can add new environments or new nodes to your project.\nSee bebox help."
43
+ end
44
+
45
+ # Check if there's an existing project in that dir
46
+ def project_exists?(parent_path, project_name)
47
+ Dir.exists?("#{parent_path}/#{project_name}")
48
+ end
49
+
50
+ # Menu to choose vagrant box provider
51
+ def ask_box_provider
52
+ choose do |menu|
53
+ menu.header = title('Choose the vagrant box provider')
54
+ menu.choices('virtualbox', 'vmware')
55
+ end
56
+ end
57
+
58
+ # Setup the bebox boxes directory
59
+ def bebox_boxes_setup
60
+ # Create user project directories
61
+ `mkdir -p #{BEBOX_BOXES_PATH}/tmp`
62
+ # Clear partial downloaded boxes
63
+ `rm -f #{BEBOX_BOXES_PATH}/tmp/*`
64
+ end
65
+
66
+ # Asks vagrant box location to user until is valid
67
+ def ask_uri
68
+ vbox_uri = ask(highline_quest('Write the URI (http, local_path) for the vagrant box to be used in the project:')) do |q|
69
+ q.default = 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box'
70
+ end
71
+ # If valid return uri if not keep asking for uri
72
+ uri_valid?(vbox_uri) ? (return vbox_uri) : ask_uri
73
+ end
74
+
75
+ # Setup the box in the bebox boxes directory
76
+ def set_box(box_uri)
77
+ uri = URI.parse(box_uri)
78
+ if uri.scheme == ('http' || 'https')
79
+ download_box(uri)
80
+ else
81
+ file_name = uri.path.split('/').last
82
+ `ln -fs #{uri.path} #{BEBOX_BOXES_PATH}/#{file_name}`
83
+ end
84
+ end
85
+
86
+ # Validate uri download or local box existence
87
+ def uri_valid?(vbox_uri)
88
+ uri = URI.parse(vbox_uri)
89
+ if uri.scheme == ('http' || 'https')
90
+ request = Net::HTTP.new uri.host
91
+ response = request.request_head uri.path
92
+ if response.code.to_i == 302
93
+ uri = URI.parse(response['location'])
94
+ request = Net::HTTP.new uri.host
95
+ response = request.request_head uri.path
96
+ end
97
+ ( response.code.to_i == 200) ? (return true) : error('Download link not valid!.')
98
+ else
99
+ File.file?(uri.path) ? (return true) : error('File path not exist!.')
100
+ end
101
+ end
102
+
103
+ # Ask for confirmation of overwrite a box
104
+ def confirm_overwrite?
105
+ quest 'There is already a box with that name, do you want to overwrite it?'
106
+ response = ask(highline_quest('(y/n)')) do |q|
107
+ q.default = 'n'
108
+ end
109
+ return response == 'y' ? true : false
110
+ end
111
+
112
+ # Check if a box with the same name already exist
113
+ def box_exists?(valid_box_uri)
114
+ box_name = valid_box_uri.split('/').last
115
+ boxes = get_existing_boxes
116
+ boxes.any? { |val| /#{box_name}/ =~ val }
117
+ end
118
+
119
+ # Obtain the current boxes downloaded or linked in the bebox user home
120
+ def get_existing_boxes
121
+ # Converts the bebox boxes directory to an absolute pathname
122
+ expanded_directory = File.expand_path("#{BEBOX_BOXES_PATH}")
123
+ # Get an array of bebox boxes paths
124
+ Dir["#{expanded_directory}/*"].reject {|f| File.directory? f}
125
+ end
126
+
127
+ # Asks to choose an existing box in the bebox boxes directory
128
+ def choose_box(boxes)
129
+ # Menu to choose vagrant box provider
130
+ other_box_message = 'Download/Select a new box'
131
+ current_box = choose do |menu|
132
+ menu.header = title('Choose an existing box or download/select a new box')
133
+ boxes.each do |box|
134
+ menu.choice(box.split('/').last)
135
+ end
136
+ menu.choice(other_box_message)
137
+ end
138
+ current_box = (current_box == other_box_message) ? nil : current_box
139
+ end
140
+
141
+ # Download a box by the specified uri
142
+ def download_box(uri)
143
+ require 'progressbar'
144
+ info 'Downloading box ...'
145
+ @counter = 0
146
+ # Manage redirections
147
+ request = Net::HTTP.new uri.host
148
+ response = request.request_head uri.path
149
+ uri = URI.parse(response['location']) if response.code.to_i == 302
150
+
151
+ # Set url variables
152
+ url = uri.path
153
+ url_base = uri.host
154
+ file_name = uri.path.split('/').last
155
+ expanded_directory = File.expand_path("#{BEBOX_BOXES_PATH}")
156
+
157
+ # Download file to bebox boxes tmp
158
+ Net::HTTP.start(url_base) do |http|
159
+ response = http.request_head(URI.escape(url))
160
+ ProgressBar
161
+ pbar = ProgressBar.new('file name:', response['content-length'].to_i)
162
+ File.open("#{expanded_directory}/tmp/#{file_name}", 'w') {|f|
163
+ http.get(URI.escape(url)) do |str|
164
+ f.write str
165
+ @counter += str.length
166
+ pbar.set(@counter)
167
+ end
168
+ }
169
+ # In download completion move from tmp to bebox boxes dir
170
+ pbar.finish
171
+ `mv #{BEBOX_BOXES_PATH}/tmp/#{file_name} #{BEBOX_BOXES_PATH}/`
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,80 @@
1
+ require 'bebox/provision'
2
+ require 'bebox/node'
3
+
4
+ module Bebox
5
+ class ProvisionWizard
6
+ include Bebox::Logger
7
+ # Apply a step for the nodes in a environment
8
+ def apply_step(project_root, environment, step)
9
+ # Check if environment has configured the ssh keys
10
+ if Bebox::Environment.check_environment_access(project_root, environment)
11
+ # Check already in step nodes
12
+ nodes_to_step = check_nodes_to_step(project_root, environment, step)
13
+ # Output the nodes that are ready for provisioning step-N
14
+ if nodes_to_step.count > 0
15
+ title "Provisioning #{step} in nodes:"
16
+ nodes_to_step.each{|node| msg(node.hostname)}
17
+ linebreak
18
+ # Apply the nodes provisioning for step-N
19
+ nodes_to_step.each do |node|
20
+ title "Applying #{step} in node #{node.hostname}:"
21
+ role = Bebox::Provision.role_from_node(project_root, step, node.hostname)
22
+ profiles = Bebox::Provision.profiles_from_role(project_root, role) unless role.nil?
23
+ # Before apply generate the Puppetfile with modules from all associated profiles
24
+ Bebox::Provision.generate_puppetfile(project_root, step, profiles) unless profiles.nil?
25
+ # Before apply generate the roles and profiles modules structure for puppet step
26
+ Bebox::Provision.generate_roles_and_profiles(project_root, step, role, profiles)
27
+ provision = Bebox::Provision.new(project_root, environment, node, step)
28
+ provision.apply.success? ? (ok "Node '#{node.hostname}' provisioned to #{step}.") : (error "An error ocurred in the provision of #{step} for node '#{node.hostname}'")
29
+ end
30
+ else
31
+ warn "There are no nodes for provision in #{step}. No changes were made."
32
+ end
33
+ else
34
+ warn "Please add a ssh key pair (id_rsa, id_rsa.pub) in config/keys/environments/#{environment} to do this step."
35
+ end
36
+ end
37
+
38
+ # Check the nodes already in step and ask confirmation to re-do-it
39
+ def check_nodes_to_step(project_root, environment, step)
40
+ nodes_to_step = []
41
+ nodes = Bebox::Node.nodes_in_environment(project_root, environment, previous_checkpoint(step))
42
+ in_step_nodes = Bebox::Node.list(project_root, environment, "steps/#{step}")
43
+ nodes.each do |node|
44
+ if in_step_nodes.include?(node.hostname)
45
+ nodes_to_step << node if confirm_node_step?(node, step)
46
+ else
47
+ nodes_to_step << node
48
+ end
49
+ end
50
+ nodes_to_step
51
+ end
52
+
53
+ # Obtain the previous checkpoint (step/phase) for a node
54
+ def previous_checkpoint(step)
55
+ case step
56
+ when 'prepared_nodes'
57
+ 'nodes'
58
+ when 'step-0'
59
+ 'prepared_nodes'
60
+ when 'step-1'
61
+ 'steps/step-0'
62
+ when 'step-2'
63
+ 'steps/step-1'
64
+ when 'step-3'
65
+ 'steps/step-2'
66
+ end
67
+ end
68
+
69
+ # Ask for confirmation of node step
70
+ def confirm_node_step?(node, step)
71
+ node_type = "steps/#{step}"
72
+ checkpoint_status = "(start: #{node.checkpoint_parameter_from_file(node_type, 'started_at')} - end: #{node.checkpoint_parameter_from_file(node_type, 'finished_at')})"
73
+ quest "The node '#{node.hostname}' was already provisioned in #{step} #{checkpoint_status}.\nDo you want to re-provision it?"
74
+ response = ask(highline_quest('(y/n)')) do |q|
75
+ q.default = "n"
76
+ end
77
+ return response == 'y' ? true : false
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,97 @@
1
+ require 'bebox/role'
2
+
3
+ module Bebox
4
+ class RoleWizard
5
+ include Bebox::Logger
6
+ # Create a new role
7
+ def create_new_role(project_root, role_name)
8
+ # Check if the role name is valid
9
+ return error "The role name can only contain:\n
10
+ \n* Lowercase letters
11
+ \n* Numbers
12
+ \n* Underscores
13
+ \n* Must begin with an Lowercase letter
14
+ \n* Can not be any of: #{Bebox::RESERVED_WORDS.join(', ')}
15
+ \n\nNo changes were made." unless Bebox::Role.valid_name?(role_name)
16
+ # Check if the role exist
17
+ return error("The '#{role_name}' role already exist. No changes were made.") if role_exists?(project_root, role_name)
18
+ # Role creation
19
+ role = Bebox::Role.new(role_name, project_root)
20
+ role.create
21
+ ok 'Role created!.'
22
+ end
23
+
24
+ # Removes an existing role
25
+ def remove_role(project_root)
26
+ # Choose a role from the availables
27
+ roles = Bebox::Role.list(project_root)
28
+ # Get a role if exist.
29
+ if roles.count > 0
30
+ role_name = choose_role(roles, 'Choose the role to remove:')
31
+ else
32
+ return error "There are no roles to remove. No changes were made."
33
+ end
34
+ # Ask for deletion confirmation
35
+ return warn('No changes were made.') unless confirm_role_deletion?
36
+ # Role deletion
37
+ role = Bebox::Role.new(role_name, project_root)
38
+ role.remove
39
+ ok 'Role removed!.'
40
+ end
41
+
42
+ # Add a profile to a role
43
+ def add_profile(project_root)
44
+ roles = Bebox::Role.list(project_root)
45
+ profiles = Bebox::Profile.list(project_root)
46
+ role = choose_role(roles, 'Choose an existing role:')
47
+ require 'bebox/wizards/profile_wizard'
48
+ profile = Bebox::ProfileWizard.new.choose_profile(profiles, 'Choose the profile to add:')
49
+ if Bebox::Role.profile_in_role?(project_root, role, profile)
50
+ return warn("Profile '#{profile}' already in the Role '#{role}'. No changes were made.")
51
+ else
52
+ Bebox::Role.add_profile(project_root, role, profile)
53
+ return ok("Profile '#{profile}' added to Role '#{role}'.")
54
+ end
55
+ end
56
+
57
+ # Remove a profile in a role
58
+ def remove_profile(project_root)
59
+ roles = Bebox::Role.list(project_root)
60
+ profiles = Bebox::Profile.list(project_root)
61
+ role = choose_role(roles, 'Choose an existing role:')
62
+ require 'bebox/wizards/profile_wizard'
63
+ profile = Bebox::ProfileWizard.new.choose_profile(profiles, 'Choose the profile to remove:')
64
+ if Bebox::Role.profile_in_role?(project_root, role, profile)
65
+ Bebox::Role.remove_profile(project_root, role, profile)
66
+ return ok("Profile '#{profile}' removed from Role '#{role}'.")
67
+ else
68
+ return warn("Profile '#{profile}' is not in the Role '#{role}'. No changes were made.")
69
+ end
70
+
71
+ end
72
+
73
+ # Asks to choose an existing role
74
+ def choose_role(roles, question)
75
+ choose do |menu|
76
+ menu.header = title(question)
77
+ roles.each do |box|
78
+ menu.choice(box.split('/').last)
79
+ end
80
+ end
81
+ end
82
+
83
+ # Check if there's an existing role in the project
84
+ def role_exists?(project_root, role_name)
85
+ Dir.exists?("#{project_root}/puppet/roles/#{role_name}")
86
+ end
87
+
88
+ # Ask for confirmation of role deletion
89
+ def confirm_role_deletion?
90
+ quest 'Are you sure that you want to delete the role?'
91
+ response = ask(highline_quest('(y/n)')) do |q|
92
+ q.default = "n"
93
+ end
94
+ return response == 'y' ? true : false
95
+ end
96
+ end
97
+ end
data/lib/bebox.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Add requires for other files you add to your project here, so
2
+ # you just need to require this one file in your bin file
@@ -0,0 +1,18 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ <% nodes.each do |vagrant_node| %>
6
+ config.vm.define :'<%= vagrant_node.hostname %>' do |node|
7
+ node.vm.box = "<%= "#{project_name}-#{vagrant_node.hostname}" %>"
8
+ node.vm.hostname = "<%= vagrant_node.hostname %>"
9
+ node.vm.network :public_network, :bridge => '<%= network_interface %>: Ethernet', :auto_config => false
10
+ node.vm.provision :shell, :inline => "sudo ifconfig eth1 <%= vagrant_node.ip %> netmask 255.255.255.0 up"
11
+ end
12
+ config.vm.provider "<%= vagrant_box_provider %>" do |v|
13
+ v.memory = 512
14
+ v.cpus = 1
15
+ v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
16
+ end
17
+ <% end %>
18
+ end
@@ -0,0 +1,3 @@
1
+ <% nodes.each do |node| %>
2
+ server "<%= node.hostname %>", :web, :app, :db
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ hostname: '<%= node.hostname %>'
2
+ ip: '<%= node.ip %>'
3
+ created_at: '<%= node.created_at %>'
@@ -0,0 +1,4 @@
1
+ hostname: '<%= node.hostname %>'
2
+ ip: '<%= node.ip %>'
3
+ started_at: '<%= node.started_at %>'
4
+ finished_at: '<%= node.finished_at %>'
@@ -0,0 +1,4 @@
1
+ hostname: '<%= node.hostname %>'
2
+ ip: '<%= node.ip %>'
3
+ started_at: '<%= node.started_at %>'
4
+ finished_at: '<%= node.finished_at %>'
@@ -0,0 +1,2 @@
1
+ load 'deploy'
2
+ load 'config/deploy'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '0.9.2.2'
4
+ gem 'capistrano', '2.15.5'
5
+ gem 'capistrano-copy-subdir', '0.1.0'
@@ -0,0 +1,40 @@
1
+ set :ssh_key, '<%= "config/keys/environments/#{environment}/id_rsa" %>'
2
+ set(:deploy_via, :copy_subdir)
3
+ set(:deploy_subdir, 'puppet')
4
+ # Select options accord to the phase parameter
5
+ if phase == 'node_prepare'
6
+ set :user, "root"
7
+ set :copy_exclude, ['/profiles', '/roles', '/steps']
8
+ set(:deploy_to) { "/root/code" }
9
+ elsif phase == 'step-0'
10
+ set :user, "root"
11
+ set :copy_exclude, ['/lib', '/prepare', '/profiles', '/roles']
12
+ set(:deploy_to) { "/root/code" }
13
+ else
14
+ set :user, "puppet"
15
+ set :copy_exclude, ['/lib', '/prepare', '/profiles', '/roles']
16
+ set(:deploy_to) { "/home/puppet/code" }
17
+ end
18
+ # set :deploy_via, :copy
19
+ set :scm, :none
20
+ set :repository, "."
21
+
22
+
23
+ set :ssh_options, {
24
+ :keys => ssh_key,
25
+ :port => '22',
26
+ :forward_agent => 'true'
27
+ }
28
+
29
+ # Start nodes definitions
30
+ <% if nodes %>
31
+ <% nodes.each do |node| %>
32
+ server "<%= node.hostname %>", :web, :app, :db
33
+ <% end %>
34
+ <% end %>
35
+ # End nodes definitions
36
+
37
+ desc 'Test the vagrant connection by doing issuing a simple echo command'
38
+ task :probe, roles: [:web, :app, :db] do
39
+ run 'echo $PATH'
40
+ end
@@ -0,0 +1,42 @@
1
+ set(:deploy_via, :copy_subdir)
2
+ set(:deploy_subdir, 'puppet')
3
+ # Select options accord to the phase parameter
4
+ if phase == 'node_prepare'
5
+ set :user, "vagrant"
6
+ set :ssh_key, '~/.vagrant.d/insecure_private_key'
7
+ set :copy_exclude, ['/profiles', '/roles', '/steps']
8
+ set(:deploy_to) { "/home/vagrant/code" }
9
+ elsif phase == 'step-0'
10
+ set :user, "vagrant"
11
+ set :ssh_key, '~/.vagrant.d/insecure_private_key'
12
+ set :copy_exclude, ['/lib', '/prepare', '/profiles', '/roles']
13
+ set(:deploy_to) { "/home/vagrant/code" }
14
+ else
15
+ set :user, "puppet"
16
+ set :ssh_key, '<%= "config/keys/environments/vagrant/id_rsa" %>'
17
+ set :copy_exclude, ['/lib', '/prepare', '/profiles', '/roles']
18
+ set(:deploy_to) { "/home/puppet/code" }
19
+ end
20
+ # set :deploy_via, :copy
21
+ set :scm, :none
22
+ set :repository, "."
23
+
24
+
25
+ set :ssh_options, {
26
+ :keys => ssh_key,
27
+ :port => '22',
28
+ :forward_agent => 'true'
29
+ }
30
+
31
+ # Start nodes definitions
32
+ <% if nodes %>
33
+ <% nodes.each do |node| %>
34
+ server "<%= node.hostname %>", :web, :app, :db
35
+ <% end %>
36
+ <% end %>
37
+ # End nodes definitions
38
+
39
+ desc 'Test the vagrant connection by doing issuing a simple echo command'
40
+ task :probe, roles: [:web, :app, :db] do
41
+ run 'echo $PATH'
42
+ end
@@ -0,0 +1,120 @@
1
+ require 'capistrano/ext/multistage'
2
+
3
+ set :application, "<%= project.shortname %>"
4
+ set :stages, Dir[".checkpoints/*/*"].map{|f| File.basename(f)}
5
+ set :default_stage, 'vagrant'
6
+ set :use_sudo, false
7
+ set :keep_releases, 3
8
+ set :deploy_via, :remote_cache
9
+ default_run_options[:pty] = true
10
+ default_run_options[:shell] = '/bin/bash --login'
11
+ set :normalize_asset_timestamps, false
12
+ set(:facter_variables) { {deploy_environment: stage, deploy_user: user, deploy_to: deploy_to} }
13
+
14
+ before 'puppet:apply', 'puppet:config_hiera'
15
+
16
+ # evaluate if a file exists in a remote server
17
+ def remote_file_exists?(full_path)
18
+ 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
19
+ end
20
+
21
+ # When using puppet apply for example, pass additional facts to Facter
22
+ # @returns an environment variable string like FACTER_custom
23
+ def custom_facter_variables
24
+ facter_variables.map{|facter_key, facter_value| "FACTER_#{facter_key}=#{facter_value}"}.join(' ')
25
+ end
26
+
27
+ namespace :deploy do
28
+
29
+ desc 'Installs tools and required dependencies in the remote machine'
30
+ namespace :prepare_installation do
31
+
32
+ desc 'Install dependencies and command line tools to operate correctly'
33
+ task :common do
34
+ ubuntu.setup
35
+ dependencies
36
+ end
37
+
38
+ desc 'Install puppet on the remote machine (free-standalone) [including dependencies]'
39
+ task :puppet do
40
+ run "#{sudo} apt-get --yes --fix-broken install"
41
+ run "cd #{current_path}/lib/deb/puppet_3.6.0 && #{sudo} dpkg -i *.deb"
42
+ end
43
+
44
+ desc 'Install libraries'
45
+ task :dependencies do
46
+ run "#{sudo} aptitude update"
47
+ run "cd #{current_path}/prepare/dependencies/ubuntu && cat packages|xargs #{sudo} aptitude -y install"
48
+ end
49
+ end
50
+ namespace :ubuntu do
51
+ desc 'Install dependencies and command line tools to opperate correctly'
52
+ task :setup do
53
+ install_aptitude
54
+ set_fqdn
55
+ end
56
+
57
+ desc 'Install aptitude'
58
+ task :install_aptitude do
59
+ run "#{sudo} apt-get update"
60
+ run "#{sudo} apt-get -y install aptitude"
61
+ # run "#{sudo} aptitude -y full-upgrade"
62
+ end
63
+
64
+ desc "Sets the boxes' fully qualified domain name (fqdn), through the 'hostname' command"
65
+ task :set_fqdn do
66
+ run('hostname') do |ch, stream, out|
67
+ if ch[:server].host.strip == out.strip
68
+ puts "The #{ch[:server]} server hostname is configured properly"
69
+ else
70
+ run "#{sudo} hostname #{ch[:server].host}", hosts: ch[:server]
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ namespace :puppet do
78
+
79
+ desc 'Bundle modules listed in the Puppetfile through librarian-puppet'
80
+ task :bundle_modules do
81
+ librarian_path = "#{shared_path}/librarian-puppet/#{step_dir}"
82
+ step_path = "#{current_path}/steps/#{step_dir}"
83
+ # Create shared directories for librarian-puppet
84
+ run "mkdir -p #{librarian_path}/{modules,.tmp}"
85
+ # Check if Puppetfile.lock and .tmp are created for librarian-puppet
86
+ puppetfile_lock = remote_file_exists?("#{librarian_path}/Puppetfile.lock")
87
+ librarian_tmp = remote_file_exists?("#{step_path}/.tmp")
88
+ # Link the modules directory from shared to the step directory
89
+ run "cp -Rf #{step_path}/modules/* #{librarian_path}/modules/"
90
+ run "rm -rf #{step_path}/modules"
91
+ run "ln -fs #{librarian_path}/modules #{step_path}/modules"
92
+ if remote_file_exists?("#{step_path}/Puppetfile")
93
+ # Move the Puppetfile.lock create the first time
94
+ run "ln -fs #{librarian_path}/Puppetfile.lock #{step_path}/Puppetfile.lock" if puppetfile_lock
95
+ # Link the .tmp directory from shared to the step directory
96
+ run "cp -Rf #{step_path}/.tmp/* #{librarian_path}/.tmp/" if librarian_tmp
97
+ run "rm -rf #{step_path}/.tmp"
98
+ run "ln -fs #{librarian_path}/.tmp #{step_path}/.tmp"
99
+ # Execute librarian-puppet module installation
100
+ run "cd #{step_path} && librarian-puppet install"
101
+ # Move the Puppetfile.lock create the first time
102
+ run "mv -f #{step_path}/Puppetfile.lock #{librarian_path}/" unless puppetfile_lock
103
+ end
104
+ end
105
+
106
+ desc 'Applies puppet using the current path puppet repo uploaded through capistrano itself'
107
+ task :apply do
108
+ run 'touch puppet.log'
109
+ run "echo 'Running puppet at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}...' >> puppet.log"
110
+ run "#{sudo} #{custom_facter_variables} puppet apply --debug --verbose --modulepath=#{current_path}/steps/#{step_dir}/modules --parser future --pluginsync #{current_path}/steps/#{step_dir}/manifests/site.pp"
111
+ end
112
+
113
+ desc 'Make a symlink to configure the hiera settings from hiera project directory'
114
+ task :config_hiera do
115
+ remote_hiera_path = "/etc/puppet/hiera.yaml"
116
+ local_hiera_path = "#{current_path}/steps/#{step_dir}/hiera/hiera.yaml"
117
+ puts 'Creating the symlink to hiera.yaml!'
118
+ run "#{sudo} ln -fs #{local_hiera_path} #{remote_hiera_path}"
119
+ end
120
+ end
@@ -0,0 +1,4 @@
1
+ project: '<%= project.name %>'
2
+ vagrant_box_base: '<%= project.vagrant_box_base %>'
3
+ vagrant_box_provider: '<%= project.vagrant_box_provider %>'
4
+ created_at: '<%= project.created_at %>'