bebox 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -8
  3. data/README.md +33 -30
  4. data/bebox.gemspec +1 -2
  5. data/bin/bebox +1 -2
  6. data/lib/bebox/cli.rb +0 -5
  7. data/lib/bebox/commands/commands_helper.rb +3 -1
  8. data/lib/bebox/commands/environment_commands.rb +26 -29
  9. data/lib/bebox/commands/general_commands.rb +0 -1
  10. data/lib/bebox/commands/node_commands.rb +44 -48
  11. data/lib/bebox/commands/prepare_commands.rb +25 -32
  12. data/lib/bebox/commands/profile_commands.rb +56 -0
  13. data/lib/bebox/commands/project_commands.rb +23 -29
  14. data/lib/bebox/commands/provision_commands.rb +18 -120
  15. data/lib/bebox/commands/role_commands.rb +83 -0
  16. data/lib/bebox/environment.rb +4 -10
  17. data/lib/bebox/files_helper.rb +37 -0
  18. data/lib/bebox/logger.rb +0 -1
  19. data/lib/bebox/node.rb +9 -122
  20. data/lib/bebox/profile.rb +5 -16
  21. data/lib/bebox/project.rb +14 -38
  22. data/lib/bebox/provision.rb +21 -36
  23. data/lib/bebox/role.rb +2 -12
  24. data/lib/bebox/vagrant_helper.rb +96 -0
  25. data/lib/bebox/version.rb +1 -1
  26. data/lib/bebox/wizards/environment_wizard.rb +4 -20
  27. data/lib/bebox/wizards/node_wizard.rb +17 -47
  28. data/lib/bebox/wizards/profile_wizard.rb +8 -26
  29. data/lib/bebox/wizards/project_wizard.rb +42 -72
  30. data/lib/bebox/wizards/provision_wizard.rb +35 -51
  31. data/lib/bebox/wizards/role_wizard.rb +9 -29
  32. data/lib/bebox/wizards/wizards_helper.rb +41 -0
  33. data/lib/bebox.rb +30 -2
  34. data/lib/templates/project/config/deploy/steps/step-0.erb +13 -0
  35. data/lib/templates/project/config/deploy/steps/step-1.erb +0 -0
  36. data/lib/templates/project/config/deploy/steps/step-2.erb +0 -0
  37. data/lib/templates/project/config/deploy/steps/step-3.erb +0 -0
  38. data/lib/templates/project/config/deploy.erb +3 -0
  39. data/spec/fixtures/config/deploy/steps/step-0.test +13 -0
  40. data/spec/fixtures/config/deploy/steps/step-1.test +0 -0
  41. data/spec/fixtures/config/deploy/steps/step-2.test +0 -0
  42. data/spec/fixtures/config/deploy/steps/step-3.test +0 -0
  43. data/spec/fixtures/config/deploy.test +3 -0
  44. data/spec/ordered_phases_spec.rb +6 -4
  45. data/spec/pre_prepare_spec.rb +8 -6
  46. data/spec/profile_spec.rb +9 -5
  47. data/spec/project_spec.rb +9 -2
  48. data/spec/puppet_spec_helper.rb +1 -1
  49. data/spec/role_spec.rb +9 -5
  50. data/spec/spec_helper.rb +5 -0
  51. metadata +17 -212
  52. data/lib/templates/puppet/step-0/modules/rbenv/AUTHORS +0 -11
  53. data/lib/templates/puppet/step-0/modules/rbenv/CHANGELOG.md +0 -70
  54. data/lib/templates/puppet/step-0/modules/rbenv/Gemfile +0 -8
  55. data/lib/templates/puppet/step-0/modules/rbenv/Gemfile.lock +0 -28
  56. data/lib/templates/puppet/step-0/modules/rbenv/Modulefile +0 -7
  57. data/lib/templates/puppet/step-0/modules/rbenv/README.md +0 -173
  58. data/lib/templates/puppet/step-0/modules/rbenv/Rakefile +0 -22
  59. data/lib/templates/puppet/step-0/modules/rbenv/TODO +0 -10
  60. data/lib/templates/puppet/step-0/modules/rbenv/bin/autospec +0 -16
  61. data/lib/templates/puppet/step-0/modules/rbenv/bin/facter +0 -16
  62. data/lib/templates/puppet/step-0/modules/rbenv/bin/filebucket +0 -16
  63. data/lib/templates/puppet/step-0/modules/rbenv/bin/hiera +0 -16
  64. data/lib/templates/puppet/step-0/modules/rbenv/bin/htmldiff +0 -16
  65. data/lib/templates/puppet/step-0/modules/rbenv/bin/ldiff +0 -16
  66. data/lib/templates/puppet/step-0/modules/rbenv/bin/pi +0 -16
  67. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet +0 -16
  68. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-lint +0 -16
  69. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-module +0 -16
  70. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetca +0 -16
  71. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetd +0 -16
  72. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetdoc +0 -16
  73. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetmasterd +0 -16
  74. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetqd +0 -16
  75. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetrun +0 -16
  76. data/lib/templates/puppet/step-0/modules/rbenv/bin/rake +0 -16
  77. data/lib/templates/puppet/step-0/modules/rbenv/bin/ralsh +0 -16
  78. data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec +0 -16
  79. data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec-puppet-init +0 -16
  80. data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/provider/rbenvgem/default.rb +0 -50
  81. data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/type/rbenvgem.rb +0 -62
  82. data/lib/templates/puppet/step-0/modules/rbenv/manifests/bundle.pp +0 -36
  83. data/lib/templates/puppet/step-0/modules/rbenv/manifests/client.pp +0 -48
  84. data/lib/templates/puppet/step-0/modules/rbenv/manifests/compile.pp +0 -102
  85. data/lib/templates/puppet/step-0/modules/rbenv/manifests/definition.pp +0 -31
  86. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/centos.pp +0 -25
  87. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/suse.pp +0 -28
  88. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/ubuntu.pp +0 -17
  89. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies.pp +0 -8
  90. data/lib/templates/puppet/step-0/modules/rbenv/manifests/gem.pp +0 -29
  91. data/lib/templates/puppet/step-0/modules/rbenv/manifests/install.pp +0 -55
  92. data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rbenvvars.pp +0 -16
  93. data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rubybuild.pp +0 -16
  94. data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin.pp +0 -40
  95. data/lib/templates/puppet/step-0/modules/rbenv/metadata.json +0 -109
  96. data/lib/templates/puppet/step-0/modules/rbenv/templates/Gemfile.erb +0 -5
  97. data/lib/templates/puppet/step-0/modules/rbenv/templates/dot.rbenvrc.erb +0 -8
  98. data/lib/templates/puppet/step-0/modules/stdlib/CHANGELOG.md +0 -418
  99. data/lib/templates/puppet/step-0/modules/stdlib/CONTRIBUTING.md +0 -65
  100. data/lib/templates/puppet/step-0/modules/stdlib/Gemfile +0 -33
  101. data/lib/templates/puppet/step-0/modules/stdlib/Gemfile.lock +0 -166
  102. data/lib/templates/puppet/step-0/modules/stdlib/LICENSE +0 -19
  103. data/lib/templates/puppet/step-0/modules/stdlib/Modulefile +0 -11
  104. data/lib/templates/puppet/step-0/modules/stdlib/README.markdown +0 -1304
  105. data/lib/templates/puppet/step-0/modules/stdlib/README_DEVELOPER.markdown +0 -35
  106. data/lib/templates/puppet/step-0/modules/stdlib/README_SPECS.markdown +0 -7
  107. data/lib/templates/puppet/step-0/modules/stdlib/RELEASE_PROCESS.markdown +0 -24
  108. data/lib/templates/puppet/step-0/modules/stdlib/Rakefile +0 -18
  109. data/lib/templates/puppet/step-0/modules/stdlib/checksums.json +0 -349
  110. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/facter_dot_d.rb +0 -202
  111. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/pe_version.rb +0 -53
  112. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/puppet_vardir.rb +0 -26
  113. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/root_home.rb +0 -32
  114. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/util/puppet_settings.rb +0 -21
  115. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/abs.rb +0 -36
  116. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/any2array.rb +0 -33
  117. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/base64.rb +0 -37
  118. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +0 -49
  119. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +0 -34
  120. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chomp.rb +0 -35
  121. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chop.rb +0 -37
  122. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/concat.rb +0 -41
  123. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/count.rb +0 -22
  124. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb +0 -44
  125. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +0 -35
  126. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete.rb +0 -46
  127. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +0 -49
  128. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb +0 -34
  129. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_values.rb +0 -26
  130. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/difference.rb +0 -36
  131. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/dirname.rb +0 -15
  132. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/downcase.rb +0 -33
  133. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/empty.rb +0 -28
  134. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +0 -35
  135. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +0 -45
  136. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/flatten.rb +0 -33
  137. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/floor.rb +0 -25
  138. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +0 -46
  139. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +0 -17
  140. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getparam.rb +0 -35
  141. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getvar.rb +0 -26
  142. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/grep.rb +0 -33
  143. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +0 -52
  144. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +0 -25
  145. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +0 -25
  146. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_key.rb +0 -28
  147. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/hash.rb +0 -41
  148. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/intersection.rb +0 -34
  149. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_array.rb +0 -22
  150. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_bool.rb +0 -22
  151. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +0 -50
  152. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_float.rb +0 -30
  153. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb +0 -26
  154. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +0 -22
  155. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +0 -45
  156. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +0 -32
  157. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +0 -27
  158. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +0 -75
  159. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_string.rb +0 -26
  160. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join.rb +0 -41
  161. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +0 -47
  162. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/keys.rb +0 -26
  163. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +0 -20
  164. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +0 -33
  165. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/max.rb +0 -21
  166. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/member.rb +0 -44
  167. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/merge.rb +0 -34
  168. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/min.rb +0 -21
  169. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +0 -43
  170. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +0 -24
  171. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +0 -24
  172. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick.rb +0 -29
  173. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick_default.rb +0 -35
  174. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/prefix.rb +0 -45
  175. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/range.rb +0 -88
  176. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reject.rb +0 -31
  177. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reverse.rb +0 -28
  178. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +0 -32
  179. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +0 -46
  180. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/size.rb +0 -48
  181. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/sort.rb +0 -27
  182. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +0 -36
  183. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +0 -46
  184. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +0 -32
  185. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strftime.rb +0 -107
  186. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strip.rb +0 -39
  187. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/suffix.rb +0 -45
  188. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +0 -39
  189. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/time.rb +0 -49
  190. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +0 -28
  191. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/type.rb +0 -50
  192. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/union.rb +0 -34
  193. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/unique.rb +0 -51
  194. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/upcase.rb +0 -41
  195. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +0 -35
  196. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +0 -56
  197. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +0 -33
  198. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +0 -81
  199. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +0 -34
  200. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb +0 -48
  201. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +0 -33
  202. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb +0 -48
  203. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb +0 -49
  204. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +0 -40
  205. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +0 -71
  206. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +0 -33
  207. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values.rb +0 -39
  208. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values_at.rb +0 -98
  209. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/zip.rb +0 -65
  210. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +0 -83
  211. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/anchor.rb +0 -46
  212. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/file_line.rb +0 -79
  213. data/lib/templates/puppet/step-0/modules/stdlib/manifests/init.pp +0 -20
  214. data/lib/templates/puppet/step-0/modules/stdlib/manifests/stages.pp +0 -43
  215. data/lib/templates/puppet/step-0/modules/stdlib/metadata.json +0 -111
  216. data/lib/templates/puppet/step-0/modules/sudo/.fixtures.yml +0 -5
  217. data/lib/templates/puppet/step-0/modules/sudo/.gemfile +0 -14
  218. data/lib/templates/puppet/step-0/modules/sudo/.gemfile.lock +0 -43
  219. data/lib/templates/puppet/step-0/modules/sudo/.travis.yml +0 -34
  220. data/lib/templates/puppet/step-0/modules/sudo/LICENSE +0 -13
  221. data/lib/templates/puppet/step-0/modules/sudo/Modulefile +0 -9
  222. data/lib/templates/puppet/step-0/modules/sudo/README.md +0 -171
  223. data/lib/templates/puppet/step-0/modules/sudo/Rakefile +0 -1
  224. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.aix +0 -90
  225. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.archlinux +0 -90
  226. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.deb +0 -90
  227. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.freebsd +0 -98
  228. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.omnios +0 -90
  229. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel5 +0 -97
  230. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel6 +0 -115
  231. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.solaris +0 -90
  232. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.suse +0 -81
  233. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.ubuntu +0 -30
  234. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.wheezy +0 -17
  235. data/lib/templates/puppet/step-0/modules/sudo/lib/augeas/lenses/fixedsudoers.aug +0 -520
  236. data/lib/templates/puppet/step-0/modules/sudo/manifests/allow.pp +0 -76
  237. data/lib/templates/puppet/step-0/modules/sudo/manifests/conf.pp +0 -105
  238. data/lib/templates/puppet/step-0/modules/sudo/manifests/configs.pp +0 -24
  239. data/lib/templates/puppet/step-0/modules/sudo/manifests/init.pp +0 -151
  240. data/lib/templates/puppet/step-0/modules/sudo/manifests/package/aix.pp +0 -46
  241. data/lib/templates/puppet/step-0/modules/sudo/manifests/package/solaris.pp +0 -60
  242. data/lib/templates/puppet/step-0/modules/sudo/manifests/package.pp +0 -61
  243. data/lib/templates/puppet/step-0/modules/sudo/manifests/params.pp +0 -127
  244. data/lib/templates/puppet/step-0/modules/sudo/metadata.json +0 -59
  245. data/lib/templates/puppet/step-0/modules/sudo/templates/users_groups.erb +0 -9
