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,43 @@
|
|
1
|
+
#
|
2
|
+
# num2bool.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function converts a number or a string representation of a number into a
|
8
|
+
true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0
|
9
|
+
become true.
|
10
|
+
EOS
|
11
|
+
) do |arguments|
|
12
|
+
|
13
|
+
raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " +
|
14
|
+
"given (#{arguments.size} for 1)") if arguments.size != 1
|
15
|
+
|
16
|
+
number = arguments[0]
|
17
|
+
|
18
|
+
case number
|
19
|
+
when Numeric
|
20
|
+
# Yay, it's a number
|
21
|
+
when String
|
22
|
+
begin
|
23
|
+
number = Float(number)
|
24
|
+
rescue ArgumentError => ex
|
25
|
+
raise(Puppet::ParseError, "num2bool(): '#{number}' does not look like a number: #{ex.message}")
|
26
|
+
end
|
27
|
+
else
|
28
|
+
begin
|
29
|
+
number = number.to_s
|
30
|
+
rescue NoMethodError => ex
|
31
|
+
raise(Puppet::ParseError, "num2bool(): Unable to parse argument: #{ex.message}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Truncate Floats
|
36
|
+
number = number.to_i
|
37
|
+
|
38
|
+
# Return true for any positive number and false otherwise
|
39
|
+
return number > 0
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# parsejson.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function accepts JSON as a string and converts into the correct Puppet
|
8
|
+
structure.
|
9
|
+
EOS
|
10
|
+
) do |arguments|
|
11
|
+
|
12
|
+
if (arguments.size != 1) then
|
13
|
+
raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+
|
14
|
+
"given #{arguments.size} for 1")
|
15
|
+
end
|
16
|
+
|
17
|
+
json = arguments[0]
|
18
|
+
|
19
|
+
# PSON is natively available in puppet
|
20
|
+
PSON.load(json)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# parseyaml.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function accepts YAML as a string and converts it into the correct
|
8
|
+
Puppet structure.
|
9
|
+
EOS
|
10
|
+
) do |arguments|
|
11
|
+
|
12
|
+
if (arguments.size != 1) then
|
13
|
+
raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+
|
14
|
+
"given #{arguments.size} for 1")
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'yaml'
|
18
|
+
|
19
|
+
YAML::load(arguments[0])
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:pick, :type => :rvalue, :doc => <<-EOS
|
3
|
+
|
4
|
+
This function is similar to a coalesce function in SQL in that it will return
|
5
|
+
the first value in a list of values that is not undefined or an empty string
|
6
|
+
(two things in Puppet that will return a boolean false value). Typically,
|
7
|
+
this function is used to check for a value in the Puppet Dashboard/Enterprise
|
8
|
+
Console, and failover to a default value like the following:
|
9
|
+
|
10
|
+
$real_jenkins_version = pick($::jenkins_version, '1.449')
|
11
|
+
|
12
|
+
The value of $real_jenkins_version will first look for a top-scope variable
|
13
|
+
called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
|
14
|
+
Enterprise Console are brought into Puppet as top-scope variables), and,
|
15
|
+
failing that, will use a default value of 1.449.
|
16
|
+
|
17
|
+
EOS
|
18
|
+
) do |args|
|
19
|
+
args = args.compact
|
20
|
+
args.delete(:undef)
|
21
|
+
args.delete(:undefined)
|
22
|
+
args.delete("")
|
23
|
+
if args[0].to_s.empty? then
|
24
|
+
fail Puppet::ParseError, "pick(): must receive at least one non empty value"
|
25
|
+
else
|
26
|
+
return args[0]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:pick_default, :type => :rvalue, :doc => <<-EOS
|
3
|
+
|
4
|
+
This function is similar to a coalesce function in SQL in that it will return
|
5
|
+
the first value in a list of values that is not undefined or an empty string
|
6
|
+
(two things in Puppet that will return a boolean false value). If no value is
|
7
|
+
found, it will return the last argument.
|
8
|
+
|
9
|
+
Typically, this function is used to check for a value in the Puppet
|
10
|
+
Dashboard/Enterprise Console, and failover to a default value like the
|
11
|
+
following:
|
12
|
+
|
13
|
+
$real_jenkins_version = pick_default($::jenkins_version, '1.449')
|
14
|
+
|
15
|
+
The value of $real_jenkins_version will first look for a top-scope variable
|
16
|
+
called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
|
17
|
+
Enterprise Console are brought into Puppet as top-scope variables), and,
|
18
|
+
failing that, will use a default value of 1.449.
|
19
|
+
|
20
|
+
Note that, contrary to the pick() function, the pick_default does not fail if
|
21
|
+
all arguments are empty. This allows pick_default to use an empty value as
|
22
|
+
default.
|
23
|
+
|
24
|
+
EOS
|
25
|
+
) do |args|
|
26
|
+
fail "Must receive at least one argument." if args.empty?
|
27
|
+
default = args.last
|
28
|
+
args = args[0..-2].compact
|
29
|
+
args.delete(:undef)
|
30
|
+
args.delete(:undefined)
|
31
|
+
args.delete("")
|
32
|
+
args << default
|
33
|
+
return args[0]
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# prefix.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:prefix, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function applies a prefix to all elements in an array.
|
8
|
+
|
9
|
+
*Examples:*
|
10
|
+
|
11
|
+
prefix(['a','b','c'], 'p')
|
12
|
+
|
13
|
+
Will return: ['pa','pb','pc']
|
14
|
+
EOS
|
15
|
+
) do |arguments|
|
16
|
+
|
17
|
+
# Technically we support two arguments but only first is mandatory ...
|
18
|
+
raise(Puppet::ParseError, "prefix(): Wrong number of arguments " +
|
19
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
20
|
+
|
21
|
+
array = arguments[0]
|
22
|
+
|
23
|
+
unless array.is_a?(Array)
|
24
|
+
raise Puppet::ParseError, "prefix(): expected first argument to be an Array, got #{array.inspect}"
|
25
|
+
end
|
26
|
+
|
27
|
+
prefix = arguments[1] if arguments[1]
|
28
|
+
|
29
|
+
if prefix
|
30
|
+
unless prefix.is_a?(String)
|
31
|
+
raise Puppet::ParseError, "prefix(): expected second argument to be a String, got #{prefix.inspect}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Turn everything into string same as join would do ...
|
36
|
+
result = array.collect do |i|
|
37
|
+
i = i.to_s
|
38
|
+
prefix ? prefix + i : i
|
39
|
+
end
|
40
|
+
|
41
|
+
return result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# range.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
# TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ...
|
6
|
+
|
7
|
+
module Puppet::Parser::Functions
|
8
|
+
newfunction(:range, :type => :rvalue, :doc => <<-EOS
|
9
|
+
When given range in the form of (start, stop) it will extrapolate a range as
|
10
|
+
an array.
|
11
|
+
|
12
|
+
*Examples:*
|
13
|
+
|
14
|
+
range("0", "9")
|
15
|
+
|
16
|
+
Will return: [0,1,2,3,4,5,6,7,8,9]
|
17
|
+
|
18
|
+
range("00", "09")
|
19
|
+
|
20
|
+
Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to
|
21
|
+
integers automatically)
|
22
|
+
|
23
|
+
range("a", "c")
|
24
|
+
|
25
|
+
Will return: ["a","b","c"]
|
26
|
+
|
27
|
+
range("host01", "host10")
|
28
|
+
|
29
|
+
Will return: ["host01", "host02", ..., "host09", "host10"]
|
30
|
+
|
31
|
+
Passing a third argument will cause the generated range to step by that
|
32
|
+
interval, e.g.
|
33
|
+
|
34
|
+
range("0", "9", "2")
|
35
|
+
|
36
|
+
Will return: [0,2,4,6,8]
|
37
|
+
EOS
|
38
|
+
) do |arguments|
|
39
|
+
|
40
|
+
# We support more than one argument but at least one is mandatory ...
|
41
|
+
raise(Puppet::ParseError, "range(): Wrong number of " +
|
42
|
+
"arguments given (#{arguments.size} for 1)") if arguments.size < 1
|
43
|
+
|
44
|
+
if arguments.size > 1
|
45
|
+
start = arguments[0]
|
46
|
+
stop = arguments[1]
|
47
|
+
step = arguments[2].nil? ? 1 : arguments[2].to_i.abs
|
48
|
+
|
49
|
+
type = '..' # We select simplest type for Range available in Ruby ...
|
50
|
+
|
51
|
+
elsif arguments.size > 0
|
52
|
+
value = arguments[0]
|
53
|
+
|
54
|
+
if m = value.match(/^(\w+)(\.\.\.?|\-)(\w+)$/)
|
55
|
+
start = m[1]
|
56
|
+
stop = m[3]
|
57
|
+
|
58
|
+
type = m[2]
|
59
|
+
|
60
|
+
elsif value.match(/^.+$/)
|
61
|
+
raise(Puppet::ParseError, 'range(): Unable to compute range ' +
|
62
|
+
'from the value given')
|
63
|
+
else
|
64
|
+
raise(Puppet::ParseError, 'range(): Unknown format of range given')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check whether we have integer value if so then make it so ...
|
69
|
+
if start.match(/^\d+$/)
|
70
|
+
start = start.to_i
|
71
|
+
stop = stop.to_i
|
72
|
+
else
|
73
|
+
start = start.to_s
|
74
|
+
stop = stop.to_s
|
75
|
+
end
|
76
|
+
|
77
|
+
range = case type
|
78
|
+
when /^(\.\.|\-)$/ then (start .. stop)
|
79
|
+
when /^(\.\.\.)$/ then (start ... stop) # Exclusive of last element ...
|
80
|
+
end
|
81
|
+
|
82
|
+
result = range.step(step).collect { |i| i } # Get them all ... Pokemon ...
|
83
|
+
|
84
|
+
return result
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# reject.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args|
|
7
|
+
This function searches through an array and rejects all elements that match
|
8
|
+
the provided regular expression.
|
9
|
+
|
10
|
+
*Examples:*
|
11
|
+
|
12
|
+
reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
|
13
|
+
|
14
|
+
Would return:
|
15
|
+
|
16
|
+
['bbb','ccc']
|
17
|
+
EOS
|
18
|
+
|
19
|
+
if (args.size != 2)
|
20
|
+
raise Puppet::ParseError,
|
21
|
+
"reject(): Wrong number of arguments given #{args.size} for 2"
|
22
|
+
end
|
23
|
+
|
24
|
+
ary = args[0]
|
25
|
+
pattern = Regexp.new(args[1])
|
26
|
+
|
27
|
+
ary.reject { |e| e =~ pattern }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# reverse.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:reverse, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Reverses the order of a string or array.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "reverse(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
13
|
+
|
14
|
+
value = arguments[0]
|
15
|
+
klass = value.class
|
16
|
+
|
17
|
+
unless [Array, String].include?(klass)
|
18
|
+
raise(Puppet::ParseError, 'reverse(): Requires either ' +
|
19
|
+
'array or string to work with')
|
20
|
+
end
|
21
|
+
|
22
|
+
result = value.reverse
|
23
|
+
|
24
|
+
return result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# rstrip.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Strips leading spaces to the right of the string.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
13
|
+
|
14
|
+
value = arguments[0]
|
15
|
+
klass = value.class
|
16
|
+
|
17
|
+
unless [Array, String].include?(klass)
|
18
|
+
raise(Puppet::ParseError, 'rstrip(): Requires either ' +
|
19
|
+
'array or string to work with')
|
20
|
+
end
|
21
|
+
|
22
|
+
if value.is_a?(Array)
|
23
|
+
result = value.collect { |i| i.is_a?(String) ? i.rstrip : i }
|
24
|
+
else
|
25
|
+
result = value.rstrip
|
26
|
+
end
|
27
|
+
|
28
|
+
return result
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# shuffle.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Randomizes the order of a string or array elements.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "shuffle(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
13
|
+
|
14
|
+
value = arguments[0]
|
15
|
+
klass = value.class
|
16
|
+
|
17
|
+
unless [Array, String].include?(klass)
|
18
|
+
raise(Puppet::ParseError, 'shuffle(): Requires either ' +
|
19
|
+
'array or string to work with')
|
20
|
+
end
|
21
|
+
|
22
|
+
result = value.clone
|
23
|
+
|
24
|
+
string = value.is_a?(String) ? true : false
|
25
|
+
|
26
|
+
# Check whether it makes sense to shuffle ...
|
27
|
+
return result if result.size <= 1
|
28
|
+
|
29
|
+
# We turn any string value into an array to be able to shuffle ...
|
30
|
+
result = string ? result.split('') : result
|
31
|
+
|
32
|
+
elements = result.size
|
33
|
+
|
34
|
+
# Simple implementation of Fisher–Yates in-place shuffle ...
|
35
|
+
elements.times do |i|
|
36
|
+
j = rand(elements - i) + i
|
37
|
+
result[j], result[i] = result[i], result[j]
|
38
|
+
end
|
39
|
+
|
40
|
+
result = string ? result.join : result
|
41
|
+
|
42
|
+
return result
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
# size.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
# TODO(Krzysztof Wilczynski): Support for hashes would be nice too ...
|
6
|
+
|
7
|
+
module Puppet::Parser::Functions
|
8
|
+
newfunction(:size, :type => :rvalue, :doc => <<-EOS
|
9
|
+
Returns the number of elements in a string or array.
|
10
|
+
EOS
|
11
|
+
) do |arguments|
|
12
|
+
|
13
|
+
raise(Puppet::ParseError, "size(): Wrong number of arguments " +
|
14
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
15
|
+
|
16
|
+
item = arguments[0]
|
17
|
+
|
18
|
+
if item.is_a?(String)
|
19
|
+
|
20
|
+
begin
|
21
|
+
#
|
22
|
+
# Check whether your item is a numeric value or not ...
|
23
|
+
# This will take care about positive and/or negative numbers
|
24
|
+
# for both integer and floating-point values ...
|
25
|
+
#
|
26
|
+
# Please note that Puppet has no notion of hexadecimal
|
27
|
+
# nor octal numbers for its DSL at this point in time ...
|
28
|
+
#
|
29
|
+
Float(item)
|
30
|
+
|
31
|
+
raise(Puppet::ParseError, 'size(): Requires either ' +
|
32
|
+
'string or array to work with')
|
33
|
+
|
34
|
+
rescue ArgumentError
|
35
|
+
result = item.size
|
36
|
+
end
|
37
|
+
|
38
|
+
elsif item.is_a?(Array)
|
39
|
+
result = item.size
|
40
|
+
else
|
41
|
+
raise(Puppet::ParseError, 'size(): Unknown type given')
|
42
|
+
end
|
43
|
+
|
44
|
+
return result
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# sort.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:sort, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Sorts strings and arrays lexically.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
if (arguments.size != 1) then
|
12
|
+
raise(Puppet::ParseError, "sort(): Wrong number of arguments "+
|
13
|
+
"given #{arguments.size} for 1")
|
14
|
+
end
|
15
|
+
|
16
|
+
value = arguments[0]
|
17
|
+
|
18
|
+
if value.is_a?(Array) then
|
19
|
+
value.sort
|
20
|
+
elsif value.is_a?(String) then
|
21
|
+
value.split("").sort.join("")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# squeeze.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns a new string where runs of the same character that occur in this set are replaced by a single character.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
if ((arguments.size != 2) and (arguments.size != 1)) then
|
12
|
+
raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+
|
13
|
+
"given #{arguments.size} for 2 or 1")
|
14
|
+
end
|
15
|
+
|
16
|
+
item = arguments[0]
|
17
|
+
squeezeval = arguments[1]
|
18
|
+
|
19
|
+
if item.is_a?(Array) then
|
20
|
+
if squeezeval then
|
21
|
+
item.collect { |i| i.squeeze(squeezeval) }
|
22
|
+
else
|
23
|
+
item.collect { |i| i.squeeze }
|
24
|
+
end
|
25
|
+
else
|
26
|
+
if squeezeval then
|
27
|
+
item.squeeze(squeezeval)
|
28
|
+
else
|
29
|
+
item.squeeze
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# str2bool.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This converts a string to a boolean. This attempt to convert strings that
|
8
|
+
contain things like: y, 1, t, true to 'true' and strings that contain things
|
9
|
+
like: 0, f, n, false, no to 'false'.
|
10
|
+
EOS
|
11
|
+
) do |arguments|
|
12
|
+
|
13
|
+
raise(Puppet::ParseError, "str2bool(): Wrong number of arguments " +
|
14
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
15
|
+
|
16
|
+
string = arguments[0]
|
17
|
+
|
18
|
+
# If string is already Boolean, return it
|
19
|
+
if !!string == string
|
20
|
+
return string
|
21
|
+
end
|
22
|
+
|
23
|
+
unless string.is_a?(String)
|
24
|
+
raise(Puppet::ParseError, 'str2bool(): Requires either ' +
|
25
|
+
'string to work with')
|
26
|
+
end
|
27
|
+
|
28
|
+
# We consider all the yes, no, y, n and so on too ...
|
29
|
+
result = case string
|
30
|
+
#
|
31
|
+
# This is how undef looks like in Puppet ...
|
32
|
+
# We yield false in this case.
|
33
|
+
#
|
34
|
+
when /^$/, '' then false # Empty string will be false ...
|
35
|
+
when /^(1|t|y|true|yes)$/ then true
|
36
|
+
when /^(0|f|n|false|no)$/ then false
|
37
|
+
when /^(undef|undefined)$/ then false # This is not likely to happen ...
|
38
|
+
else
|
39
|
+
raise(Puppet::ParseError, 'str2bool(): Unknown type of boolean given')
|
40
|
+
end
|
41
|
+
|
42
|
+
return result
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# vim: set ts=2 sw=2 et :
|
data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# str2saltedsha512.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This converts a string to a salted-SHA512 password hash (which is used for
|
8
|
+
OS X versions >= 10.7). Given any simple string, you will get a hex version
|
9
|
+
of a salted-SHA512 password hash that can be inserted into your Puppet
|
10
|
+
manifests as a valid password attribute.
|
11
|
+
EOS
|
12
|
+
) do |arguments|
|
13
|
+
require 'digest/sha2'
|
14
|
+
|
15
|
+
raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments " +
|
16
|
+
"passed (#{arguments.size} but we require 1)") if arguments.size != 1
|
17
|
+
|
18
|
+
password = arguments[0]
|
19
|
+
|
20
|
+
unless password.is_a?(String)
|
21
|
+
raise(Puppet::ParseError, 'str2saltedsha512(): Requires a ' +
|
22
|
+
"String argument, you passed: #{password.class}")
|
23
|
+
end
|
24
|
+
|
25
|
+
seedint = rand(2**31 - 1)
|
26
|
+
seedstring = Array(seedint).pack("L")
|
27
|
+
saltedpass = Digest::SHA512.digest(seedstring + password)
|
28
|
+
(seedstring + saltedpass).unpack('H*')[0]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# vim: set ts=2 sw=2 et :
|