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,53 @@
|
|
1
|
+
# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
|
2
|
+
#
|
3
|
+
# Purpose: Return various facts about the PE state of the system
|
4
|
+
#
|
5
|
+
# Resolution: Uses a regex match against puppetversion to determine whether the
|
6
|
+
# machine has Puppet Enterprise installed, and what version (overall, major,
|
7
|
+
# minor, patch) is installed.
|
8
|
+
#
|
9
|
+
# Caveats:
|
10
|
+
#
|
11
|
+
Facter.add("pe_version") do
|
12
|
+
setcode do
|
13
|
+
pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
|
14
|
+
pe_ver[1] if pe_ver
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Facter.add("is_pe") do
|
19
|
+
setcode do
|
20
|
+
if Facter.value(:pe_version).to_s.empty? then
|
21
|
+
false
|
22
|
+
else
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Facter.add("pe_major_version") do
|
29
|
+
confine :is_pe => true
|
30
|
+
setcode do
|
31
|
+
if pe_version = Facter.value(:pe_version)
|
32
|
+
pe_version.to_s.split('.')[0]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Facter.add("pe_minor_version") do
|
38
|
+
confine :is_pe => true
|
39
|
+
setcode do
|
40
|
+
if pe_version = Facter.value(:pe_version)
|
41
|
+
pe_version.to_s.split('.')[1]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Facter.add("pe_patch_version") do
|
47
|
+
confine :is_pe => true
|
48
|
+
setcode do
|
49
|
+
if pe_version = Facter.value(:pe_version)
|
50
|
+
pe_version.to_s.split('.')[2]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This facter fact returns the value of the Puppet vardir setting for the node
|
2
|
+
# running puppet or puppet agent. The intent is to enable Puppet modules to
|
3
|
+
# automatically have insight into a place where they can place variable data,
|
4
|
+
# regardless of the node's platform.
|
5
|
+
#
|
6
|
+
# The value should be directly usable in a File resource path attribute.
|
7
|
+
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'facter/util/puppet_settings'
|
11
|
+
rescue LoadError => e
|
12
|
+
# puppet apply does not add module lib directories to the $LOAD_PATH (See
|
13
|
+
# #4248). It should (in the future) but for the time being we need to be
|
14
|
+
# defensive which is what this rescue block is doing.
|
15
|
+
rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
|
16
|
+
load rb_file if File.exists?(rb_file) or raise e
|
17
|
+
end
|
18
|
+
|
19
|
+
Facter.add(:puppet_vardir) do
|
20
|
+
setcode do
|
21
|
+
# This will be nil if Puppet is not available.
|
22
|
+
Facter::Util::PuppetSettings.with_puppet do
|
23
|
+
Puppet[:vardir]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# A facter fact to determine the root home directory.
|
2
|
+
# This varies on PE supported platforms and may be
|
3
|
+
# reconfigured by the end user.
|
4
|
+
|
5
|
+
module Facter::Util::RootHome
|
6
|
+
class << self
|
7
|
+
def get_root_home
|
8
|
+
root_ent = Facter::Util::Resolution.exec("getent passwd root")
|
9
|
+
# The home directory is the sixth element in the passwd entry
|
10
|
+
# If the platform doesn't have getent, root_ent will be nil and we should
|
11
|
+
# return it straight away.
|
12
|
+
root_ent && root_ent.split(":")[5]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Facter.add(:root_home) do
|
18
|
+
setcode { Facter::Util::RootHome.get_root_home }
|
19
|
+
end
|
20
|
+
|
21
|
+
Facter.add(:root_home) do
|
22
|
+
confine :kernel => :darwin
|
23
|
+
setcode do
|
24
|
+
str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
|
25
|
+
hash = {}
|
26
|
+
str.split("\n").each do |pair|
|
27
|
+
key,value = pair.split(/:/)
|
28
|
+
hash[key] = value
|
29
|
+
end
|
30
|
+
hash['dir'].strip
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Facter
|
2
|
+
module Util
|
3
|
+
module PuppetSettings
|
4
|
+
# This method is intended to provide a convenient way to evaluate a
|
5
|
+
# Facter code block only if Puppet is loaded. This is to account for the
|
6
|
+
# situation where the fact happens to be in the load path, but Puppet is
|
7
|
+
# not loaded for whatever reason. Perhaps the user is simply running
|
8
|
+
# facter without the --puppet flag and they happen to be working in a lib
|
9
|
+
# directory of a module.
|
10
|
+
def self.with_puppet
|
11
|
+
begin
|
12
|
+
Module.const_get("Puppet")
|
13
|
+
rescue NameError
|
14
|
+
nil
|
15
|
+
else
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# abs.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns the absolute value of a number, for example -34.56 becomes
|
8
|
+
34.56. Takes a single integer and float value as an argument.
|
9
|
+
EOS
|
10
|
+
) do |arguments|
|
11
|
+
|
12
|
+
raise(Puppet::ParseError, "abs(): Wrong number of arguments " +
|
13
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
14
|
+
|
15
|
+
value = arguments[0]
|
16
|
+
|
17
|
+
# Numbers in Puppet are often string-encoded which is troublesome ...
|
18
|
+
if value.is_a?(String)
|
19
|
+
if value.match(/^-?(?:\d+)(?:\.\d+){1}$/)
|
20
|
+
value = value.to_f
|
21
|
+
elsif value.match(/^-?\d+$/)
|
22
|
+
value = value.to_i
|
23
|
+
else
|
24
|
+
raise(Puppet::ParseError, 'abs(): Requires float or ' +
|
25
|
+
'integer to work with')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# We have numeric value to handle ...
|
30
|
+
result = value.abs
|
31
|
+
|
32
|
+
return result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# any2array.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This converts any object to an array containing that object. Empty argument
|
8
|
+
lists are converted to an empty array. Arrays are left untouched. Hashes are
|
9
|
+
converted to arrays of alternating keys and values.
|
10
|
+
EOS
|
11
|
+
) do |arguments|
|
12
|
+
|
13
|
+
if arguments.empty?
|
14
|
+
return []
|
15
|
+
end
|
16
|
+
|
17
|
+
if arguments.length == 1
|
18
|
+
if arguments[0].kind_of?(Array)
|
19
|
+
return arguments[0]
|
20
|
+
elsif arguments[0].kind_of?(Hash)
|
21
|
+
result = []
|
22
|
+
arguments[0].each do |key, value|
|
23
|
+
result << key << value
|
24
|
+
end
|
25
|
+
return result
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return arguments
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
|
3
|
+
newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
4
|
+
|
5
|
+
Base64 encode or decode a string based on the command and the string submitted
|
6
|
+
|
7
|
+
Usage:
|
8
|
+
|
9
|
+
$encodestring = base64('encode','thestring')
|
10
|
+
$decodestring = base64('decode','dGhlc3RyaW5n')
|
11
|
+
|
12
|
+
ENDHEREDOC
|
13
|
+
|
14
|
+
require 'base64'
|
15
|
+
|
16
|
+
raise Puppet::ParseError, ("base64(): Wrong number of arguments (#{args.length}; must be = 2)") unless args.length == 2
|
17
|
+
|
18
|
+
actions = ['encode','decode']
|
19
|
+
|
20
|
+
unless actions.include?(args[0])
|
21
|
+
raise Puppet::ParseError, ("base64(): the first argument must be one of 'encode' or 'decode'")
|
22
|
+
end
|
23
|
+
|
24
|
+
unless args[1].is_a?(String)
|
25
|
+
raise Puppet::ParseError, ("base64(): the second argument must be a string to base64")
|
26
|
+
end
|
27
|
+
|
28
|
+
case args[0]
|
29
|
+
when 'encode'
|
30
|
+
result = Base64.encode64(args[1])
|
31
|
+
when 'decode'
|
32
|
+
result = Base64.decode64(args[1])
|
33
|
+
end
|
34
|
+
|
35
|
+
return result
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# bool2num.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Converts a boolean to a number. Converts the values:
|
8
|
+
false, f, 0, n, and no to 0
|
9
|
+
true, t, 1, y, and yes to 1
|
10
|
+
Requires a single boolean or string as an input.
|
11
|
+
EOS
|
12
|
+
) do |arguments|
|
13
|
+
|
14
|
+
raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " +
|
15
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
16
|
+
|
17
|
+
value = arguments[0]
|
18
|
+
klass = value.class
|
19
|
+
|
20
|
+
# We can have either true or false, or string which resembles boolean ...
|
21
|
+
unless [FalseClass, TrueClass, String].include?(klass)
|
22
|
+
raise(Puppet::ParseError, 'bool2num(): Requires either ' +
|
23
|
+
'boolean or string to work with')
|
24
|
+
end
|
25
|
+
|
26
|
+
if value.is_a?(String)
|
27
|
+
# We consider all the yes, no, y, n and so on too ...
|
28
|
+
value = case value
|
29
|
+
#
|
30
|
+
# This is how undef looks like in Puppet ...
|
31
|
+
# We yield 0 (or false if you wish) in this case.
|
32
|
+
#
|
33
|
+
when /^$/, '' then false # Empty string will be false ...
|
34
|
+
when /^(1|t|y|true|yes)$/ then true
|
35
|
+
when /^(0|f|n|false|no)$/ then false
|
36
|
+
when /^(undef|undefined)$/ then false # This is not likely to happen ...
|
37
|
+
else
|
38
|
+
raise(Puppet::ParseError, 'bool2num(): Unknown type of boolean given')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# We have real boolean values as well ...
|
43
|
+
result = value ? 1 : 0
|
44
|
+
|
45
|
+
return result
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# capitalize.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Capitalizes the first letter of a string or array of strings.
|
8
|
+
Requires either a single string or an array as an input.
|
9
|
+
EOS
|
10
|
+
) do |arguments|
|
11
|
+
|
12
|
+
raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " +
|
13
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
14
|
+
|
15
|
+
value = arguments[0]
|
16
|
+
klass = value.class
|
17
|
+
|
18
|
+
unless [Array, String].include?(klass)
|
19
|
+
raise(Puppet::ParseError, 'capitalize(): Requires either ' +
|
20
|
+
'array or string to work with')
|
21
|
+
end
|
22
|
+
|
23
|
+
if value.is_a?(Array)
|
24
|
+
# Numbers in Puppet are often string-encoded which is troublesome ...
|
25
|
+
result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
|
26
|
+
else
|
27
|
+
result = value.capitalize
|
28
|
+
end
|
29
|
+
|
30
|
+
return result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# chomp.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
|
7
|
+
Removes the record separator from the end of a string or an array of
|
8
|
+
strings, for example `hello\n` becomes `hello`.
|
9
|
+
Requires a single string or array as an input.
|
10
|
+
EOS
|
11
|
+
) do |arguments|
|
12
|
+
|
13
|
+
raise(Puppet::ParseError, "chomp(): Wrong number of arguments " +
|
14
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
15
|
+
|
16
|
+
value = arguments[0]
|
17
|
+
klass = value.class
|
18
|
+
|
19
|
+
unless [Array, String].include?(klass)
|
20
|
+
raise(Puppet::ParseError, 'chomp(): Requires either ' +
|
21
|
+
'array or string to work with')
|
22
|
+
end
|
23
|
+
|
24
|
+
if value.is_a?(Array)
|
25
|
+
# Numbers in Puppet are often string-encoded which is troublesome ...
|
26
|
+
result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
|
27
|
+
else
|
28
|
+
result = value.chomp
|
29
|
+
end
|
30
|
+
|
31
|
+
return result
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# chop.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
|
7
|
+
Returns a new string with the last character removed. If the string ends
|
8
|
+
with `\r\n`, both characters are removed. Applying chop to an empty
|
9
|
+
string returns an empty string. If you wish to merely remove record
|
10
|
+
separators then you should use the `chomp` function.
|
11
|
+
Requires a string or array of strings as input.
|
12
|
+
EOS
|
13
|
+
) do |arguments|
|
14
|
+
|
15
|
+
raise(Puppet::ParseError, "chop(): Wrong number of arguments " +
|
16
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
17
|
+
|
18
|
+
value = arguments[0]
|
19
|
+
klass = value.class
|
20
|
+
|
21
|
+
unless [Array, String].include?(klass)
|
22
|
+
raise(Puppet::ParseError, 'chop(): Requires either an ' +
|
23
|
+
'array or string to work with')
|
24
|
+
end
|
25
|
+
|
26
|
+
if value.is_a?(Array)
|
27
|
+
# Numbers in Puppet are often string-encoded which is troublesome ...
|
28
|
+
result = value.collect { |i| i.is_a?(String) ? i.chop : i }
|
29
|
+
else
|
30
|
+
result = value.chop
|
31
|
+
end
|
32
|
+
|
33
|
+
return result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# concat.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Appends the contents of array 2 onto array 1.
|
8
|
+
|
9
|
+
*Example:*
|
10
|
+
|
11
|
+
concat(['1','2','3'],['4','5','6'])
|
12
|
+
|
13
|
+
Would result in:
|
14
|
+
|
15
|
+
['1','2','3','4','5','6']
|
16
|
+
EOS
|
17
|
+
) do |arguments|
|
18
|
+
|
19
|
+
# Check that 2 arguments have been given ...
|
20
|
+
raise(Puppet::ParseError, "concat(): Wrong number of arguments " +
|
21
|
+
"given (#{arguments.size} for 2)") if arguments.size != 2
|
22
|
+
|
23
|
+
a = arguments[0]
|
24
|
+
b = arguments[1]
|
25
|
+
|
26
|
+
# Check that the first parameter is an array
|
27
|
+
unless a.is_a?(Array)
|
28
|
+
raise(Puppet::ParseError, 'concat(): Requires array to work with')
|
29
|
+
end
|
30
|
+
|
31
|
+
if b.is_a?(Array)
|
32
|
+
result = a.concat(b)
|
33
|
+
else
|
34
|
+
result = a << b
|
35
|
+
end
|
36
|
+
|
37
|
+
return result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
|
3
|
+
Takes an array as first argument and an optional second argument.
|
4
|
+
Count the number of elements in array that matches second argument.
|
5
|
+
If called with only an array it counts the number of elements that are not nil/undef.
|
6
|
+
EOS
|
7
|
+
) do |args|
|
8
|
+
|
9
|
+
if (args.size > 2) then
|
10
|
+
raise(ArgumentError, "count(): Wrong number of arguments "+
|
11
|
+
"given #{args.size} for 1 or 2.")
|
12
|
+
end
|
13
|
+
|
14
|
+
collection, item = args
|
15
|
+
|
16
|
+
if item then
|
17
|
+
collection.count item
|
18
|
+
else
|
19
|
+
collection.count { |obj| obj != nil && obj != :undef && obj != '' }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
3
|
+
Recursively merges two or more hashes together and returns the resulting hash.
|
4
|
+
|
5
|
+
For example:
|
6
|
+
|
7
|
+
$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
|
8
|
+
$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
|
9
|
+
$merged_hash = deep_merge($hash1, $hash2)
|
10
|
+
# The resulting hash is equivalent to:
|
11
|
+
# $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
|
12
|
+
|
13
|
+
When there is a duplicate key that is a hash, they are recursively merged.
|
14
|
+
When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
|
15
|
+
|
16
|
+
ENDHEREDOC
|
17
|
+
|
18
|
+
if args.length < 2
|
19
|
+
raise Puppet::ParseError, ("deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)")
|
20
|
+
end
|
21
|
+
|
22
|
+
deep_merge = Proc.new do |hash1,hash2|
|
23
|
+
hash1.merge(hash2) do |key,old_value,new_value|
|
24
|
+
if old_value.is_a?(Hash) && new_value.is_a?(Hash)
|
25
|
+
deep_merge.call(old_value, new_value)
|
26
|
+
else
|
27
|
+
new_value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
result = Hash.new
|
33
|
+
args.each do |arg|
|
34
|
+
next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
|
35
|
+
# If the argument was not a hash, skip it.
|
36
|
+
unless arg.is_a?(Hash)
|
37
|
+
raise Puppet::ParseError, "deep_merge: unexpected argument type #{arg.class}, only expects hash arguments"
|
38
|
+
end
|
39
|
+
|
40
|
+
result = deep_merge.call(result, arg)
|
41
|
+
end
|
42
|
+
return( result )
|
43
|
+
end
|
44
|
+
end
|
data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Test whether a given class or definition is defined
|
2
|
+
require 'puppet/parser/functions'
|
3
|
+
|
4
|
+
Puppet::Parser::Functions.newfunction(:defined_with_params,
|
5
|
+
:type => :rvalue,
|
6
|
+
:doc => <<-'ENDOFDOC'
|
7
|
+
Takes a resource reference and an optional hash of attributes.
|
8
|
+
|
9
|
+
Returns true if a resource with the specified attributes has already been added
|
10
|
+
to the catalog, and false otherwise.
|
11
|
+
|
12
|
+
user { 'dan':
|
13
|
+
ensure => present,
|
14
|
+
}
|
15
|
+
|
16
|
+
if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
|
17
|
+
user { 'dan': ensure => present, }
|
18
|
+
}
|
19
|
+
ENDOFDOC
|
20
|
+
) do |vals|
|
21
|
+
reference, params = vals
|
22
|
+
raise(ArgumentError, 'Must specify a reference') unless reference
|
23
|
+
if (! params) || params == ''
|
24
|
+
params = {}
|
25
|
+
end
|
26
|
+
ret = false
|
27
|
+
if resource = findresource(reference.to_s)
|
28
|
+
matches = params.collect do |key, value|
|
29
|
+
resource[key] == value
|
30
|
+
end
|
31
|
+
ret = params.empty? || !matches.include?(false)
|
32
|
+
end
|
33
|
+
Puppet.debug("Resource #{reference} was not determined to be defined")
|
34
|
+
ret
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# delete.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
|
6
|
+
|
7
|
+
module Puppet::Parser::Functions
|
8
|
+
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
|
9
|
+
Deletes all instances of a given element from an array, substring from a
|
10
|
+
string, or key from a hash.
|
11
|
+
|
12
|
+
*Examples:*
|
13
|
+
|
14
|
+
delete(['a','b','c','b'], 'b')
|
15
|
+
Would return: ['a','c']
|
16
|
+
|
17
|
+
delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
|
18
|
+
Would return: {'a'=>1,'c'=>3}
|
19
|
+
|
20
|
+
delete('abracadabra', 'bra')
|
21
|
+
Would return: 'acada'
|
22
|
+
EOS
|
23
|
+
) do |arguments|
|
24
|
+
|
25
|
+
if (arguments.size != 2) then
|
26
|
+
raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
|
27
|
+
"given #{arguments.size} for 2.")
|
28
|
+
end
|
29
|
+
|
30
|
+
collection = arguments[0].dup
|
31
|
+
item = arguments[1]
|
32
|
+
|
33
|
+
case collection
|
34
|
+
when Array, Hash
|
35
|
+
collection.delete item
|
36
|
+
when String
|
37
|
+
collection.gsub! item, ''
|
38
|
+
else
|
39
|
+
raise(TypeError, "delete(): First argument must be an Array, " +
|
40
|
+
"String, or Hash. Given an argument of class #{collection.class}.")
|
41
|
+
end
|
42
|
+
collection
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# delete_at.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Deletes a determined indexed value from an array.
|
8
|
+
|
9
|
+
*Examples:*
|
10
|
+
|
11
|
+
delete_at(['a','b','c'], 1)
|
12
|
+
|
13
|
+
Would return: ['a','c']
|
14
|
+
EOS
|
15
|
+
) do |arguments|
|
16
|
+
|
17
|
+
raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " +
|
18
|
+
"given (#{arguments.size} for 2)") if arguments.size < 2
|
19
|
+
|
20
|
+
array = arguments[0]
|
21
|
+
|
22
|
+
unless array.is_a?(Array)
|
23
|
+
raise(Puppet::ParseError, 'delete_at(): Requires array to work with')
|
24
|
+
end
|
25
|
+
|
26
|
+
index = arguments[1]
|
27
|
+
|
28
|
+
if index.is_a?(String) and not index.match(/^\d+$/)
|
29
|
+
raise(Puppet::ParseError, 'delete_at(): You must provide ' +
|
30
|
+
'non-negative numeric index')
|
31
|
+
end
|
32
|
+
|
33
|
+
result = array.clone
|
34
|
+
|
35
|
+
# Numbers in Puppet are often string-encoded which is troublesome ...
|
36
|
+
index = index.to_i
|
37
|
+
|
38
|
+
if index > result.size - 1 # First element is at index 0 is it not?
|
39
|
+
raise(Puppet::ParseError, 'delete_at(): Given index ' +
|
40
|
+
'exceeds size of array given')
|
41
|
+
end
|
42
|
+
|
43
|
+
result.delete_at(index) # We ignore the element that got deleted ...
|
44
|
+
|
45
|
+
return result
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# vim: set ts=2 sw=2 et :
|
data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS
|
3
|
+
Returns a copy of input hash or array with all undefs deleted.
|
4
|
+
|
5
|
+
*Examples:*
|
6
|
+
|
7
|
+
$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
|
8
|
+
|
9
|
+
Would return: {a => 'A', b => '', d => false}
|
10
|
+
|
11
|
+
$array = delete_undef_values(['A','',undef,false])
|
12
|
+
|
13
|
+
Would return: ['A','',false]
|
14
|
+
|
15
|
+
EOS
|
16
|
+
) do |args|
|
17
|
+
|
18
|
+
raise(Puppet::ParseError,
|
19
|
+
"delete_undef_values(): Wrong number of arguments given " +
|
20
|
+
"(#{args.size})") if args.size < 1
|
21
|
+
|
22
|
+
unless args[0].is_a? Array or args[0].is_a? Hash
|
23
|
+
raise(Puppet::ParseError,
|
24
|
+
"delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ")
|
25
|
+
end
|
26
|
+
result = args[0].dup
|
27
|
+
if result.is_a?(Hash)
|
28
|
+
result.delete_if {|key, val| val.equal? :undef}
|
29
|
+
elsif result.is_a?(Array)
|
30
|
+
result.delete :undef
|
31
|
+
end
|
32
|
+
result
|
33
|
+
end
|
34
|
+
end
|