data/lib/bebox/project.rb CHANGED
@@ -1,12 +1,9 @@
1
- require 'tilt'
2
- require 'bebox/environment'
3
- require 'bebox/provision'
4
- require 'bebox/logger'
5
1
 
6
2
  module Bebox
7
3
  class Project
8
4
 
9
5
  include Bebox::Logger
6
+ include Bebox::FilesHelper
10
7
 
11
8
  attr_accessor :name, :vagrant_box_base, :parent_path, :vagrant_box_provider, :environments, :path, :created_at
12
9
 
@@ -53,7 +50,7 @@ module Bebox
53
50
  generate_ruby_version
54
51
  # Generate Capfile and deploy files
55
52
  create_capfile
56
- generate_deploy_file
53
+ generate_deploy_files
57
54
  # Generate Gemfile
58
55
  create_gemfile
59
56
  # Create the default environments
@@ -96,18 +93,12 @@ module Bebox
96
93
  # Set the creation time for the project
97
94
  self.created_at = DateTime.now.to_s
98
95
  # 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
96
+ generate_file_from_template("#{Bebox::Project.templates_path}/project/dot_bebox.erb", "#{self.path}/.bebox", {project: self})
103
97
  end
104
98
 
105
99
  # Generate .gitignore file
106
100
  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
