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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -8
- data/README.md +33 -30
- data/bebox.gemspec +1 -2
- data/bin/bebox +1 -2
- data/lib/bebox/cli.rb +0 -5
- data/lib/bebox/commands/commands_helper.rb +3 -1
- data/lib/bebox/commands/environment_commands.rb +26 -29
- data/lib/bebox/commands/general_commands.rb +0 -1
- data/lib/bebox/commands/node_commands.rb +44 -48
- data/lib/bebox/commands/prepare_commands.rb +25 -32
- data/lib/bebox/commands/profile_commands.rb +56 -0
- data/lib/bebox/commands/project_commands.rb +23 -29
- data/lib/bebox/commands/provision_commands.rb +18 -120
- data/lib/bebox/commands/role_commands.rb +83 -0
- data/lib/bebox/environment.rb +4 -10
- data/lib/bebox/files_helper.rb +37 -0
- data/lib/bebox/logger.rb +0 -1
- data/lib/bebox/node.rb +9 -122
- data/lib/bebox/profile.rb +5 -16
- data/lib/bebox/project.rb +14 -38
- data/lib/bebox/provision.rb +21 -36
- data/lib/bebox/role.rb +2 -12
- data/lib/bebox/vagrant_helper.rb +96 -0
- data/lib/bebox/version.rb +1 -1
- data/lib/bebox/wizards/environment_wizard.rb +4 -20
- data/lib/bebox/wizards/node_wizard.rb +17 -47
- data/lib/bebox/wizards/profile_wizard.rb +8 -26
- data/lib/bebox/wizards/project_wizard.rb +42 -72
- data/lib/bebox/wizards/provision_wizard.rb +35 -51
- data/lib/bebox/wizards/role_wizard.rb +9 -29
- data/lib/bebox/wizards/wizards_helper.rb +41 -0
- data/lib/bebox.rb +30 -2
- data/lib/templates/project/config/deploy/steps/step-0.erb +13 -0
- data/lib/templates/project/config/deploy/steps/step-1.erb +0 -0
- data/lib/templates/project/config/deploy/steps/step-2.erb +0 -0
- data/lib/templates/project/config/deploy/steps/step-3.erb +0 -0
- data/lib/templates/project/config/deploy.erb +3 -0
- data/spec/fixtures/config/deploy/steps/step-0.test +13 -0
- data/spec/fixtures/config/deploy/steps/step-1.test +0 -0
- data/spec/fixtures/config/deploy/steps/step-2.test +0 -0
- data/spec/fixtures/config/deploy/steps/step-3.test +0 -0
- data/spec/fixtures/config/deploy.test +3 -0
- data/spec/ordered_phases_spec.rb +6 -4
- data/spec/pre_prepare_spec.rb +8 -6
- data/spec/profile_spec.rb +9 -5
- data/spec/project_spec.rb +9 -2
- data/spec/puppet_spec_helper.rb +1 -1
- data/spec/role_spec.rb +9 -5
- data/spec/spec_helper.rb +5 -0
- metadata +17 -212
- data/lib/templates/puppet/step-0/modules/rbenv/AUTHORS +0 -11
- data/lib/templates/puppet/step-0/modules/rbenv/CHANGELOG.md +0 -70
- data/lib/templates/puppet/step-0/modules/rbenv/Gemfile +0 -8
- data/lib/templates/puppet/step-0/modules/rbenv/Gemfile.lock +0 -28
- data/lib/templates/puppet/step-0/modules/rbenv/Modulefile +0 -7
- data/lib/templates/puppet/step-0/modules/rbenv/README.md +0 -173
- data/lib/templates/puppet/step-0/modules/rbenv/Rakefile +0 -22
- data/lib/templates/puppet/step-0/modules/rbenv/TODO +0 -10
- data/lib/templates/puppet/step-0/modules/rbenv/bin/autospec +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/facter +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/filebucket +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/hiera +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/htmldiff +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/ldiff +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/pi +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-lint +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-module +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetca +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetd +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetdoc +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetmasterd +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetqd +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetrun +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/rake +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/ralsh +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec-puppet-init +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/provider/rbenvgem/default.rb +0 -50
- data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/type/rbenvgem.rb +0 -62
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/bundle.pp +0 -36
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/client.pp +0 -48
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/compile.pp +0 -102
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/definition.pp +0 -31
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/centos.pp +0 -25
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/suse.pp +0 -28
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/ubuntu.pp +0 -17
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies.pp +0 -8
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/gem.pp +0 -29
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/install.pp +0 -55
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rbenvvars.pp +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rubybuild.pp +0 -16
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin.pp +0 -40
- data/lib/templates/puppet/step-0/modules/rbenv/metadata.json +0 -109
- data/lib/templates/puppet/step-0/modules/rbenv/templates/Gemfile.erb +0 -5
- data/lib/templates/puppet/step-0/modules/rbenv/templates/dot.rbenvrc.erb +0 -8
- data/lib/templates/puppet/step-0/modules/stdlib/CHANGELOG.md +0 -418
- data/lib/templates/puppet/step-0/modules/stdlib/CONTRIBUTING.md +0 -65
- data/lib/templates/puppet/step-0/modules/stdlib/Gemfile +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/Gemfile.lock +0 -166
- data/lib/templates/puppet/step-0/modules/stdlib/LICENSE +0 -19
- data/lib/templates/puppet/step-0/modules/stdlib/Modulefile +0 -11
- data/lib/templates/puppet/step-0/modules/stdlib/README.markdown +0 -1304
- data/lib/templates/puppet/step-0/modules/stdlib/README_DEVELOPER.markdown +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/README_SPECS.markdown +0 -7
- data/lib/templates/puppet/step-0/modules/stdlib/RELEASE_PROCESS.markdown +0 -24
- data/lib/templates/puppet/step-0/modules/stdlib/Rakefile +0 -18
- data/lib/templates/puppet/step-0/modules/stdlib/checksums.json +0 -349
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/facter_dot_d.rb +0 -202
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/pe_version.rb +0 -53
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/puppet_vardir.rb +0 -26
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/root_home.rb +0 -32
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/util/puppet_settings.rb +0 -21
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/abs.rb +0 -36
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/any2array.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/base64.rb +0 -37
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +0 -49
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +0 -34
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chomp.rb +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chop.rb +0 -37
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/concat.rb +0 -41
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/count.rb +0 -22
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb +0 -44
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete.rb +0 -46
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +0 -49
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb +0 -34
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_values.rb +0 -26
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/difference.rb +0 -36
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/dirname.rb +0 -15
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/downcase.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/empty.rb +0 -28
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +0 -45
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/flatten.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/floor.rb +0 -25
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +0 -46
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +0 -17
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getparam.rb +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getvar.rb +0 -26
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/grep.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +0 -52
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +0 -25
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +0 -25
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_key.rb +0 -28
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/hash.rb +0 -41
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/intersection.rb +0 -34
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_array.rb +0 -22
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_bool.rb +0 -22
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +0 -50
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_float.rb +0 -30
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb +0 -26
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +0 -22
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +0 -45
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +0 -32
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +0 -27
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +0 -75
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_string.rb +0 -26
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join.rb +0 -41
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +0 -47
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/keys.rb +0 -26
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +0 -20
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/max.rb +0 -21
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/member.rb +0 -44
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/merge.rb +0 -34
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/min.rb +0 -21
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +0 -43
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +0 -24
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +0 -24
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick.rb +0 -29
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick_default.rb +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/prefix.rb +0 -45
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/range.rb +0 -88
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reject.rb +0 -31
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reverse.rb +0 -28
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +0 -32
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +0 -46
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/size.rb +0 -48
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/sort.rb +0 -27
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +0 -36
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +0 -46
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +0 -32
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strftime.rb +0 -107
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strip.rb +0 -39
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/suffix.rb +0 -45
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +0 -39
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/time.rb +0 -49
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +0 -28
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/type.rb +0 -50
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/union.rb +0 -34
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/unique.rb +0 -51
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/upcase.rb +0 -41
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +0 -35
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +0 -56
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +0 -81
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +0 -34
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb +0 -48
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb +0 -48
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb +0 -49
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +0 -40
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +0 -71
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +0 -33
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values.rb +0 -39
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values_at.rb +0 -98
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/zip.rb +0 -65
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +0 -83
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/anchor.rb +0 -46
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/file_line.rb +0 -79
- data/lib/templates/puppet/step-0/modules/stdlib/manifests/init.pp +0 -20
- data/lib/templates/puppet/step-0/modules/stdlib/manifests/stages.pp +0 -43
- data/lib/templates/puppet/step-0/modules/stdlib/metadata.json +0 -111
- data/lib/templates/puppet/step-0/modules/sudo/.fixtures.yml +0 -5
- data/lib/templates/puppet/step-0/modules/sudo/.gemfile +0 -14
- data/lib/templates/puppet/step-0/modules/sudo/.gemfile.lock +0 -43
- data/lib/templates/puppet/step-0/modules/sudo/.travis.yml +0 -34
- data/lib/templates/puppet/step-0/modules/sudo/LICENSE +0 -13
- data/lib/templates/puppet/step-0/modules/sudo/Modulefile +0 -9
- data/lib/templates/puppet/step-0/modules/sudo/README.md +0 -171
- data/lib/templates/puppet/step-0/modules/sudo/Rakefile +0 -1
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.aix +0 -90
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.archlinux +0 -90
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.deb +0 -90
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.freebsd +0 -98
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.omnios +0 -90
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel5 +0 -97
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel6 +0 -115
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.solaris +0 -90
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.suse +0 -81
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.ubuntu +0 -30
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.wheezy +0 -17
- data/lib/templates/puppet/step-0/modules/sudo/lib/augeas/lenses/fixedsudoers.aug +0 -520
- data/lib/templates/puppet/step-0/modules/sudo/manifests/allow.pp +0 -76
- data/lib/templates/puppet/step-0/modules/sudo/manifests/conf.pp +0 -105
- data/lib/templates/puppet/step-0/modules/sudo/manifests/configs.pp +0 -24
- data/lib/templates/puppet/step-0/modules/sudo/manifests/init.pp +0 -151
- data/lib/templates/puppet/step-0/modules/sudo/manifests/package/aix.pp +0 -46
- data/lib/templates/puppet/step-0/modules/sudo/manifests/package/solaris.pp +0 -60
- data/lib/templates/puppet/step-0/modules/sudo/manifests/package.pp +0 -61
- data/lib/templates/puppet/step-0/modules/sudo/manifests/params.pp +0 -127
- data/lib/templates/puppet/step-0/modules/sudo/metadata.json +0 -59
- data/lib/templates/puppet/step-0/modules/sudo/templates/users_groups.erb +0 -9
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'bebox/profile'
|
|
2
1
|
|
|
3
2
|
module Bebox
|
|
4
3
|
module ProvisionCommands
|
|
@@ -8,6 +7,12 @@ module Bebox
|
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def load_commands
|
|
10
|
+
load_provision_commands
|
|
11
|
+
self.extend Bebox::RoleCommands
|
|
12
|
+
self.extend Bebox::ProfileCommands
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def load_provision_commands
|
|
11
16
|
desc 'Apply the Puppet step for the nodes in a environment. (step-0: Fundamental, step-1: User layer, step-2: Service layer, step-3: Security layer)'
|
|
12
17
|
arg_name "[step]"
|
|
13
18
|
command :apply do |apply_command|
|
|
@@ -16,130 +21,23 @@ module Bebox
|
|
|
16
21
|
apply_command.action do |global_options,options,args|
|
|
17
22
|
environment = get_environment(options)
|
|
18
23
|
title "Environment: #{environment}"
|
|
19
|
-
|
|
20
|
-
if options[:all]
|
|
21
|
-
title "Provisioning all steps..."
|
|
22
|
-
Bebox::PROVISION_STEPS.each do |step|
|
|
23
|
-
title "Provisioning #{step}:"
|
|
24
|
-
Bebox::ProvisionWizard.new.apply_step(project_root, environment, step)
|
|
25
|
-
end
|
|
26
|
-
else
|
|
27
|
-
step = args.first
|
|
28
|
-
help_now!(error('You did not specify an step')) if args.count == 0
|
|
29
|
-
help_now!(error('You did not specify a valid step')) unless valid_step?(step)
|
|
30
|
-
# Apply the step for the environment
|
|
31
|
-
title "Provisioning #{step}:"
|
|
32
|
-
Bebox::ProvisionWizard.new.apply_step(project_root, environment, step)
|
|
33
|
-
end
|
|
24
|
+
options[:all] ? apply_all(environment) : apply(environment, args)
|
|
34
25
|
end
|
|
35
26
|
end
|
|
27
|
+
end
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
profile_command.desc 'list the profiles in the project'
|
|
42
|
-
profile_command.command :list do |profile_list_command|
|
|
43
|
-
profile_list_command.action do |global_options,options,args|
|
|
44
|
-
require 'bebox/wizards/profile_wizard'
|
|
45
|
-
profiles = Bebox::ProfileWizard.new.list_profiles(project_root)
|
|
46
|
-
title 'Current profiles:'
|
|
47
|
-
profiles.map{|profile| msg(profile)}
|
|
48
|
-
warn('There are not profiles yet. You can create a new one with: \'bebox profile new\' command.') if profiles.empty?
|
|
49
|
-
linebreak
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
# Profile new command
|
|
53
|
-
profile_command.desc 'add a profile to the project'
|
|
54
|
-
profile_command.arg_name "[name]"
|
|
55
|
-
profile_command.command :new do |profile_new_command|
|
|
56
|
-
profile_new_command.flag :p, :arg_name => 'path', :desc => 'A relative path of the category folders tree to store the profile. Ex. basic/security/iptables'
|
|
57
|
-
profile_new_command.action do |global_options,options,args|
|
|
58
|
-
path = options[:p] || ''
|
|
59
|
-
help_now!(error('You did not supply a name')) if args.count == 0
|
|
60
|
-
require 'bebox/wizards/profile_wizard'
|
|
61
|
-
Bebox::ProfileWizard.new.create_new_profile(project_root, args.first, path)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
# Profile remove command
|
|
65
|
-
profile_command.desc "remove a profile from the project"
|
|
66
|
-
profile_command.command :remove do |profile_remove_command|
|
|
67
|
-
profile_remove_command.action do |global_options,options,args|
|
|
68
|
-
require 'bebox/wizards/profile_wizard'
|
|
69
|
-
Bebox::ProfileWizard.new.remove_profile(project_root)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
29
|
+
def apply_all(environment)
|
|
30
|
+
title "Provisioning all steps..."
|
|
31
|
+
Bebox::PROVISION_STEPS.each do |step|
|
|
32
|
+
Bebox::ProvisionWizard.new.apply_step(project_root, environment, step)
|
|
72
33
|
end
|
|
34
|
+
end
|
|
73
35
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
role_command.command :list do |role_list_command|
|
|
80
|
-
role_list_command.action do |global_options,options,args|
|
|
81
|
-
roles = Bebox::Role.list(project_root)
|
|
82
|
-
title 'Current roles:'
|
|
83
|
-
roles.map{|role| msg(role)}
|
|
84
|
-
warn('There are not roles yet. You can create a new one with: \'bebox role new\' command.') if roles.empty?
|
|
85
|
-
linebreak
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
# Role new command
|
|
89
|
-
role_command.desc 'add a role to the project'
|
|
90
|
-
role_command.arg_name "[name]"
|
|
91
|
-
role_command.command :new do |role_new_command|
|
|
92
|
-
role_new_command.action do |global_options,options,args|
|
|
93
|
-
help_now!(error('You did not supply a name')) if args.count == 0
|
|
94
|
-
require 'bebox/wizards/role_wizard'
|
|
95
|
-
Bebox::RoleWizard.new.create_new_role(project_root, args.first)
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
# Role remove command
|
|
99
|
-
role_command.desc "remove a role from the project"
|
|
100
|
-
role_command.command :remove do |role_remove_command|
|
|
101
|
-
role_remove_command.action do |global_options,options,args|
|
|
102
|
-
require 'bebox/wizards/role_wizard'
|
|
103
|
-
Bebox::RoleWizard.new.remove_role(project_root)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# These commands are available if there are at least one role and one profile
|
|
108
|
-
if Bebox::Role.roles_count(project_root) > 0 && Bebox::Profile.profiles_count(project_root) > 0
|
|
109
|
-
# Role list profiles command
|
|
110
|
-
role_command.desc 'list the profiles in a role'
|
|
111
|
-
role_command.arg_name "[role_name]"
|
|
112
|
-
role_command.command :list_profiles do |list_profiles_command|
|
|
113
|
-
list_profiles_command.action do |global_options,options,args|
|
|
114
|
-
help_now!(error('You did not supply a role name.')) if args.count == 0
|
|
115
|
-
role = args.first
|
|
116
|
-
require 'bebox/wizards/role_wizard'
|
|
117
|
-
exit_now!(error("The '#{role}' role does not exist.")) unless Bebox::RoleWizard.new.role_exists?(project_root, role)
|
|
118
|
-
profiles = Bebox::Role.list_profiles(project_root, role)
|
|
119
|
-
title "Current profiles in '#{role}' role:"
|
|
120
|
-
profiles.map{|profile| msg(profile)}
|
|
121
|
-
warn("There are not profiles in role '#{role}'. You can add a new one with: 'bebox role add_profile' command.") if profiles.empty?
|
|
122
|
-
linebreak
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
# Role add profile command
|
|
126
|
-
role_command.desc 'add a profile to a role'
|
|
127
|
-
role_command.command :add_profile do |add_profile_command|
|
|
128
|
-
add_profile_command.action do |global_options,options,args|
|
|
129
|
-
require 'bebox/wizards/role_wizard'
|
|
130
|
-
Bebox::RoleWizard.new.add_profile(project_root)
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
# Role remove profile command
|
|
134
|
-
role_command.desc "remove a profile from a role"
|
|
135
|
-
role_command.command :remove_profile do |remove_profile_command|
|
|
136
|
-
remove_profile_command.action do |global_options,options,args|
|
|
137
|
-
require 'bebox/wizards/role_wizard'
|
|
138
|
-
Bebox::RoleWizard.new.remove_profile(project_root)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
36
|
+
def apply(environment, args)
|
|
37
|
+
step = args.first
|
|
38
|
+
help_now!(error('You did not specify an step')) if args.count == 0
|
|
39
|
+
help_now!(error('You did not specify a valid step')) unless valid_step?(step)
|
|
40
|
+
Bebox::ProvisionWizard.new.apply_step(project_root, environment, step)
|
|
143
41
|
end
|
|
144
42
|
end
|
|
145
43
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
|
|
2
|
+
module Bebox
|
|
3
|
+
module RoleCommands
|
|
4
|
+
|
|
5
|
+
def self.extended(base)
|
|
6
|
+
base.load_commands
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def load_commands
|
|
10
|
+
desc 'Manage roles for the node provisioning phase.'
|
|
11
|
+
command :role do |role_command|
|
|
12
|
+
role_new_command(role_command)
|
|
13
|
+
generate_role_command(role_command, :remove, :remove_role, 'Remove a role from the project')
|
|
14
|
+
role_list_command(role_command)
|
|
15
|
+
# These commands are available if there are at least one role and one profile
|
|
16
|
+
(Bebox::Role.roles_count(project_root) > 0 && Bebox::Profile.profiles_count(project_root) > 0) ? load_role_profile_commands(role_command) : return
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Role list command
|
|
21
|
+
def role_list_command(role_command)
|
|
22
|
+
role_command.desc 'List the roles in the project'
|
|
23
|
+
role_command.command :list do |role_list_command|
|
|
24
|
+
role_list_command.action do |global_options,options,args|
|
|
25
|
+
roles = Bebox::Role.list(project_root)
|
|
26
|
+
title 'Current roles:'
|
|
27
|
+
roles.map{|role| msg(role)}
|
|
28
|
+
warn('There are not roles yet. You can create a new one with: \'bebox role new\' command.') if roles.empty?
|
|
29
|
+
linebreak
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Role new command
|
|
35
|
+
def role_new_command(role_command)
|
|
36
|
+
role_command.desc 'Add a role to the project'
|
|
37
|
+
role_command.arg_name "[name]"
|
|
38
|
+
role_command.command :new do |role_new_command|
|
|
39
|
+
role_new_command.action do |global_options,options,args|
|
|
40
|
+
help_now!(error('You did not supply a name')) if args.count == 0
|
|
41
|
+
Bebox::RoleWizard.new.create_new_role(project_root, args.first)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def load_role_profile_commands(role_command)
|
|
47
|
+
generate_role_command(role_command, :add_profile, :add_profile, 'Add a profile to a role')
|
|
48
|
+
generate_role_command(role_command, :remove_profile, :remove_profile, 'Remove a profile from a role')
|
|
49
|
+
role_list_profiles_command(role_command)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# For add_profile remove_profile and remove_role commands
|
|
53
|
+
def generate_role_command(role_command, command, send_command, description)
|
|
54
|
+
role_command.desc description
|
|
55
|
+
role_command.command command do |generated_command|
|
|
56
|
+
generated_command.action do |global_options,options,args|
|
|
57
|
+
Bebox::RoleWizard.new.send(send_command, project_root)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Role list profiles command
|
|
63
|
+
def role_list_profiles_command(role_command)
|
|
64
|
+
role_command.desc 'List the profiles in a role'
|
|
65
|
+
role_command.arg_name "[role_name]"
|
|
66
|
+
role_command.command :list_profiles do |list_profiles_command|
|
|
67
|
+
list_profiles_command.action do |global_options,options,args|
|
|
68
|
+
help_now!(error('You did not supply a role name.')) if args.count == 0
|
|
69
|
+
role = args.first
|
|
70
|
+
exit_now!(error("The '#{role}' role does not exist.")) unless Bebox::RoleWizard.new.role_exists?(project_root, role)
|
|
71
|
+
print_profiles(role, Bebox::Role.list_profiles(project_root, role))
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def print_profiles(role, profiles)
|
|
77
|
+
title "Current profiles in '#{role}' role:"
|
|
78
|
+
profiles.map{|profile| msg(profile)}
|
|
79
|
+
warn("There are not profiles in role '#{role}'. You can add a new one with: 'bebox role add_profile' command.") if profiles.empty?
|
|
80
|
+
linebreak
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
data/lib/bebox/environment.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require 'tilt'
|
|
2
|
-
require 'bebox/project'
|
|
3
1
|
|
|
4
2
|
module Bebox
|
|
5
3
|
class Environment
|
|
6
4
|
|
|
5
|
+
include Bebox::FilesHelper
|
|
6
|
+
|
|
7
7
|
attr_accessor :name, :project_root
|
|
8
8
|
|
|
9
9
|
def initialize(name, project_root)
|
|
@@ -59,10 +59,7 @@ module Bebox
|
|
|
59
59
|
# Generate the deploy file for the environment
|
|
60
60
|
def generate_deploy_file
|
|
61
61
|
template_name = (self.name == 'vagrant') ? 'vagrant' : "environment"
|
|
62
|
-
|
|
63
|
-
File.open("#{self.project_root}/config/deploy/#{self.name}.rb", 'w') do |f|
|
|
64
|
-
f.write config_deploy_template.render(nil, :nodes => nil, :environment => self.name)
|
|
65
|
-
end
|
|
62
|
+
generate_file_from_template("#{templates_path}/project/config/deploy/#{template_name}.erb", "#{self.project_root}/config/deploy/#{self.name}.rb", {nodes: nil, environment: self.name})
|
|
66
63
|
end
|
|
67
64
|
|
|
68
65
|
# Generate the hiera data template for the environment
|
|
@@ -71,10 +68,7 @@ module Bebox
|
|
|
71
68
|
project_name = Bebox::Project.shortname_from_file(self.project_root)
|
|
72
69
|
Bebox::PROVISION_STEPS.each do |step|
|
|
73
70
|
step_dir = Bebox::Provision.step_name(step)
|
|
74
|
-
|
|
75
|
-
File.open("#{self.project_root}/puppet/steps/#{step_dir}/hiera/data/#{self.name}.yaml", 'w') do |f|
|
|
76
|
-
f.write hiera_template.render(nil, :step_dir => step_dir, :ssh_key => ssh_key, :project_name => project_name)
|
|
77
|
-
end
|
|
71
|
+
generate_file_from_template("#{templates_path}/puppet/#{step}/hiera/data/environment.yaml.erb", "#{self.project_root}/puppet/steps/#{step_dir}/hiera/data/#{self.name}.yaml", {step_dir: step_dir, ssh_key: ssh_key, project_name: project_name})
|
|
78
72
|
end
|
|
79
73
|
end
|
|
80
74
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
module Bebox
|
|
3
|
+
module FilesHelper
|
|
4
|
+
|
|
5
|
+
def self.included(base)
|
|
6
|
+
base.extend(self)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Generate a file from a template
|
|
10
|
+
def generate_file_from_template(template_path, file_path, options)
|
|
11
|
+
write_content_to_file(file_path, render_erb_template(template_path, options))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Render a template for file content
|
|
15
|
+
def render_erb_template(template_path, options)
|
|
16
|
+
require 'tilt'
|
|
17
|
+
Tilt::ERBTemplate.new(template_path).render(nil, options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Write content to a file
|
|
21
|
+
def write_content_to_file(file_path, content)
|
|
22
|
+
File.open(file_path, 'w') do |f|
|
|
23
|
+
f.write content
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Get the content of a file with trimmed spaces
|
|
28
|
+
def file_content_trimmed(path)
|
|
29
|
+
File.read(path).gsub(/\s+/, ' ').strip
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Get the templates path inside the gem
|
|
33
|
+
def self.templates_path
|
|
34
|
+
File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/bebox/logger.rb
CHANGED
data/lib/bebox/node.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require 'tilt'
|
|
2
|
-
require 'bebox/logger'
|
|
3
1
|
|
|
4
2
|
module Bebox
|
|
5
3
|
class Node
|
|
6
4
|
|
|
7
5
|
include Bebox::Logger
|
|
6
|
+
include Bebox::FilesHelper
|
|
7
|
+
include Bebox::VagrantHelper
|
|
8
8
|
|
|
9
9
|
attr_accessor :environment, :project_root, :hostname, :ip, :created_at, :started_at, :finished_at
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ module Bebox
|
|
|
24
24
|
|
|
25
25
|
# Delete all files and directories related to an node
|
|
26
26
|
def remove
|
|
27
|
-
remove_vagrant_box
|
|
27
|
+
remove_vagrant_box(self)
|
|
28
28
|
remove_checkpoints
|
|
29
29
|
remove_hiera_template
|
|
30
30
|
remove_manifests_node
|
|
@@ -75,17 +75,12 @@ module Bebox
|
|
|
75
75
|
def create_prepare_checkpoint(started_at)
|
|
76
76
|
self.started_at = started_at
|
|
77
77
|
self.finished_at = DateTime.now.to_s
|
|
78
|
-
|
|
79
|
-
File.open("#{self.project_root}/.checkpoints/environments/#{self.environment}/prepared_nodes/#{self.hostname}.yml", 'w') do |f|
|
|
80
|
-
f.write node_template.render(nil, :node => self)
|
|
81
|
-
end
|
|
78
|
+
generate_file_from_template("#{Bebox::FilesHelper::templates_path}/node/prepared_node.yml.erb", "#{self.project_root}/.checkpoints/environments/#{self.environment}/prepared_nodes/#{self.hostname}.yml", {node: self})
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
# Create the puppet hiera template file
|
|
85
82
|
def create_hiera_template
|
|
86
|
-
options = {}
|
|
87
|
-
options[:ssh_key] = Bebox::Project.public_ssh_key_from_file(self.project_root, self.environment)
|
|
88
|
-
options[:project_name] = Bebox::Project.shortname_from_file(self.project_root)
|
|
83
|
+
options = {ssh_key: Bebox::Project.public_ssh_key_from_file(project_root, environment), project_name: Bebox::Project.shortname_from_file(project_root)}
|
|
89
84
|
Bebox::Provision.generate_hiera_for_steps(self.project_root, "node.yaml.erb", self.hostname, options)
|
|
90
85
|
end
|
|
91
86
|
|
|
@@ -94,38 +89,6 @@ module Bebox
|
|
|
94
89
|
Bebox::Provision.add_node_to_step_manifests(self.project_root, self)
|
|
95
90
|
end
|
|
96
91
|
|
|
97
|
-
# Prepare the vagrant nodes
|
|
98
|
-
def prepare_vagrant
|
|
99
|
-
project_name = Bebox::Project.name_from_file(self.project_root)
|
|
100
|
-
vagrant_box_base = Bebox::Project.vagrant_box_base_from_file(self.project_root)
|
|
101
|
-
configure_local_hosts(project_name)
|
|
102
|
-
add_vagrant_node(project_name, vagrant_box_base)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Add the boxes to vagrant for each node
|
|
106
|
-
def add_vagrant_node(project_name, vagrant_box_base)
|
|
107
|
-
already_installed_boxes = installed_vagrant_box_names
|
|
108
|
-
box_name = "#{project_name}-#{self.hostname}"
|
|
109
|
-
info "Adding server to vagrant: #{self.hostname}..."
|
|
110
|
-
`cd #{self.project_root} && vagrant box add #{box_name} #{vagrant_box_base}` unless already_installed_boxes.include? box_name
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Up the vagrant boxes in Vagrantfile
|
|
114
|
-
def self.up_vagrant_nodes(project_root)
|
|
115
|
-
`cd #{project_root} && vagrant up --provision`
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Halt the vagrant boxes running
|
|
119
|
-
def self.halt_vagrant_nodes(project_root)
|
|
120
|
-
`cd #{project_root} && vagrant halt`
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# return an Array with the names of the currently installed vagrant boxes
|
|
124
|
-
# @returns Array
|
|
125
|
-
def installed_vagrant_box_names
|
|
126
|
-
(`cd #{self.project_root} && vagrant box list`).split("\n").map{|vagrant_box| vagrant_box.split(' ').first}
|
|
127
|
-
end
|
|
128
|
-
|
|
129
92
|
# returns an Array of the Node objects for an environment
|
|
130
93
|
# @returns Array
|
|
131
94
|
def self.nodes_in_environment(project_root, environment, node_type)
|
|
@@ -138,56 +101,12 @@ module Bebox
|
|
|
138
101
|
node_objects
|
|
139
102
|
end
|
|
140
103
|
|
|
141
|
-
# Generate the Vagrantfile
|
|
142
|
-
def self.generate_vagrantfile(project_root, nodes)
|
|
143
|
-
template = Tilt::ERBTemplate.new("#{templates_path}/node/Vagrantfile.erb")
|
|
144
|
-
network_interface = RUBY_PLATFORM =~ /darwin/ ? 'en0' : 'eth0'
|
|
145
|
-
project_name = Bebox::Project.name_from_file(project_root)
|
|
146
|
-
vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(project_root)
|
|
147
|
-
File.open("#{project_root}/Vagrantfile", 'w') do |f|
|
|
148
|
-
f.write template.render(nil, :nodes => nodes, :project_name => project_name,
|
|
149
|
-
:vagrant_box_provider => vagrant_box_provider, :network_interface => network_interface)
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
# Backup and add the vagrant hosts to local hosts file
|
|
154
|
-
def configure_local_hosts(project_name)
|
|
155
|
-
info "\nPlease provide your account password, if ask you, to configure the local hosts file."
|
|
156
|
-
backup_local_hosts(project_name)
|
|
157
|
-
add_to_local_hosts
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# Add the vagrant hosts to the local hosts file
|
|
161
|
-
def add_to_local_hosts
|
|
162
|
-
# Get the content of the hosts file
|
|
163
|
-
hosts_content = File.read("#{local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
|
|
164
|
-
# Put the node lines in hosts file if not exist
|
|
165
|
-
line = "#{self.ip} #{self.hostname}"
|
|
166
|
-
node_present = (hosts_content =~ /#{self.ip}\s+#{self.hostname}/) ? true : false
|
|
167
|
-
`echo '#{line} # Added by bebox' >> #{local_hosts_path}/hosts` unless node_present
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# Backup the local hosts file
|
|
171
|
-
def backup_local_hosts(project_name)
|
|
172
|
-
# Make a backup of hosts file
|
|
173
|
-
hosts_backup_file = "#{local_hosts_path}/hosts_before_#{project_name}"
|
|
174
|
-
`sudo cp #{local_hosts_path}/hosts #{hosts_backup_file}` unless File.exist?(hosts_backup_file)
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
# Obtain the local hosts file for the OS
|
|
178
|
-
def local_hosts_path
|
|
179
|
-
RUBY_PLATFORM =~ /darwin/ ? '/private/etc' : '/etc'
|
|
180
|
-
end
|
|
181
|
-
|
|
182
104
|
# Create checkpoint for node
|
|
183
105
|
def create_node_checkpoint
|
|
184
106
|
# Set the creation time for the node
|
|
185
107
|
self.created_at = DateTime.now.to_s
|
|
186
108
|
# Create the checkpoint file from template
|
|
187
|
-
|
|
188
|
-
File.open("#{self.project_root}/.checkpoints/environments/#{self.environment}/nodes/#{self.hostname}.yml", 'w') do |f|
|
|
189
|
-
f.write node_template.render(nil, :node => self)
|
|
190
|
-
end
|
|
109
|
+
generate_file_from_template("#{Bebox::FilesHelper::templates_path}/node/node.yml.erb", "#{project_root}/.checkpoints/environments/#{environment}/nodes/#{hostname}.yml", {node: self})
|
|
191
110
|
end
|
|
192
111
|
|
|
193
112
|
# Remove checkpoints for node
|
|
@@ -205,19 +124,6 @@ module Bebox
|
|
|
205
124
|
Bebox::Provision.remove_node_for_steps(self.project_root, self.hostname)
|
|
206
125
|
end
|
|
207
126
|
|
|
208
|
-
# Remove the specified boxes from vagrant
|
|
209
|
-
def remove_vagrant_box
|
|
210
|
-
project_name = Bebox::Project.name_from_file(self.project_root)
|
|
211
|
-
vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(self.project_root)
|
|
212
|
-
`cd #{self.project_root} && vagrant destroy -f #{self.hostname}`
|
|
213
|
-
`cd #{self.project_root} && vagrant box remove #{project_name}-#{self.hostname} --provider #{vagrant_box_provider}`
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
# Get the templates path inside the gem
|
|
217
|
-
def self.templates_path
|
|
218
|
-
File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
|
|
219
|
-
end
|
|
220
|
-
|
|
221
127
|
# Get the environments path for project
|
|
222
128
|
def self.environments_path(project_root)
|
|
223
129
|
"#{project_root}/.checkpoints/environments"
|
|
@@ -226,24 +132,7 @@ module Bebox
|
|
|
226
132
|
# Regenerate the deploy file for the environment
|
|
227
133
|
def self.regenerate_deploy_file(project_root, environment, nodes)
|
|
228
134
|
template_name = (environment == 'vagrant') ? 'vagrant' : "environment"
|
|
229
|
-
|
|
230
|
-
File.open("#{project_root}/config/deploy/#{environment}.rb", 'w') do |f|
|
|
231
|
-
f.write config_deploy_template.render(nil, :nodes => nodes, :environment => environment)
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
# Return the running status of vagrant node
|
|
236
|
-
def vagrant_box_running?
|
|
237
|
-
status = `cd #{self.project_root} && vagrant status`
|
|
238
|
-
(status =~ /#{self.hostname}\s+running/) ? true : false
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
# Return the existence status of vagrant node
|
|
242
|
-
def vagrant_box_exist?
|
|
243
|
-
vagrant_boxes = `cd #{project_root} && vagrant box list`
|
|
244
|
-
project_name = Bebox::Project.name_from_file(self.project_root)
|
|
245
|
-
vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(self.project_root)
|
|
246
|
-
(vagrant_boxes =~ /#{project_name}-#{self.hostname}\s+\(#{vagrant_box_provider}/) ? true : false
|
|
135
|
+
generate_file_from_template("#{Bebox::FilesHelper::templates_path}/project/config/deploy/#{template_name}.erb", "#{project_root}/config/deploy/#{environment}.rb", {nodes: nodes, environment: environment})
|
|
247
136
|
end
|
|
248
137
|
|
|
249
138
|
# Count the number of prepared nodes
|
|
@@ -257,10 +146,8 @@ module Bebox
|
|
|
257
146
|
checkpoint_directories = %w{nodes prepared_nodes steps/step-0 steps/step-1 steps/step-2 steps/step-3}
|
|
258
147
|
checkpoint_directories.each do |checkpoint_directory|
|
|
259
148
|
checkpoint_directory_path = "#{project_root}/.checkpoints/environments/#{environment}/#{checkpoint_directory}/#{node}.yml"
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
provision_state = "#{state_from_checkpoint(checkpoint_directory)} at #{creation_date}"
|
|
263
|
-
end
|
|
149
|
+
next unless File.exist?(checkpoint_directory_path)
|
|
150
|
+
provision_state = "#{state_from_checkpoint(checkpoint_directory)} at #{Bebox::Node.node_creation_date(project_root, environment, checkpoint_directory, node)}"
|
|
264
151
|
end
|
|
265
152
|
provision_state
|
|
266
153
|
end
|
data/lib/bebox/profile.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
require 'tilt'
|
|
2
1
|
|
|
3
2
|
module Bebox
|
|
4
3
|
class Profile
|
|
5
4
|
|
|
5
|
+
include Bebox::FilesHelper
|
|
6
|
+
|
|
6
7
|
attr_accessor :project_root, :name, :path
|
|
7
8
|
|
|
8
9
|
def initialize(name, project_root, path)
|
|
@@ -36,18 +37,12 @@ module Bebox
|
|
|
36
37
|
|
|
37
38
|
# Generate the manifests init.pp file
|
|
38
39
|
def generate_manifests_file
|
|
39
|
-
|
|
40
|
-
File.open("#{absolute_path}/manifests/init.pp", 'w') do |f|
|
|
41
|
-
f.write manifests_template.render(nil, :profile => self)
|
|
42
|
-
end
|
|
40
|
+
generate_file_from_template("#{templates_path}/puppet/profiles/manifests/init.pp.erb", "#{absolute_path}/manifests/init.pp", {profile: self})
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
# Generate the Puppetfile
|
|
46
44
|
def generate_puppetfile
|
|
47
|
-
|
|
48
|
-
File.open("#{absolute_path}/Puppetfile", 'w') do |f|
|
|
49
|
-
f.write puppetfile_template.render(nil)
|
|
50
|
-
end
|
|
45
|
+
generate_file_from_template("#{templates_path}/puppet/profiles/Puppetfile.erb", "#{absolute_path}/Puppetfile", {})
|
|
51
46
|
end
|
|
52
47
|
|
|
53
48
|
# Path to the templates directory in the gem
|
|
@@ -65,12 +60,6 @@ module Bebox
|
|
|
65
60
|
Bebox::Profile.list(project_root).count
|
|
66
61
|
end
|
|
67
62
|
|
|
68
|
-
# Check if the profile has a valid name
|
|
69
|
-
def self.valid_name?(name)
|
|
70
|
-
valid_name = (name =~ /\A[a-z][a-z0-9_]*\Z/).nil? ? false : true
|
|
71
|
-
valid_name && !Bebox::RESERVED_WORDS.include?(name)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
63
|
# Check if the profile has a valid path name
|
|
75
64
|
def self.valid_pathname?(pathname)
|
|
76
65
|
#Split the name and validate each path part
|
|
@@ -91,7 +80,7 @@ module Bebox
|
|
|
91
80
|
|
|
92
81
|
# Create the profile path relative to the project
|
|
93
82
|
def relative_path
|
|
94
|
-
File.join("#{self.path}", "#{self.name}")
|
|
83
|
+
path.empty? ? self.name : File.join("#{self.path}", "#{self.name}")
|
|
95
84
|
end
|
|
96
85
|
|
|
97
86
|
# Generate the namespace name from the profile relative path
|