bebox 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +78 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +163 -0
- data/LICENSE +21 -0
- data/README.md +372 -0
- data/Rakefile +8 -0
- data/bebox.gemspec +40 -0
- data/bin/bebox +5 -0
- data/lib/bebox/cli.rb +42 -0
- data/lib/bebox/commands/commands_helper.rb +33 -0
- data/lib/bebox/commands/environment_commands.rb +46 -0
- data/lib/bebox/commands/general_commands.rb +24 -0
- data/lib/bebox/commands/node_commands.rb +68 -0
- data/lib/bebox/commands/prepare_commands.rb +59 -0
- data/lib/bebox/commands/project_commands.rb +44 -0
- data/lib/bebox/commands/provision_commands.rb +145 -0
- data/lib/bebox/environment.rb +114 -0
- data/lib/bebox/logger.rb +51 -0
- data/lib/bebox/node.rb +308 -0
- data/lib/bebox/profile.rb +102 -0
- data/lib/bebox/project.rb +259 -0
- data/lib/bebox/provision.rb +257 -0
- data/lib/bebox/role.rb +103 -0
- data/lib/bebox/version.rb +3 -0
- data/lib/bebox/wizards/environment_wizard.rb +45 -0
- data/lib/bebox/wizards/node_wizard.rb +163 -0
- data/lib/bebox/wizards/profile_wizard.rb +91 -0
- data/lib/bebox/wizards/project_wizard.rb +175 -0
- data/lib/bebox/wizards/provision_wizard.rb +80 -0
- data/lib/bebox/wizards/role_wizard.rb +97 -0
- data/lib/bebox.rb +2 -0
- data/lib/deb/puppet_3.6.0/augeas-lenses_0.10.0-0ubuntu4_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/debconf-utils_1.5.42ubuntu1_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/facter_2.0.1-1puppetlabs1_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/hiera_1.3.2-1puppetlabs1_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/libaugeas-ruby1.8_0.3.0-1.1ubuntu4_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/libaugeas-ruby_0.3.0-1.1ubuntu4_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/libaugeas0_0.10.0-0ubuntu4_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/libjson-ruby_1.6.3-1_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/libruby1.8_1.8.7.352-2ubuntu1.4_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/libruby_4.8_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/libshadow-ruby1.8_1.4.1-8build1_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/puppet-common_3.6.0-1puppetlabs1_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/puppet_3.6.0-1puppetlabs1_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/ruby-json_1.6.3-1_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/ruby-rgen_0.6.5-1puppetlabs1_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/ruby1.8_1.8.7.352-2ubuntu1.4_amd64.deb +0 -0
- data/lib/deb/puppet_3.6.0/ruby_4.8_all.deb +0 -0
- data/lib/deb/puppet_3.6.0/virt-what_1.11-1_amd64.deb +0 -0
- data/lib/templates/node/Vagrantfile.erb +18 -0
- data/lib/templates/node/deploy_vagrant_node.erb +3 -0
- data/lib/templates/node/node.yml.erb +3 -0
- data/lib/templates/node/prepared_node.yml.erb +4 -0
- data/lib/templates/node/provisioned_node.yml.erb +4 -0
- data/lib/templates/project/Capfile.erb +2 -0
- data/lib/templates/project/Gemfile.erb +5 -0
- data/lib/templates/project/config/deploy/environment.erb +40 -0
- data/lib/templates/project/config/deploy/vagrant.erb +42 -0
- data/lib/templates/project/config/deploy.erb +120 -0
- data/lib/templates/project/dot_bebox.erb +4 -0
- data/lib/templates/project/gitignore.erb +7 -0
- data/lib/templates/project/ubuntu_dependencies +10 -0
- data/lib/templates/puppet/default_profiles/base/fundamental/ruby/Puppetfile +0 -0
- data/lib/templates/puppet/default_profiles/base/fundamental/ruby/manifests/init.pp +24 -0
- data/lib/templates/puppet/default_profiles/base/fundamental/sudo/Puppetfile +0 -0
- data/lib/templates/puppet/default_profiles/base/fundamental/sudo/manifests/init.pp +22 -0
- data/lib/templates/puppet/default_profiles/base/fundamental/users/Puppetfile +0 -0
- data/lib/templates/puppet/default_profiles/base/fundamental/users/manifests/init.pp +18 -0
- data/lib/templates/puppet/default_profiles/base/security/fail2ban/Puppetfile +2 -0
- data/lib/templates/puppet/default_profiles/base/security/fail2ban/manifests/init.pp +28 -0
- data/lib/templates/puppet/default_profiles/base/security/iptables/Puppetfile +2 -0
- data/lib/templates/puppet/default_profiles/base/security/iptables/manifests/init.pp +27 -0
- data/lib/templates/puppet/default_profiles/base/security/ssh/Puppetfile +2 -0
- data/lib/templates/puppet/default_profiles/base/security/ssh/manifests/init.pp +30 -0
- data/lib/templates/puppet/default_profiles/base/security/sysctl/Puppetfile +2 -0
- data/lib/templates/puppet/default_profiles/base/security/sysctl/manifests/init.pp +20 -0
- data/lib/templates/puppet/default_profiles/base/users/ssh/Puppetfile +2 -0
- data/lib/templates/puppet/default_profiles/base/users/ssh/manifests/init.pp +47 -0
- data/lib/templates/puppet/default_profiles/base/users/users/Puppetfile +0 -0
- data/lib/templates/puppet/default_profiles/base/users/users/manifests/init.pp +18 -0
- data/lib/templates/puppet/default_roles/fundamental/manifests/init.pp +16 -0
- data/lib/templates/puppet/default_roles/security/manifests/init.pp +17 -0
- data/lib/templates/puppet/default_roles/users/manifests/init.pp +15 -0
- data/lib/templates/puppet/profiles/Puppetfile.erb +24 -0
- data/lib/templates/puppet/profiles/manifests/init.pp.erb +17 -0
- data/lib/templates/puppet/roles/manifests/init.pp.erb +14 -0
- data/lib/templates/puppet/step-0/Puppetfile.erb +5 -0
- data/lib/templates/puppet/step-0/hiera/data/common.yaml.erb +26 -0
- data/lib/templates/puppet/step-0/hiera/data/environment.yaml.erb +26 -0
- data/lib/templates/puppet/step-0/hiera/data/node.yaml.erb +26 -0
- data/lib/templates/puppet/step-0/hiera/hiera.yaml.erb +11 -0
- data/lib/templates/puppet/step-0/manifests/node.erb +5 -0
- data/lib/templates/puppet/step-0/manifests/site.pp.erb +15 -0
- data/lib/templates/puppet/step-0/modules/rbenv/AUTHORS +11 -0
- data/lib/templates/puppet/step-0/modules/rbenv/CHANGELOG.md +70 -0
- data/lib/templates/puppet/step-0/modules/rbenv/Gemfile +8 -0
- data/lib/templates/puppet/step-0/modules/rbenv/Gemfile.lock +28 -0
- data/lib/templates/puppet/step-0/modules/rbenv/Modulefile +7 -0
- data/lib/templates/puppet/step-0/modules/rbenv/README.md +173 -0
- data/lib/templates/puppet/step-0/modules/rbenv/Rakefile +22 -0
- data/lib/templates/puppet/step-0/modules/rbenv/TODO +10 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/autospec +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/facter +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/filebucket +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/hiera +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/htmldiff +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/ldiff +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/pi +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-lint +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-module +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetca +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetd +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetdoc +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetmasterd +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetqd +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetrun +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/rake +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/ralsh +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec-puppet-init +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/provider/rbenvgem/default.rb +50 -0
- data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/type/rbenvgem.rb +62 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/bundle.pp +36 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/client.pp +48 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/compile.pp +102 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/definition.pp +31 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/centos.pp +25 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/suse.pp +28 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/ubuntu.pp +17 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies.pp +8 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/gem.pp +29 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/install.pp +55 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rbenvvars.pp +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rubybuild.pp +16 -0
- data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin.pp +40 -0
- data/lib/templates/puppet/step-0/modules/rbenv/metadata.json +109 -0
- data/lib/templates/puppet/step-0/modules/rbenv/templates/Gemfile.erb +5 -0
- data/lib/templates/puppet/step-0/modules/rbenv/templates/dot.rbenvrc.erb +8 -0
- data/lib/templates/puppet/step-0/modules/stdlib/CHANGELOG.md +418 -0
- data/lib/templates/puppet/step-0/modules/stdlib/CONTRIBUTING.md +65 -0
- data/lib/templates/puppet/step-0/modules/stdlib/Gemfile +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/Gemfile.lock +166 -0
- data/lib/templates/puppet/step-0/modules/stdlib/LICENSE +19 -0
- data/lib/templates/puppet/step-0/modules/stdlib/Modulefile +11 -0
- data/lib/templates/puppet/step-0/modules/stdlib/README.markdown +1304 -0
- data/lib/templates/puppet/step-0/modules/stdlib/README_DEVELOPER.markdown +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/README_SPECS.markdown +7 -0
- data/lib/templates/puppet/step-0/modules/stdlib/RELEASE_PROCESS.markdown +24 -0
- data/lib/templates/puppet/step-0/modules/stdlib/Rakefile +18 -0
- data/lib/templates/puppet/step-0/modules/stdlib/checksums.json +349 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/facter_dot_d.rb +202 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/pe_version.rb +53 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/puppet_vardir.rb +26 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/root_home.rb +32 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/util/puppet_settings.rb +21 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/abs.rb +36 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/any2array.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/base64.rb +37 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +49 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +34 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chomp.rb +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chop.rb +37 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/concat.rb +41 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/count.rb +22 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb +44 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete.rb +46 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +49 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb +34 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_values.rb +26 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/difference.rb +36 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/dirname.rb +15 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/downcase.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/empty.rb +28 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +45 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/flatten.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/floor.rb +25 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +46 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +17 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getparam.rb +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getvar.rb +26 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/grep.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +52 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +25 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +25 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_key.rb +28 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/hash.rb +41 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/intersection.rb +34 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_array.rb +22 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_bool.rb +22 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +50 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_float.rb +30 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb +26 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +22 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +45 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +32 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +27 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +75 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_string.rb +26 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join.rb +41 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +47 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/keys.rb +26 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +20 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/max.rb +21 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/member.rb +44 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/merge.rb +34 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/min.rb +21 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +43 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +24 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +24 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick.rb +29 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick_default.rb +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/prefix.rb +45 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/range.rb +88 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reject.rb +31 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reverse.rb +28 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +32 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +46 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/size.rb +48 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/sort.rb +27 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +36 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +46 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +32 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strftime.rb +107 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strip.rb +39 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/suffix.rb +45 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +39 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/time.rb +49 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +28 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/type.rb +50 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/union.rb +34 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/unique.rb +51 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/upcase.rb +41 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +35 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +56 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +81 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +34 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb +48 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb +48 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb +49 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +40 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +71 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +33 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values.rb +39 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values_at.rb +98 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/zip.rb +65 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +83 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/anchor.rb +46 -0
- data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/file_line.rb +79 -0
- data/lib/templates/puppet/step-0/modules/stdlib/manifests/init.pp +20 -0
- data/lib/templates/puppet/step-0/modules/stdlib/manifests/stages.pp +43 -0
- data/lib/templates/puppet/step-0/modules/stdlib/metadata.json +111 -0
- data/lib/templates/puppet/step-0/modules/sudo/.fixtures.yml +5 -0
- data/lib/templates/puppet/step-0/modules/sudo/.gemfile +14 -0
- data/lib/templates/puppet/step-0/modules/sudo/.gemfile.lock +43 -0
- data/lib/templates/puppet/step-0/modules/sudo/.travis.yml +34 -0
- data/lib/templates/puppet/step-0/modules/sudo/LICENSE +13 -0
- data/lib/templates/puppet/step-0/modules/sudo/Modulefile +9 -0
- data/lib/templates/puppet/step-0/modules/sudo/README.md +171 -0
- data/lib/templates/puppet/step-0/modules/sudo/Rakefile +1 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.aix +90 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.archlinux +90 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.deb +90 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.freebsd +98 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.omnios +90 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel5 +97 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel6 +115 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.solaris +90 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.suse +81 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.ubuntu +30 -0
- data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.wheezy +17 -0
- data/lib/templates/puppet/step-0/modules/sudo/lib/augeas/lenses/fixedsudoers.aug +520 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/allow.pp +76 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/conf.pp +105 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/configs.pp +24 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/init.pp +151 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/package/aix.pp +46 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/package/solaris.pp +60 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/package.pp +61 -0
- data/lib/templates/puppet/step-0/modules/sudo/manifests/params.pp +127 -0
- data/lib/templates/puppet/step-0/modules/sudo/metadata.json +59 -0
- data/lib/templates/puppet/step-0/modules/sudo/templates/users_groups.erb +9 -0
- data/lib/templates/puppet/step-0/modules/users/manifests/init.pp +15 -0
- data/lib/templates/puppet/step-0/modules/users/manifests/user.pp +50 -0
- data/lib/templates/puppet/step-1/Puppetfile.erb +5 -0
- data/lib/templates/puppet/step-1/hiera/data/common.yaml.erb +11 -0
- data/lib/templates/puppet/step-1/hiera/data/environment.yaml.erb +11 -0
- data/lib/templates/puppet/step-1/hiera/data/node.yaml.erb +11 -0
- data/lib/templates/puppet/step-1/hiera/hiera.yaml.erb +11 -0
- data/lib/templates/puppet/step-1/manifests/node.erb +5 -0
- data/lib/templates/puppet/step-1/manifests/site.pp.erb +15 -0
- data/lib/templates/puppet/step-1/modules/users/manifests/init.pp +15 -0
- data/lib/templates/puppet/step-1/modules/users/manifests/user.pp +49 -0
- data/lib/templates/puppet/step-2/Puppetfile.erb +5 -0
- data/lib/templates/puppet/step-2/hiera/data/common.yaml.erb +1 -0
- data/lib/templates/puppet/step-2/hiera/data/environment.yaml.erb +1 -0
- data/lib/templates/puppet/step-2/hiera/data/node.yaml.erb +1 -0
- data/lib/templates/puppet/step-2/hiera/hiera.yaml.erb +11 -0
- data/lib/templates/puppet/step-2/manifests/node.erb +3 -0
- data/lib/templates/puppet/step-2/manifests/site.pp.erb +10 -0
- data/lib/templates/puppet/step-3/Puppetfile.erb +5 -0
- data/lib/templates/puppet/step-3/hiera/data/common.yaml.erb +99 -0
- data/lib/templates/puppet/step-3/hiera/data/environment.yaml.erb +99 -0
- data/lib/templates/puppet/step-3/hiera/data/node.yaml.erb +99 -0
- data/lib/templates/puppet/step-3/hiera/hiera.yaml.erb +11 -0
- data/lib/templates/puppet/step-3/manifests/node.erb +5 -0
- data/lib/templates/puppet/step-3/manifests/site.pp.erb +15 -0
- data/spec/environment_spec.rb +82 -0
- data/spec/factories/environment.rb +20 -0
- data/spec/factories/node.rb +22 -0
- data/spec/factories/profile.rb +10 -0
- data/spec/factories/project.rb +17 -0
- data/spec/factories/provision.rb +13 -0
- data/spec/factories/role.rb +9 -0
- data/spec/fixtures/Capfile.test +2 -0
- data/spec/fixtures/Gemfile.test +5 -0
- data/spec/fixtures/config/deploy/environment.test +35 -0
- data/spec/fixtures/config/deploy/production.test +35 -0
- data/spec/fixtures/config/deploy/staging.test +35 -0
- data/spec/fixtures/config/deploy/vagrant.test +37 -0
- data/spec/fixtures/config/deploy.test +120 -0
- data/spec/fixtures/dot_bebox.test.erb +4 -0
- data/spec/fixtures/dot_gitignore.test +8 -0
- data/spec/fixtures/node/Vagrantfile.test.erb +18 -0
- data/spec/fixtures/node/node_0.test.erb +3 -0
- data/spec/fixtures/node/prepared_node_0.test.erb +4 -0
- data/spec/fixtures/node/provisioned_node_0.test.erb +4 -0
- data/spec/fixtures/node/vagrant_deploy.test +38 -0
- data/spec/fixtures/puppet/hiera/data/node0.server1.test.yaml.test +4 -0
- data/spec/fixtures/puppet/profiles/test/profile_0/Puppetfile.test +24 -0
- data/spec/fixtures/puppet/profiles/test/profile_0/Puppetfile_with_modules.test +20 -0
- data/spec/fixtures/puppet/profiles/test/profile_0/manifests/init.pp.test +17 -0
- data/spec/fixtures/puppet/profiles/test/profile_0/manifests/init_with_content.pp.test +22 -0
- data/spec/fixtures/puppet/roles/manifests/init.pp.test +14 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/data/common.yaml.test +26 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/data/node0.server1.test.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/data/pname_env.yaml.test +26 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/data/production.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/data/staging.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/data/vagrant.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-0/hiera/hiera.yaml.test +11 -0
- data/spec/fixtures/puppet/steps/step-0/manifests/site.pp.test +10 -0
- data/spec/fixtures/puppet/steps/step-0/manifests/site_with_node.pp.test +15 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/data/common.yaml.test +11 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/data/node0.server1.test.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/data/pname_env.yaml.test +11 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/data/production.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/data/staging.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/data/vagrant.yaml.test +0 -0
- data/spec/fixtures/puppet/steps/step-1/hiera/hiera.yaml.test +11 -0
- data/spec/fixtures/puppet/steps/step-1/manifests/site.pp.test +10 -0
- data/spec/fixtures/puppet/steps/step-1/manifests/site_with_node.pp.test +15 -0
- data/spec/fixtures/puppet/steps/step-2/Puppetfile.test +6 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/data/common.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/data/node0.server1.test.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/data/pname_env.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/data/production.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/data/staging.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/data/vagrant.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-2/hiera/hiera.yaml.test +11 -0
- data/spec/fixtures/puppet/steps/step-2/manifests/site.pp.test +10 -0
- data/spec/fixtures/puppet/steps/step-2/manifests/site_with_node.pp.test +13 -0
- data/spec/fixtures/puppet/steps/step-2/manifests/site_with_node_role_association.pp.test +16 -0
- data/spec/fixtures/puppet/steps/step-2/modules/profiles/manifests/test/profile_0.pp.test +17 -0
- data/spec/fixtures/puppet/steps/step-2/modules/roles/manifests/role_0.pp.test +16 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/data/common.yaml.test +99 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/data/node0.server1.test.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/data/pname_env.yaml.test +99 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/data/production.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/data/staging.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/data/vagrant.yaml.test +1 -0
- data/spec/fixtures/puppet/steps/step-3/hiera/hiera.yaml.test +11 -0
- data/spec/fixtures/puppet/steps/step-3/manifests/site.pp.test +10 -0
- data/spec/fixtures/puppet/steps/step-3/manifests/site_with_node.pp.test +15 -0
- data/spec/fixtures/puppet/ubuntu_dependencies.test +10 -0
- data/spec/node0.server1.test/prepare_phase_spec.rb +53 -0
- data/spec/node0.server1.test/provision_step_0_spec.rb +46 -0
- data/spec/node0.server1.test/provision_step_1_spec.rb +41 -0
- data/spec/node0.server1.test/provision_step_2_spec.rb +79 -0
- data/spec/node0.server1.test/provision_step_3_spec.rb +76 -0
- data/spec/node_role_spec.rb +20 -0
- data/spec/node_spec.rb +71 -0
- data/spec/node_wizard_spec.rb +22 -0
- data/spec/ordered_phases_spec.rb +55 -0
- data/spec/pre_prepare_spec.rb +78 -0
- data/spec/pre_provision_steps_spec.rb +40 -0
- data/spec/profile_spec.rb +70 -0
- data/spec/project_spec.rb +195 -0
- data/spec/project_wizard_spec.rb +51 -0
- data/spec/puppet_spec_helper.rb +15 -0
- data/spec/role_profiles_spec.rb +40 -0
- data/spec/role_spec.rb +56 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/config_specs.yaml.example +2 -0
- data/spec/vagrant_spec_helper.rb +15 -0
- metadata +625 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Bebox
|
4
|
+
|
5
|
+
PROVISION_STEPS = %w{step-0 step-1 step-2 step-3}
|
6
|
+
PROVISION_STEP_NAMES = %w{0-fundamental 1-users 2-services 3-security}
|
7
|
+
RESERVED_WORDS = %w{and case class default define else elsif false if in import inherits node or true undef unless main settings}
|
8
|
+
|
9
|
+
class Provision
|
10
|
+
|
11
|
+
attr_accessor :environment, :project_root, :node, :step, :started_at, :finished_at
|
12
|
+
|
13
|
+
def initialize(project_root, environment, node, step)
|
14
|
+
self.project_root = project_root
|
15
|
+
self.environment = environment
|
16
|
+
self.node = node
|
17
|
+
self.step = step
|
18
|
+
end
|
19
|
+
|
20
|
+
# Puppet apply Fundamental step
|
21
|
+
def apply
|
22
|
+
started_at = DateTime.now.to_s
|
23
|
+
# Check if a Puppetfile is neccesary for use/not use librarian-puppet
|
24
|
+
check_puppetfile_content
|
25
|
+
# Copy static modules that are not downloaded by librarian-puppet
|
26
|
+
copy_static_modules
|
27
|
+
# Apply step and if the process is succesful create the checkpoint.
|
28
|
+
process_status = apply_step
|
29
|
+
create_step_checkpoint(started_at) if process_status.success?
|
30
|
+
process_status
|
31
|
+
end
|
32
|
+
|
33
|
+
# Check if it's necessary a Puppetfile accord to it's content
|
34
|
+
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?
|
37
|
+
end
|
38
|
+
|
39
|
+
# Copy the static modules to the step-N modules path
|
40
|
+
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
|
+
end
|
43
|
+
|
44
|
+
# Generate the hiera data for step from the template
|
45
|
+
def generate_hiera
|
46
|
+
ssh_key = Bebox::Project.public_ssh_key_from_file(self.project_root, self.environment)
|
47
|
+
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
|
56
|
+
end
|
57
|
+
|
58
|
+
# Generate the site.pp manifests file for step
|
59
|
+
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
|
64
|
+
end
|
65
|
+
|
66
|
+
# Generate the hiera templates for each step
|
67
|
+
def self.generate_hiera_for_steps(project_root, template_file, filename, options)
|
68
|
+
Bebox::PROVISION_STEPS.each do |step|
|
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
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Generate the roles and profiles modules for the step
|
78
|
+
def self.generate_roles_and_profiles(project_root, step, role, profiles)
|
79
|
+
# Re-create the roles and profiles puppet module directories
|
80
|
+
`rm -rf #{project_root}/puppet/steps/#{step_name(step)}/modules/{roles,profiles}`
|
81
|
+
`mkdir -p #{project_root}/puppet/steps/#{step_name(step)}/modules/{roles,profiles}/manifests`
|
82
|
+
# Copy role to puppet roles module
|
83
|
+
`cp #{project_root}/puppet/roles/#{role}/manifests/init.pp #{project_root}/puppet/steps/#{step_name(step)}/modules/roles/manifests/#{role}.pp`
|
84
|
+
# Copy profiles to puppet profiles module
|
85
|
+
profiles.each do |profile|
|
86
|
+
profile_tree = profile.gsub('::','/')
|
87
|
+
profile_tree_parent = profile_tree.split('/')[0...-1].join('/')
|
88
|
+
`mkdir -p #{project_root}/puppet/steps/#{step_name(step)}/modules/profiles/manifests/#{profile_tree_parent}`
|
89
|
+
`cp #{project_root}/puppet/profiles/#{profile_tree}/manifests/init.pp #{project_root}/puppet/steps/#{step_name(step)}/modules/profiles/manifests/#{profile_tree}.pp`
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Generate the Puppetfile from the role-profiles partial puppetfiles
|
94
|
+
def self.generate_puppetfile(project_root, step, profiles)
|
95
|
+
modules = []
|
96
|
+
puppetfile_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/Puppetfile"
|
97
|
+
profiles.each do |profile|
|
98
|
+
profile_puppetfile_path = "#{project_root}/puppet/profiles/#{profile.gsub('::','/')}/Puppetfile"
|
99
|
+
puppetfile_content = File.read(profile_puppetfile_path)
|
100
|
+
modules << puppetfile_content.scan(/^\s*(mod\s*.+?)$/).uniq
|
101
|
+
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
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get the role name associated with a node
|
109
|
+
def self.role_from_node(project_root, step, node)
|
110
|
+
manifest_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp"
|
111
|
+
manifest_content = File.read(manifest_path)
|
112
|
+
matching_nodes = manifest_content.match(/^\s*node\s+#{node}\s*({.*?}\s*)/m)
|
113
|
+
unless matching_nodes.nil?
|
114
|
+
matching_role = matching_nodes[0].strip.match(/roles::(.+?$)/)
|
115
|
+
role = matching_role[1] unless matching_role.nil?
|
116
|
+
end
|
117
|
+
role
|
118
|
+
end
|
119
|
+
|
120
|
+
# Get the profiles names array associated with a role
|
121
|
+
def self.profiles_from_role(project_root, role_name)
|
122
|
+
profiles = []
|
123
|
+
role_path = "#{project_root}/puppet/roles/#{role_name}/manifests/init.pp"
|
124
|
+
role_content = File.read(role_path)
|
125
|
+
matching_roles = role_content.match(/^\s*class\s+roles::#{role_name}\s*({.*?}\s*)/m)
|
126
|
+
profiles = matching_roles[0].strip.scan(/profiles::(.+?$)/).flatten unless matching_roles.nil?
|
127
|
+
profiles
|
128
|
+
end
|
129
|
+
|
130
|
+
# Set a role for a node in the step-2 manifests file
|
131
|
+
def self.associate_node_role(project_root, environment, node_name, role_name)
|
132
|
+
# Create the manifests site.pp file for step-2 if not exist
|
133
|
+
unless Bebox::Provision.manifests_exists?(project_root, 'step-2')
|
134
|
+
nodes = Bebox::Node.nodes_in_environment(project_root, environment, 'nodes')
|
135
|
+
Bebox::Provision.generate_manifests(project_root, self.step, nodes)
|
136
|
+
end
|
137
|
+
# Set the role for a node
|
138
|
+
Bebox::Provision.remove_role(project_root, node_name, 'step-2')
|
139
|
+
Bebox::Provision.add_role(project_root, node_name, role_name)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Add a node to site.pp
|
143
|
+
def self.add_node_to_step_manifests(project_root, node)
|
144
|
+
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)
|
147
|
+
Bebox::Provision.remove_node(project_root, node.hostname, step)
|
148
|
+
manifest_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp"
|
149
|
+
content = File.read(manifest_path)
|
150
|
+
content += "\n#{manifest_node}\n"
|
151
|
+
File.open(manifest_path, 'wb') { |file| file.write(content) }
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Remove hiera data file for node
|
156
|
+
def self.remove_hiera_for_steps(project_root, node_name)
|
157
|
+
Bebox::PROVISION_STEP_NAMES.each do |step|
|
158
|
+
`cd #{project_root} && rm -rf #{project_root}/puppet/steps/#{step}/hiera/data/#{node_name}.yaml`
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Remove node in manifests file for each step
|
163
|
+
def self.remove_node_for_steps(project_root, node_name)
|
164
|
+
Bebox::PROVISION_STEPS.each do |step|
|
165
|
+
Bebox::Provision.remove_node(project_root, node_name, step)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Add a role to a node
|
170
|
+
def self.add_role(project_root, node_name, role_name)
|
171
|
+
tempfile_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name('step-2')}/manifests/site.pp.tmp"
|
172
|
+
manifest_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name('step-2')}/manifests/site.pp"
|
173
|
+
tempfile = File.open(tempfile_path, 'w')
|
174
|
+
manifest_file = File.new(manifest_path)
|
175
|
+
manifest_file.each do |line|
|
176
|
+
line << "\n include roles::#{role_name}\n" if (line =~ /^\s*node\s+#{node_name}\s+{\s*$/)
|
177
|
+
tempfile << line
|
178
|
+
end
|
179
|
+
manifest_file.close
|
180
|
+
tempfile.close
|
181
|
+
FileUtils.mv(tempfile_path, manifest_path)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Remove the current role in a node
|
185
|
+
def self.remove_node(project_root, node_name, step)
|
186
|
+
manifest_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp"
|
187
|
+
regexp = /^\s*node\s+#{node_name}\s*({.*?}\s*)/m
|
188
|
+
content = File.read(manifest_path).sub(regexp, '')
|
189
|
+
File.open(manifest_path, 'wb') { |file| file.write(content) }
|
190
|
+
end
|
191
|
+
|
192
|
+
# Remove the current role in a node
|
193
|
+
def self.remove_role(project_root, node_name, step)
|
194
|
+
manifest_path = "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp"
|
195
|
+
regexp = /^\s*node\s+#{node_name}\s*({.*?}\s*)/m
|
196
|
+
content = File.read(manifest_path).sub(regexp, "\nnode #{node_name} {\n\n}\n\n")
|
197
|
+
File.open(manifest_path, 'wb') { |file| file.write(content) }
|
198
|
+
end
|
199
|
+
|
200
|
+
# Check if a manifests for a step exist
|
201
|
+
def self.manifests_exists?(project_root, step)
|
202
|
+
File.exist?("#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp")
|
203
|
+
end
|
204
|
+
|
205
|
+
# Apply step via capistrano in the machine
|
206
|
+
def apply_step
|
207
|
+
# Create deploy directories
|
208
|
+
cap 'deploy:setup'
|
209
|
+
# Deploy the configured step
|
210
|
+
$?.success? ? (cap 'deploy') : (return $?)
|
211
|
+
# Download dynamic step modules through librarian-puppet
|
212
|
+
$?.success? ? (cap 'puppet:bundle_modules') : (return $?)
|
213
|
+
# Install the step provision through puppet
|
214
|
+
$?.success? ? (cap 'puppet:apply') : (return $?)
|
215
|
+
$?
|
216
|
+
end
|
217
|
+
|
218
|
+
# Executes capistrano commands
|
219
|
+
def cap(command)
|
220
|
+
`cd #{self.project_root} && BUNDLE_GEMFILE=Gemfile bundle exec cap #{self.environment} #{command} -S phase='#{self.step}' -S step_dir='#{step_name}' HOSTS=#{self.node.hostname}`
|
221
|
+
end
|
222
|
+
|
223
|
+
# Create checkpoint for step
|
224
|
+
def create_step_checkpoint(started_at)
|
225
|
+
self.node.started_at = started_at
|
226
|
+
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')
|
236
|
+
end
|
237
|
+
|
238
|
+
# Translate step name to directory name
|
239
|
+
def step_name
|
240
|
+
Bebox::Provision.step_name(self.step)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Translate step name to directory name
|
244
|
+
def self.step_name(step)
|
245
|
+
case step
|
246
|
+
when 'step-0'
|
247
|
+
'0-fundamental'
|
248
|
+
when 'step-1'
|
249
|
+
'1-users'
|
250
|
+
when 'step-2'
|
251
|
+
'2-services'
|
252
|
+
when 'step-3'
|
253
|
+
'3-security'
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
data/lib/bebox/role.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Bebox
|
4
|
+
class Role
|
5
|
+
|
6
|
+
attr_accessor :project_root, :name
|
7
|
+
|
8
|
+
def initialize(name, project_root)
|
9
|
+
self.project_root = project_root
|
10
|
+
self.name = name
|
11
|
+
end
|
12
|
+
|
13
|
+
# Create all files and directories related to a role
|
14
|
+
def create
|
15
|
+
create_role_directory
|
16
|
+
generate_manifests_file
|
17
|
+
end
|
18
|
+
|
19
|
+
# Delete all files and directories related to a role
|
20
|
+
def remove
|
21
|
+
`cd #{self.project_root} && rm -r puppet/roles/#{self.name}`
|
22
|
+
end
|
23
|
+
|
24
|
+
# Lists existing roles
|
25
|
+
def self.list(project_root)
|
26
|
+
Dir["#{project_root}/puppet/roles/*"].map { |f| File.basename(f) }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create the directories for the role
|
30
|
+
def create_role_directory
|
31
|
+
`cd #{self.project_root} && mkdir -p puppet/roles/#{self.name}/manifests`
|
32
|
+
end
|
33
|
+
|
34
|
+
# Generate the manifests init.pp file
|
35
|
+
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
|
40
|
+
end
|
41
|
+
|
42
|
+
# Path to the templates directory in the gem
|
43
|
+
def templates_path
|
44
|
+
File.join((File.expand_path '..', File.dirname(__FILE__)), 'templates')
|
45
|
+
end
|
46
|
+
|
47
|
+
# Path to the role directory in the project
|
48
|
+
def path
|
49
|
+
"#{self.project_root}/puppet/roles/#{self.name}"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Counts existing roles
|
53
|
+
def self.roles_count(project_root)
|
54
|
+
Bebox::Role.list(project_root).count
|
55
|
+
end
|
56
|
+
|
57
|
+
# Add a profile to a role
|
58
|
+
def self.add_profile(project_root, role, profile)
|
59
|
+
tempfile_path = "#{project_root}/puppet/roles/#{role}/manifests/init.pp.tmp"
|
60
|
+
manifest_path = "#{project_root}/puppet/roles/#{role}/manifests/init.pp"
|
61
|
+
tempfile = File.open(tempfile_path, 'w')
|
62
|
+
manifest_file = File.new(manifest_path)
|
63
|
+
manifest_file.each do |line|
|
64
|
+
line << "\n\tinclude profiles::#{profile.gsub('/','::')}\n" if line.start_with?('class')
|
65
|
+
tempfile << line
|
66
|
+
end
|
67
|
+
manifest_file.close
|
68
|
+
tempfile.close
|
69
|
+
FileUtils.mv(tempfile_path, manifest_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Remove a profile in a role
|
73
|
+
def self.remove_profile(project_root, role, profile)
|
74
|
+
manifest_path = "#{project_root}/puppet/roles/#{role}/manifests/init.pp"
|
75
|
+
regexp = /^\s*include\s+profiles::#{profile.gsub('/','::')}\s*$/
|
76
|
+
content = File.read(manifest_path).gsub(regexp, '')
|
77
|
+
File.open(manifest_path, 'wb') { |file| file.write(content) }
|
78
|
+
end
|
79
|
+
|
80
|
+
# List profiles in a role
|
81
|
+
def self.list_profiles(project_root, role)
|
82
|
+
profiles = []
|
83
|
+
File.readlines("#{project_root}/puppet/roles/#{role}/manifests/init.pp").each do |line|
|
84
|
+
row = line.strip
|
85
|
+
next if row.start_with?('#')
|
86
|
+
profiles << row.split('::').drop(1).join('/') if row.start_with?('include')
|
87
|
+
end
|
88
|
+
profiles
|
89
|
+
end
|
90
|
+
|
91
|
+
# Check if a profile is defined in a role
|
92
|
+
def self.profile_in_role?(project_root, role, profile)
|
93
|
+
role_profiles = Bebox::Role.list_profiles(project_root, role)
|
94
|
+
role_profiles.include?(profile) ? true : false
|
95
|
+
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
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Bebox
|
2
|
+
class EnvironmentWizard
|
3
|
+
include Bebox::Logger
|
4
|
+
# Create a new environment
|
5
|
+
def create_new_environment(project_root, environment_name)
|
6
|
+
# Check if the environment exist
|
7
|
+
return error("The '#{environment_name}' environment already exist!.") if Bebox::Environment.environment_exists?(project_root, environment_name)
|
8
|
+
# Environment creation
|
9
|
+
environment = Bebox::Environment.new(environment_name, project_root)
|
10
|
+
environment.create
|
11
|
+
ok 'Environment created!.'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Removes an existing environment
|
15
|
+
def remove_environment(project_root, environment_name)
|
16
|
+
# Check if the environment exist
|
17
|
+
return error("The '#{environment_name}' environment do not exist!.") unless Bebox::Environment.environment_exists?(project_root, environment_name)
|
18
|
+
# Confirm deletion
|
19
|
+
return warn('No changes were made.') unless confirm_environment_deletion?
|
20
|
+
# Environment deletion
|
21
|
+
environment = Bebox::Environment.new(environment_name, project_root)
|
22
|
+
environment.remove
|
23
|
+
ok 'Environment removed!.'
|
24
|
+
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
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
module Bebox
|
2
|
+
class NodeWizard
|
3
|
+
include Bebox::Logger
|
4
|
+
# Create a new node
|
5
|
+
def create_new_node(project_root, environment)
|
6
|
+
# Ask the hostname for node
|
7
|
+
hostname = ask_not_existing_hostname(project_root, environment)
|
8
|
+
# Ask IP for node
|
9
|
+
ip = ask_ip(environment)
|
10
|
+
# Node creation
|
11
|
+
node = Bebox::Node.new(environment, project_root, hostname, ip)
|
12
|
+
node.create
|
13
|
+
ok 'Node created!.'
|
14
|
+
end
|
15
|
+
|
16
|
+
# Removes an existing node
|
17
|
+
def remove_node(project_root, environment, hostname)
|
18
|
+
# Ask for a node to remove
|
19
|
+
nodes = Bebox::Node.list(project_root, environment, 'nodes')
|
20
|
+
if nodes.count > 0
|
21
|
+
hostname = choose_node(nodes, 'Choose the node to remove:')
|
22
|
+
else
|
23
|
+
return error "There are no nodes in the '#{environment}' environment to remove. No changes were made."
|
24
|
+
end
|
25
|
+
# Ask for deletion confirmation
|
26
|
+
return warn('No changes were made.') unless confirm_node_deletion?
|
27
|
+
# Node deletion
|
28
|
+
node = Bebox::Node.new(environment, project_root, hostname, nil)
|
29
|
+
node.remove
|
30
|
+
ok 'Node removed!.'
|
31
|
+
end
|
32
|
+
|
33
|
+
# Associate a role with a node in a environment
|
34
|
+
def set_role(project_root, environment)
|
35
|
+
roles = Bebox::Role.list(project_root)
|
36
|
+
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:')
|
40
|
+
Bebox::Provision.associate_node_role(project_root, environment, node, role)
|
41
|
+
ok 'Role associated to node!.'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Prepare the nodes in a environment
|
45
|
+
def prepare(project_root, environment)
|
46
|
+
# Check already prepared nodes
|
47
|
+
nodes_to_prepare = check_nodes_to_prepare(project_root, environment)
|
48
|
+
# Output the nodes to be prepared
|
49
|
+
if nodes_to_prepare.count > 0
|
50
|
+
title 'Preparing nodes:'
|
51
|
+
nodes_to_prepare.each{|node| msg(node.hostname)}
|
52
|
+
linebreak
|
53
|
+
# For all environments regenerate the deploy file
|
54
|
+
Bebox::Node.regenerate_deploy_file(project_root, environment, nodes_to_prepare)
|
55
|
+
# If environment is 'vagrant' Prepare and Up the machines
|
56
|
+
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
|
+
end
|
61
|
+
# For all the environments do the preparation
|
62
|
+
nodes_to_prepare.each do |node|
|
63
|
+
node.prepare
|
64
|
+
ok 'Node prepared!.'
|
65
|
+
end
|
66
|
+
else
|
67
|
+
warn 'There are no nodes to prepare. No changes were made.'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check the nodes already prepared and ask confirmation to re-do-it
|
72
|
+
def check_nodes_to_prepare(project_root, environment)
|
73
|
+
nodes_to_prepare = []
|
74
|
+
nodes = Bebox::Node.nodes_in_environment(project_root, environment, 'nodes')
|
75
|
+
prepared_nodes = Bebox::Node.list(project_root, environment, 'prepared_nodes')
|
76
|
+
nodes.each do |node|
|
77
|
+
if prepared_nodes.include?(node.hostname)
|
78
|
+
nodes_to_prepare << node if confirm_node_preparation?(node)
|
79
|
+
else
|
80
|
+
nodes_to_prepare << node
|
81
|
+
end
|
82
|
+
end
|
83
|
+
nodes_to_prepare
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check if there's an existing node in a environment
|
87
|
+
def node_exists?(project_root, environment, node_name)
|
88
|
+
File.exists?("#{project_root}/.checkpoints/environments/#{environment}/nodes/#{node_name}.yml")
|
89
|
+
end
|
90
|
+
|
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
|
+
# Keep asking for a hostname that not exist
|
121
|
+
def ask_not_existing_hostname(project_root, environment)
|
122
|
+
hostname = ask_hostname(project_root, environment)
|
123
|
+
# Check if the node not exist
|
124
|
+
if node_exists?(project_root, environment, hostname)
|
125
|
+
error 'A hostname with that name already exist. Try a new one.'
|
126
|
+
ask_hostname(project_root, environment)
|
127
|
+
else
|
128
|
+
return hostname
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Ask for the hostname until is valid
|
133
|
+
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
|
138
|
+
end
|
139
|
+
|
140
|
+
# Ask for the ip until is valid
|
141
|
+
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
|
146
|
+
# If the environment is not vagrant don't check ip free
|
147
|
+
return ip if environment != 'vagrant'
|
148
|
+
# Check if the ip address is free
|
149
|
+
if free_ip?(ip)
|
150
|
+
return ip
|
151
|
+
else
|
152
|
+
error 'The IP address is not free. Try a new one.'
|
153
|
+
ask_ip(environment)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Validate if the IP address is free
|
158
|
+
def free_ip?(ip)
|
159
|
+
`ping -q -c 1 -W 3000 #{ip}`
|
160
|
+
($?.exitstatus == 0) ? false : true
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'bebox/profile'
|
2
|
+
|
3
|
+
module Bebox
|
4
|
+
class ProfileWizard
|
5
|
+
include Bebox::Logger
|
6
|
+
# Create a new profile
|
7
|
+
def create_new_profile(project_root, profile_name, profile_base_path)
|
8
|
+
# Check if the profile name is valid
|
9
|
+
return error "The profile name can only contain:\n
|
10
|
+
\n* Lowercase letters
|
11
|
+
\n* Numbers
|
12
|
+
\n* Underscores
|
13
|
+
\n* Must begin with an Lowercase letter
|
14
|
+
\n* Can not be any of: #{Bebox::RESERVED_WORDS.join(', ')}
|
15
|
+
\n\nNo changes were made." unless Bebox::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)
|
18
|
+
unless profile_base_path.empty?
|
19
|
+
# Check if the path name is valid
|
20
|
+
return error "Each part of the path can only contain:\n
|
21
|
+
\n* Lowercase letters
|
22
|
+
\n* Numbers
|
23
|
+
\n* Underscores
|
24
|
+
\n* Must begin with an Lowercase letter
|
25
|
+
\n* Can not be any of: #{Bebox::RESERVED_WORDS.join(', ')}
|
26
|
+
\n\nNo changes were made." unless Bebox::Profile.valid_pathname?(profile_base_path)
|
27
|
+
end
|
28
|
+
# Check if the profile exist
|
29
|
+
profile_path = profile_complete_path(profile_base_path, profile_name)
|
30
|
+
return error("The profile '#{profile_path}' already exist. No changes were made.") if profile_exists?(project_root, profile_path)
|
31
|
+
# Profile creation
|
32
|
+
profile = Bebox::Profile.new(profile_name, project_root, profile_base_path)
|
33
|
+
profile.create
|
34
|
+
ok "Profile '#{profile_path}' created!."
|
35
|
+
end
|
36
|
+
|
37
|
+
# Removes an existing profile
|
38
|
+
def remove_profile(project_root)
|
39
|
+
# Choose a profile from the availables
|
40
|
+
profiles = Bebox::Profile.list(project_root)
|
41
|
+
# Get a profile if exist
|
42
|
+
if profiles.count > 0
|
43
|
+
profile = choose_profile(profiles, 'Choose the profile to remove:')
|
44
|
+
else
|
45
|
+
return error "There are no profiles to remove. No changes were made."
|
46
|
+
end
|
47
|
+
# Ask for deletion confirmation
|
48
|
+
return warn('No changes were made.') unless confirm_profile_deletion?
|
49
|
+
# Profile deletion
|
50
|
+
profile_name = profile.split('/').last
|
51
|
+
profile_base_path = profile.split('/')[0...-1].join('/')
|
52
|
+
profile = Bebox::Profile.new(profile_name, project_root, profile_base_path)
|
53
|
+
profile.remove
|
54
|
+
ok 'Profile removed!.'
|
55
|
+
end
|
56
|
+
|
57
|
+
# Lists existing profiles
|
58
|
+
def list_profiles(project_root)
|
59
|
+
Profile.list(project_root)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Create the complete profile path with name
|
63
|
+
def profile_complete_path(profile_base_path, profile_name)
|
64
|
+
File.join("#{profile_base_path}", "#{profile_name}")
|
65
|
+
end
|
66
|
+
|
67
|
+
# Check if there's an existing profile in the project
|
68
|
+
def profile_exists?(project_root, profile_path)
|
69
|
+
Dir.exists?( File.join("#{project_root}/puppet/profiles", "#{profile_path}") )
|
70
|
+
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
|
+
end
|
91
|
+
end
|