101
+ generate_file_from_template("#{Bebox::Project.templates_path}/project/gitignore.erb", "#{self.path}/.gitignore", {steps: Bebox::PROVISION_STEP_NAMES})
111
102
  end
112
103
 
113
104
  # Create templates directories
@@ -127,7 +118,7 @@ module Bebox
127
118
 
128
119
  # Create config deploy and keys directories
129
120
  def create_config_deploy_directories
130
- `cd #{self.path} && mkdir -p config/{deploy,keys/environments}`
121
+ `cd #{self.path} && mkdir -p config/{deploy/steps,keys/environments}`
131
122
  end
132
123
 
133
124
  # Create the default environments
@@ -137,18 +128,12 @@ module Bebox
137
128
 
138
129
  # Create Capfile for the project
139
130
  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
131
+ write_content_to_file("#{path}/Capfile", File.read("#{Bebox::Project.templates_path}/project/Capfile.erb"))
144
132
  end
145
133
 
146
134
  # Create Gemfile for the project
147
135
  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
136
+ write_content_to_file("#{self.path}/Gemfile", File.read("#{Bebox::Project.templates_path}/project/Gemfile.erb"))
152
137
  end
153
138
 
154
139
  # Create puppet base directories and files
@@ -180,20 +165,11 @@ module Bebox
180
165
  step_dir = Bebox::Provision.step_name(step)
181
166
  templates_path = Bebox::Project::templates_path
182
167
  # 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
168
+ generate_file_from_template("#{templates_path}/puppet/#{step}/manifests/site.pp.erb", "#{self.path}/puppet/steps/#{step_dir}/manifests/site.pp", {nodes: []})
187
169
  # 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
170
+ generate_file_from_template("#{templates_path}/puppet/#{step}/hiera/hiera.yaml.erb", "#{self.path}/puppet/steps/#{step_dir}/hiera/hiera.yaml", {step_dir: step_dir})
192
171
  # 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
172
+ generate_file_from_template("#{templates_path}/puppet/#{step}/hiera/data/common.yaml.erb", "#{self.path}/puppet/steps/#{step_dir}/hiera/data/common.yaml", {step_dir: step_dir, ssh_key: ssh_key, project_name: self.shortname})
197
173
  end
198
174
  end
199
175
 
@@ -227,10 +203,10 @@ module Bebox
227
203
  end
228
204
 
229
205
  # 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)
206
+ def generate_deploy_files
207
+ generate_file_from_template("#{Bebox::Project.templates_path}/project/config/deploy.erb", "#{self.path}/config/deploy.rb", {project: self})
208
+ Bebox::PROVISION_STEPS.each do |step|
209
+ generate_file_from_template("#{Bebox::Project.templates_path}/project/config/deploy/steps/#{step}.erb", "#{self.path}/config/deploy/steps/#{step}.rb", {})
234
210
  end
235
211
  end
236
212
 
@@ -1,4 +1,3 @@
1
- require 'tilt'
2
1
 
3
2
  module Bebox
4
3
 
@@ -8,6 +7,8 @@ module Bebox
8
7
 
9
8
  class Provision
10
9
 
10
+ include Bebox::FilesHelper
11
+
11
12
  attr_accessor :environment, :project_root, :node, :step, :started_at, :finished_at
12
13
 
13
14
  def initialize(project_root, environment, node, step)
@@ -32,45 +33,41 @@ module Bebox
32
33
 
33
34
  # Check if it's necessary a Puppetfile accord to it's content
34
35
  def check_puppetfile_content
35
- puppetfile_content = File.read("#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/Puppetfile").strip
36
- `rm "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/Puppetfile"` if puppetfile_content.scan(/^\s*(mod\s*.+?)$/).flatten.empty?
36
+ puppetfile_content = File.read("#{project_root}/puppet/steps/#{step_name}/Puppetfile").strip
37
+ `rm "#{project_root}/puppet/steps/#{step_name}/Puppetfile"` if puppetfile_content.scan(/^\s*(mod\s*.+?)$/).flatten.empty?
37
38
  end
38
39
 
39
40
  # Copy the static modules to the step-N modules path
40
41
  def copy_static_modules
41
- `cp -R #{Bebox::Provision::templates_path}/puppet/#{self.step}/modules/* #{self.project_root}/puppet/steps/#{Bebox::Provision.step_name(self.step)}/modules/`
42
+ `cp -R #{Bebox::FilesHelper::templates_path}/puppet/#{self.step}/modules/* #{self.project_root}/puppet/steps/#{step_name}/modules/`
42
43
  end
43
44
 
44
45
  # Generate the hiera data for step from the template
45
46
  def generate_hiera
47
+ generate_hiera_yaml
48
+ generate_hiera_data_common
49
+ end
50
+
51
+ def generate_hiera_yaml
52
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{self.step}/hiera/hiera.yaml.erb", "#{self.project_root}/puppet/steps/#{step_name}/hiera/hiera.yaml", {step_dir: step_name})
53
+ end
54
+
55
+ def generate_hiera_data_common
46
56
  ssh_key = Bebox::Project.public_ssh_key_from_file(self.project_root, self.environment)
47
57
  project_name = Bebox::Project.shortname_from_file(self.project_root)
48
- hiera_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/puppet/#{self.step}/hiera/hiera.yaml.erb")
49
- File.open("#{self.project_root}/puppet/steps/#{Bebox::Provision.step_name(self.step)}/hiera/hiera.yaml", 'w') do |f|
50
- f.write hiera_template.render(nil, :step_dir => Bebox::Provision.step_name(self.step))
51
- end
52
- common_hiera_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/puppet/#{self.step}/hiera/data/common_apply.yaml.erb")
53
- File.open("#{self.project_root}/puppet/steps/#{Bebox::Provision.step_name(self.step)}/hiera/data/common.yaml", 'w') do |f|
54
- f.write common_hiera_template.render(nil, :ssh_key => ssh_key, :project_name => project_name)
55
- end
58
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{self.step}/hiera/data/common_apply.yaml.erb", "#{self.project_root}/puppet/steps/#{step_name}/hiera/data/common.yaml", {ssh_key: ssh_key, project_name: project_name})
56
59
  end
57
60
 
58
61
  # Generate the site.pp manifests file for step
59
62
  def self.generate_manifests(project_root, step, nodes)
60
- manifest_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/puppet/#{step}/manifests/site_apply.pp.erb", :trim => true)
61
- File.open("#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp", 'w') do |f|
62
- f.write manifest_template.render(nil, :nodes => nodes)
63
- end
63
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{step}/manifests/site_apply.pp.erb", "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp", {nodes: nodes})
64
64
  end
65
65
 
66
66
  # Generate the hiera templates for each step
67
67
  def self.generate_hiera_for_steps(project_root, template_file, filename, options)
68
68
  Bebox::PROVISION_STEPS.each do |step|
69
69
  step_dir = Bebox::Provision.step_name(step)
70
- hiera_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/puppet/#{step}/hiera/data/#{template_file}")
71
- File.open("#{project_root}/puppet/steps/#{step_dir}/hiera/data/#{filename}.yaml", 'w') do |f|
72
- f.write hiera_template.render(nil, options)
73
- end
70
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{step}/hiera/data/#{template_file}", "#{project_root}/puppet/steps/#{step_dir}/hiera/data/#{filename}.yaml", options)
74
71
  end
75
72
  end
76
73
 
@@ -99,10 +96,7 @@ module Bebox
99
96
  puppetfile_content = File.read(profile_puppetfile_path)
100
97
  modules << puppetfile_content.scan(/^\s*(mod\s*.+?)$/).uniq
101
98
  end
102
- puppetfile_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/puppet/#{step}/Puppetfile.erb", :trim => true)
103
- File.open("#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/Puppetfile", 'w') do |f|
104
- f.write puppetfile_template.render(nil, :profile_modules => modules.flatten)
105
- end
99
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{step}/Puppetfile.erb", "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/Puppetfile", {profile_modules: modules.flatten})
106
100
  end
107
101
 
108
102
  # Get the role name associated with a node
@@ -142,13 +136,12 @@ module Bebox
142
136
  # Add a node to site.pp
143
137
  def self.add_node_to_step_manifests(project_root, node)
144
138
  Bebox::PROVISION_STEPS.each do |step|
145
- manifest_node_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/puppet/#{step}/manifests/node.erb", :trim => true)
146
- manifest_node = manifest_node_template.render(nil, :node => node)
139
+ manifest_node = render_erb_template("#{Bebox::FilesHelper::templates_path}/puppet/#{step}/manifests/node.erb", {node: node})
147
140
  Bebox::Provision.remove_node(project_root, node.hostname, step)
148
141
  manifest_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp"
149
142
  content = File.read(manifest_path)
150
143
  content += "\n#{manifest_node}\n"
151
- File.open(manifest_path, 'wb') { |file| file.write(content) }
144
+ write_content_to_file(manifest_path, content)
152
145
  end
153
146
  end
154
147
 
@@ -224,15 +217,7 @@ module Bebox
224
217
  def create_step_checkpoint(started_at)
225
218
  self.node.started_at = started_at
226
219
  self.node.finished_at = DateTime.now.to_s
227
- checkpoint_template = Tilt::ERBTemplate.new("#{Bebox::Provision::templates_path}/node/provisioned_node.yml.erb")
228
- File.open("#{self.project_root}/.checkpoints/environments/#{self.environment}/steps/#{self.step}/#{self.node.hostname}.yml", 'w') do |f|
229
- f.write checkpoint_template.render(nil, :node => self.node)
230
- end
231
- end
232
-
233
- # Get the templates path inside the gem
234
- def self.templates_path
235
- File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
220
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/node/provisioned_node.yml.erb", "#{self.project_root}/.checkpoints/environments/#{self.environment}/steps/#{self.step}/#{self.node.hostname}.yml", {node: self.node})
236
221
  end
237
222
 
238
223
  # Translate step name to directory name
data/lib/bebox/role.rb CHANGED
@@ -1,8 +1,7 @@
1
- require 'tilt'
2
1
 
3
2
  module Bebox
4
3
  class Role
5
-
4
+ include Bebox::FilesHelper
6
5
  attr_accessor :project_root, :name
7
6
 
8
7
  def initialize(name, project_root)
@@ -33,10 +32,7 @@ module Bebox
33
32
 
34
33
  # Generate the manifests init.pp file
35
34
  def generate_manifests_file
36
- manifests_template = Tilt::ERBTemplate.new("#{templates_path}/puppet/roles/manifests/init.pp.erb")
37
- File.open("#{self.path}/manifests/init.pp", 'w') do |f|
38
- f.write manifests_template.render(nil, :role => self)
39
- end
35
+ generate_file_from_template("#{templates_path}/puppet/roles/manifests/init.pp.erb", "#{self.path}/manifests/init.pp", {role: self})
40
36
  end
41
37
 
42
38
  # Path to the templates directory in the gem
@@ -93,11 +89,5 @@ module Bebox
93
89
  role_profiles = Bebox::Role.list_profiles(project_root, role)
94
90
  role_profiles.include?(profile) ? true : false
95
91
  end
96
-
97
- # Check if the role has a valid name
98
- def self.valid_name?(name)
99
- valid_name = (name =~ /\A[a-z][a-z0-9_]*\Z/).nil? ? false : true
100
- valid_name && !Bebox::RESERVED_WORDS.include?(name)
101
- end
102
92
  end
103
93
  end
@@ -0,0 +1,96 @@
1
+
2
+ module Bebox
3
+ module VagrantHelper
4
+
5
+ include Bebox::Logger
6
+ include Bebox::FilesHelper
7
+
8
+ # Return the existence status of vagrant node
9
+ def vagrant_box_exist?(node)
10
+ vagrant_boxes = `cd #{node.project_root} && vagrant box list`
11
+ project_name = Bebox::Project.name_from_file(node.project_root)
12
+ vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(node.project_root)
13
+ (vagrant_boxes =~ /#{project_name}-#{node.hostname}\s+\(#{vagrant_box_provider}/) ? true : false
14
+ end
15
+
16
+ # Return the running status of vagrant node
17
+ def vagrant_box_running?(node)
18
+ status = `cd #{node.project_root} && vagrant status`
19
+ (status =~ /#{node.hostname}\s+running/) ? true : false
20
+ end
21
+
22
+ # Remove the specified boxes from vagrant
23
+ def remove_vagrant_box(node)
24
+ return unless (node.environment == 'vagrant' && node.prepared_nodes_count > 0)
25
+ project_name = Bebox::Project.name_from_file(node.project_root)
26
+ vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(node.project_root)
27
+ `cd #{node.project_root} && vagrant destroy -f #{node.hostname}`
28
+ `cd #{node.project_root} && vagrant box remove #{project_name}-#{node.hostname} --provider #{vagrant_box_provider}`
29
+ end
30
+
31
+ # Backup and add the vagrant hosts to local hosts file
32
+ def configure_local_hosts(project_name, node)
33
+ info "\nPlease provide your local password, if asked, to configure the local hosts file."
34
+ backup_local_hosts(project_name)
35
+ add_to_local_hosts(node)
36
+ end
37
+
38
+ # Backup the local hosts file
39
+ def backup_local_hosts(project_name)
40
+ hosts_backup_file = "#{local_hosts_path}/hosts_before_#{project_name}"
41
+ `sudo cp #{local_hosts_path}/hosts #{hosts_backup_file}` unless File.exist?(hosts_backup_file)
42
+ end
43
+
44
+ # Add the vagrant hosts to the local hosts file
45
+ def add_to_local_hosts(node)
46
+ host_command = `echo '#{node.ip} #{node.hostname} # Added by bebox' >> #{local_hosts_path}/hosts`
47
+ host_command if (file_content_trimmed("#{local_hosts_path}/hosts") =~ /#{node.ip}\s+#{node.hostname}/)
48
+ end
49
+
50
+ # Obtain the local hosts file for the OS
51
+ def local_hosts_path
52
+ RUBY_PLATFORM =~ /darwin/ ? '/private/etc' : '/etc'
53
+ end
54
+
55
+ # Prepare the vagrant nodes
56
+ def prepare_vagrant(node)
57
+ project_name = Bebox::Project.name_from_file(node.project_root)
58
+ vagrant_box_base = Bebox::Project.vagrant_box_base_from_file(node.project_root)
59
+ configure_local_hosts(project_name, node)
60
+ add_vagrant_node(project_name, vagrant_box_base, node)
61
+ end
62
+
63
+ # Add the boxes to vagrant for each node
64
+ def add_vagrant_node(project_name, vagrant_box_base, node)
65
+ already_installed_boxes = installed_vagrant_box_names(node)
66
+ box_name = "#{project_name}-#{node.hostname}"
67
+ info "Adding server to vagrant: #{node.hostname}..."
68
+ `cd #{node.project_root} && vagrant box add #{box_name} #{vagrant_box_base}` unless already_installed_boxes.include? box_name
69
+ end
70
+
71
+ # Up the vagrant boxes in Vagrantfile
72
+ def self.up_vagrant_nodes(project_root)
73
+ `cd #{project_root} && vagrant up --provision`
74
+ end
75
+
76
+ # Halt the vagrant boxes running
77
+ def self.halt_vagrant_nodes(project_root)
78
+ `cd #{project_root} && vagrant halt`
79
+ end
80
+
81
+ # Generate the Vagrantfile
82
+ def self.generate_vagrantfile(nodes)
83
+ project_root = nodes.first.project_root
84
+ network_interface = RUBY_PLATFORM =~ /darwin/ ? 'en0' : 'eth0'
85
+ project_name = Bebox::Project.name_from_file(project_root)
86
+ vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(project_root)
87
+ generate_file_from_template("#{Bebox::FilesHelper::templates_path}/node/Vagrantfile.erb", "#{project_root}/Vagrantfile", {nodes: nodes, project_name: project_name, vagrant_box_provider: vagrant_box_provider, network_interface: network_interface})
88
+ end
89
+
90
+ # return an Array with the names of the currently installed vagrant boxes
91
+ # @returns Array
92
+ def installed_vagrant_box_names(node)
93
+ (`cd #{node.project_root} && vagrant box list`).split("\n").map{|vagrant_box| vagrant_box.split(' ').first}
94
+ end
95
+ end
96
+ end
data/lib/bebox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bebox
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,6 +1,9 @@
1
+
1
2
  module Bebox
2
3
  class EnvironmentWizard
3
4
  include Bebox::Logger
5
+ include Bebox::WizardsHelper
6
+
4
7
  # Create a new environment
5
8
  def create_new_environment(project_root, environment_name)
6
9
  # Check if the environment exist
@@ -16,30 +19,11 @@ module Bebox
16
19
  # Check if the environment exist
17
20
  return error("The '#{environment_name}' environment do not exist!.") unless Bebox::Environment.environment_exists?(project_root, environment_name)
18
21
  # Confirm deletion
19
- return warn('No changes were made.') unless confirm_environment_deletion?
22
+ return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the environment?')
20
23
  # Environment deletion
21
24
  environment = Bebox::Environment.new(environment_name, project_root)
22
25
  environment.remove
23
26
  ok 'Environment removed!.'
24
27
  end
25
-
26
- # Ask for confirmation of environment deletion
27
- def confirm_environment_deletion?
28
- quest 'Are you sure that you want to delete the environment?'
29
- response = ask(highline_quest('(y/n)')) do |q|
30
- q.default = "n"
31
- end
32
- return response == 'y' ? true : false
33
- end
34
-
35
- # Asks to choose an existing environment
36
- def choose_environment(environments)
37
- choose do |menu|
38
- menu.header = title('Choose an existing environment:')
39
- environments.each do |box|
40
- menu.choice(box.split('/').last)
41
- end
42
- end
43
- end
44
28
  end
45
29
  end
@@ -1,6 +1,10 @@
1
+
1
2
  module Bebox
2
3
  class NodeWizard
3
4
  include Bebox::Logger
5
+ include Bebox::WizardsHelper
6
+ include Bebox::VagrantHelper
7
+
4
8
  # Create a new node
5
9
  def create_new_node(project_root, environment)
6
10
  # Ask the hostname for node
@@ -18,12 +22,12 @@ module Bebox
18
22
  # Ask for a node to remove
19
23
  nodes = Bebox::Node.list(project_root, environment, 'nodes')
20
24
  if nodes.count > 0
21
- hostname = choose_node(nodes, 'Choose the node to remove:')
25
+ hostname = choose_option(nodes, 'Choose the node to remove:')
22
26
  else
23
27
  return error "There are no nodes in the '#{environment}' environment to remove. No changes were made."
24
28
  end
25
29
  # Ask for deletion confirmation
26
- return warn('No changes were made.') unless confirm_node_deletion?
30
+ return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the node?')
27
31
  # Node deletion
28
32
  node = Bebox::Node.new(environment, project_root, hostname, nil)
29
33
  node.remove
@@ -34,9 +38,8 @@ module Bebox
34
38
  def set_role(project_root, environment)
35
39
  roles = Bebox::Role.list(project_root)
36
40
  nodes = Bebox::Node.list(project_root, environment, 'nodes')
37
- node = choose_node(nodes, 'Choose an existing node:')
38
- require 'bebox/wizards/role_wizard'
39
- role = Bebox::RoleWizard.new.choose_role(roles, 'Choose an existing role:')
41
+ node = choose_option(nodes, 'Choose an existing node:')
42
+ role = choose_option(roles, 'Choose an existing role:')
40
43
  Bebox::Provision.associate_node_role(project_root, environment, node, role)
41
44
  ok 'Role associated to node!.'
42
45
  end
@@ -54,9 +57,9 @@ module Bebox
54
57
  Bebox::Node.regenerate_deploy_file(project_root, environment, nodes_to_prepare)
55
58
  # If environment is 'vagrant' Prepare and Up the machines
56
59
  if environment == 'vagrant'
57
- Bebox::Node.generate_vagrantfile(project_root, nodes_to_prepare)
58
- nodes_to_prepare.each{|node| node.prepare_vagrant}
59
- Bebox::Node.up_vagrant_nodes(project_root)
60
+ Bebox::VagrantHelper.generate_vagrantfile(nodes_to_prepare)
61
+ nodes_to_prepare.each{|node| prepare_vagrant(node)}
62
+ Bebox::VagrantHelper.up_vagrant_nodes(project_root)
60
63
  end
61
64
  # For all the environments do the preparation
62
65
  nodes_to_prepare.each do |node|
@@ -75,7 +78,9 @@ module Bebox
75
78
  prepared_nodes = Bebox::Node.list(project_root, environment, 'prepared_nodes')
76
79
  nodes.each do |node|
77
80
  if prepared_nodes.include?(node.hostname)
78
- nodes_to_prepare << node if confirm_node_preparation?(node)
81
+ checkpoint_status = "(start: #{node.checkpoint_parameter_from_file('prepared_nodes', 'started_at')} - end: #{node.checkpoint_parameter_from_file('prepared_nodes', 'finished_at')})"
82
+ message = "The node '#{node.hostname}' was already prepared #{checkpoint_status}.\nDo you want to re-prepare it?"
83
+ nodes_to_prepare << node if confirm_action?(message)
79
84
  else
80
85
  nodes_to_prepare << node
81
86
  end
@@ -88,35 +93,6 @@ module Bebox
88
93
  File.exists?("#{project_root}/.checkpoints/environments/#{environment}/nodes/#{node_name}.yml")
89
94
  end
90
95
 
91
- # Ask for confirmation of node preparation
92
- def confirm_node_preparation?(node)
93
- checkpoint_status = "(start: #{node.checkpoint_parameter_from_file('prepared_nodes', 'started_at')} - end: #{node.checkpoint_parameter_from_file('prepared_nodes', 'finished_at')})"
94
- quest "The node '#{node.hostname}' was already prepared #{checkpoint_status}.\nDo you want to re-prepare it?"
95
- response = ask(highline_quest('(y/n)')) do |q|
96
- q.default = "n"
97
- end
98
- return response == 'y' ? true : false
99
- end
100
-
101
- # Ask for confirmation of node deletion
102
- def confirm_node_deletion?
103
- quest 'Are you sure that you want to delete the node?'
104
- response = ask(highline_quest('(y/n)')) do |q|
105
- q.default = "n"
106
- end
107
- return response == 'y' ? true : false
108
- end
109
-
110
- # Asks to choose an existing node
111
- def choose_node(nodes, question)
112
- choose do |menu|
113
- menu.header = title(question)
114
- nodes.each do |box|
115
- menu.choice(box.split('/').last)
116
- end
117
- end
118
- end
119
-
120
96
  # Keep asking for a hostname that not exist
121
97
  def ask_not_existing_hostname(project_root, environment)
122
98
  hostname = ask_hostname(project_root, environment)
@@ -129,20 +105,14 @@ module Bebox
129
105
  end
130
106
  end
131
107
 
132
- # Ask for the hostname until is valid
108
+ # Ask for the hostname
133
109
  def ask_hostname(project_root, environment)
134
- ask(highline_quest('Write the hostname for the node:')) do |q|
135
- q.validate = /\.(.*)/
136
- q.responses[:not_valid] = highline_warn('Enter valid hostname. Ex. host.server1.com')
137
- end
110
+ write_input('Write the hostname for the node:', nil, /\.(.*)/, 'Enter valid hostname. Ex. host.server1.com')
138
111
  end
139
112
 
140
113
  # Ask for the ip until is valid
141
114
  def ask_ip(environment)
142
- ip = ask(highline_quest('Write the IP address for the node:')) do |q|
143
- q.validate = /\.(.*)/
144
- q.responses[:not_valid] = highline_warn('Enter a valid IP address. Ex. 192.168.0.50')
145
- end
115
+ ip = write_input('Write the IP address for the node:', nil, /\.(.*)/, 'Enter a valid IP address. Ex. 192.168.0.50')
146
116
  # If the environment is not vagrant don't check ip free
147
117
  return ip if environment != 'vagrant'
148
118
  # Check if the ip address is free
@@ -1,8 +1,9 @@
1
- require 'bebox/profile'
2
1
 
3
2
  module Bebox
4
3
  class ProfileWizard
5
4
  include Bebox::Logger
5
+ include Bebox::WizardsHelper
6
+
6
7
  # Create a new profile
7
8
  def create_new_profile(project_root, profile_name, profile_base_path)
8
9
  # Check if the profile name is valid
@@ -12,10 +13,10 @@ module Bebox
12
13
  \n* Underscores
13
14
  \n* Must begin with an Lowercase letter
14
15
  \n* Can not be any of: #{Bebox::RESERVED_WORDS.join(', ')}
15
- \n\nNo changes were made." unless Bebox::Profile.valid_name?(profile_name)
16
- # Clean the profile_path to make it a valid path
17
- profile_base_path = Bebox::Profile.cleanpath(profile_base_path)
16
+ \n\nNo changes were made." unless valid_puppet_class_name?(profile_name)
18
17
  unless profile_base_path.empty?
18
+ # Clean the profile_path to make it a valid path
19
+ profile_base_path = Bebox::Profile.cleanpath(profile_base_path)
19
20
  # Check if the path name is valid
20
21
  return error "Each part of the path can only contain:\n
21
22
  \n* Lowercase letters
@@ -26,7 +27,7 @@ module Bebox
26
27
  \n\nNo changes were made." unless Bebox::Profile.valid_pathname?(profile_base_path)
27
28
  end
28
29
  # Check if the profile exist
29
- profile_path = profile_complete_path(profile_base_path, profile_name)
30
+ profile_path = profile_base_path.empty? ? profile_name : profile_complete_path(profile_base_path, profile_name)
30
31
  return error("The profile '#{profile_path}' already exist. No changes were made.") if profile_exists?(project_root, profile_path)
31
32
  # Profile creation
32
33
  profile = Bebox::Profile.new(profile_name, project_root, profile_base_path)
@@ -40,12 +41,12 @@ module Bebox
40
41
  profiles = Bebox::Profile.list(project_root)
41
42
  # Get a profile if exist
42
43
  if profiles.count > 0
43
- profile = choose_profile(profiles, 'Choose the profile to remove:')
44
+ profile = choose_option(profiles, 'Choose the profile to remove:')
44
45
  else
45
46
  return error "There are no profiles to remove. No changes were made."
46
47
  end
47
48
  # Ask for deletion confirmation
48
- return warn('No changes were made.') unless confirm_profile_deletion?
49
+ return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the profile?')
49
50
  # Profile deletion
50
51
  profile_name = profile.split('/').last
51
52
  profile_base_path = profile.split('/')[0...-1].join('/')
@@ -68,24 +69,5 @@ module Bebox
68
69
  def profile_exists?(project_root, profile_path)
69
70
  Dir.exists?( File.join("#{project_root}/puppet/profiles", "#{profile_path}") )
70
71
  end
71
-
72
- # Ask for confirmation of profile deletion
73
- def confirm_profile_deletion?
74
- quest 'Are you sure that you want to delete the profile?'
75
- response = ask(highline_quest('(y/n)')) do |q|
76
- q.default = "n"
77
- end
78
- return response == 'y' ? true : false
79
- end
80
-
81
- # Asks to choose a profile
82
- def choose_profile(profiles, question)
83
- choose do |menu|
84
- menu.header = title(question)
85
- profiles.each do |box|
86
- menu.choice(box)
87
- end
88
- end
89
- end
90
72
  end
91
73
  end