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,22 @@
|
|
1
|
+
#
|
2
|
+
# is_bool.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the variable passed to this function is a boolean.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size != 1
|
13
|
+
|
14
|
+
type = arguments[0]
|
15
|
+
|
16
|
+
result = type.is_a?(TrueClass) || type.is_a?(FalseClass)
|
17
|
+
|
18
|
+
return result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# is_domain_name.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the string passed to this function is a syntactically correct domain name.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
if (arguments.size != 1) then
|
12
|
+
raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+
|
13
|
+
"given #{arguments.size} for 1")
|
14
|
+
end
|
15
|
+
|
16
|
+
domain = arguments[0]
|
17
|
+
|
18
|
+
# Limits (rfc1035, 3.1)
|
19
|
+
domain_max_length=255
|
20
|
+
label_min_length=1
|
21
|
+
label_max_length=63
|
22
|
+
|
23
|
+
# Only allow string types
|
24
|
+
return false unless domain.is_a?(String)
|
25
|
+
|
26
|
+
# Allow ".", it is the top level domain
|
27
|
+
return true if domain == '.'
|
28
|
+
|
29
|
+
# Remove the final dot, if present.
|
30
|
+
domain.chomp!('.')
|
31
|
+
|
32
|
+
# Check the whole domain
|
33
|
+
return false if domain.empty?
|
34
|
+
return false if domain.length > domain_max_length
|
35
|
+
|
36
|
+
# Check each label in the domain
|
37
|
+
labels = domain.split('.')
|
38
|
+
vlabels = labels.each do |label|
|
39
|
+
break if label.length < label_min_length
|
40
|
+
break if label.length > label_max_length
|
41
|
+
break if label[-1..-1] == '-'
|
42
|
+
break if label[0..0] == '-'
|
43
|
+
break unless /^[a-z\d-]+$/i.match(label)
|
44
|
+
end
|
45
|
+
return vlabels == labels
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# is_float.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_float, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the variable passed to this function is a float.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
if (arguments.size != 1) then
|
12
|
+
raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
|
13
|
+
"given #{arguments.size} for 1")
|
14
|
+
end
|
15
|
+
|
16
|
+
value = arguments[0]
|
17
|
+
|
18
|
+
# Only allow Numeric or String types
|
19
|
+
return false unless value.is_a?(Numeric) or value.is_a?(String)
|
20
|
+
|
21
|
+
if value != value.to_f.to_s and !value.is_a? Float then
|
22
|
+
return false
|
23
|
+
else
|
24
|
+
return true
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# vim: set ts=2 sw=2 et :
|
data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# is_function_available.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function accepts a string as an argument, determines whether the
|
8
|
+
Puppet runtime has access to a function by that name. It returns a
|
9
|
+
true if the function exists, false if not.
|
10
|
+
EOS
|
11
|
+
) do |arguments|
|
12
|
+
|
13
|
+
if (arguments.size != 1) then
|
14
|
+
raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+
|
15
|
+
"given #{arguments.size} for 1")
|
16
|
+
end
|
17
|
+
|
18
|
+
# Only allow String types
|
19
|
+
return false unless arguments[0].is_a?(String)
|
20
|
+
|
21
|
+
function = Puppet::Parser::Functions.function(arguments[0].to_sym)
|
22
|
+
function.is_a?(String) and not function.empty?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# is_hash.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the variable passed to this function is a hash.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size != 1
|
13
|
+
|
14
|
+
type = arguments[0]
|
15
|
+
|
16
|
+
result = type.is_a?(Hash)
|
17
|
+
|
18
|
+
return result
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# is_integer.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the variable passed to this function is an Integer or
|
8
|
+
a decimal (base 10) integer in String form. The string may
|
9
|
+
start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not
|
10
|
+
be followed by other digits as this indicates that the value is octal (base 8).
|
11
|
+
|
12
|
+
If given any other argument `false` is returned.
|
13
|
+
EOS
|
14
|
+
) do |arguments|
|
15
|
+
|
16
|
+
if (arguments.size != 1) then
|
17
|
+
raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+
|
18
|
+
"given #{arguments.size} for 1")
|
19
|
+
end
|
20
|
+
|
21
|
+
value = arguments[0]
|
22
|
+
|
23
|
+
# Regex is taken from the lexer of puppet
|
24
|
+
# puppet/pops/parser/lexer.rb but modified to match also
|
25
|
+
# negative values and disallow numbers prefixed with multiple
|
26
|
+
# 0's
|
27
|
+
#
|
28
|
+
# TODO these parameter should be a constant but I'm not sure
|
29
|
+
# if there is no risk to declare it inside of the module
|
30
|
+
# Puppet::Parser::Functions
|
31
|
+
|
32
|
+
# Integer numbers like
|
33
|
+
# -1234568981273
|
34
|
+
# 47291
|
35
|
+
numeric = %r{^-?(?:(?:[1-9]\d*)|0)$}
|
36
|
+
|
37
|
+
if value.is_a? Integer or (value.is_a? String and value.match numeric)
|
38
|
+
return true
|
39
|
+
else
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# is_ip_address.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the string passed to this function is a valid IP address.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
require 'ipaddr'
|
12
|
+
|
13
|
+
if (arguments.size != 1) then
|
14
|
+
raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+
|
15
|
+
"given #{arguments.size} for 1")
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
ip = IPAddr.new(arguments[0])
|
20
|
+
rescue ArgumentError
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
|
24
|
+
if ip.ipv4? or ip.ipv6? then
|
25
|
+
return true
|
26
|
+
else
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# is_mac_address.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the string passed to this function is a valid mac address.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
if (arguments.size != 1) then
|
12
|
+
raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+
|
13
|
+
"given #{arguments.size} for 1")
|
14
|
+
end
|
15
|
+
|
16
|
+
mac = arguments[0]
|
17
|
+
|
18
|
+
if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then
|
19
|
+
return true
|
20
|
+
else
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# is_numeric.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the given argument is a Numeric (Integer or Float),
|
8
|
+
or a String containing either a valid integer in decimal base 10 form, or
|
9
|
+
a valid floating point string representation.
|
10
|
+
|
11
|
+
The function recognizes only decimal (base 10) integers and float but not
|
12
|
+
integers in hex (base 16) or octal (base 8) form.
|
13
|
+
|
14
|
+
The string representation may start with a '-' (minus). If a decimal '.' is used,
|
15
|
+
it must be followed by at least one digit.
|
16
|
+
|
17
|
+
Valid examples:
|
18
|
+
|
19
|
+
77435
|
20
|
+
10e-12
|
21
|
+
-8475
|
22
|
+
0.2343
|
23
|
+
-23.561e3
|
24
|
+
EOS
|
25
|
+
) do |arguments|
|
26
|
+
|
27
|
+
if (arguments.size != 1) then
|
28
|
+
raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+
|
29
|
+
"given #{arguments.size} for 1")
|
30
|
+
end
|
31
|
+
|
32
|
+
value = arguments[0]
|
33
|
+
|
34
|
+
# Regex is taken from the lexer of puppet
|
35
|
+
# puppet/pops/parser/lexer.rb but modified to match also
|
36
|
+
# negative values and disallow invalid octal numbers or
|
37
|
+
# numbers prefixed with multiple 0's (except in hex numbers)
|
38
|
+
#
|
39
|
+
# TODO these parameters should be constants but I'm not sure
|
40
|
+
# if there is no risk to declare them inside of the module
|
41
|
+
# Puppet::Parser::Functions
|
42
|
+
|
43
|
+
# TODO decide if this should be used
|
44
|
+
# HEX numbers like
|
45
|
+
# 0xaa230F
|
46
|
+
# 0X1234009C
|
47
|
+
# 0x0012
|
48
|
+
# -12FcD
|
49
|
+
#numeric_hex = %r{^-?0[xX][0-9A-Fa-f]+$}
|
50
|
+
|
51
|
+
# TODO decide if this should be used
|
52
|
+
# OCTAL numbers like
|
53
|
+
# 01234567
|
54
|
+
# -045372
|
55
|
+
#numeric_oct = %r{^-?0[1-7][0-7]*$}
|
56
|
+
|
57
|
+
# Integer/Float numbers like
|
58
|
+
# -0.1234568981273
|
59
|
+
# 47291
|
60
|
+
# 42.12345e-12
|
61
|
+
numeric = %r{^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$}
|
62
|
+
|
63
|
+
if value.is_a? Numeric or (value.is_a? String and (
|
64
|
+
value.match(numeric) #or
|
65
|
+
# value.match(numeric_hex) or
|
66
|
+
# value.match(numeric_oct)
|
67
|
+
))
|
68
|
+
return true
|
69
|
+
else
|
70
|
+
return false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# is_string.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:is_string, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns true if the variable passed to this function is a string.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "is_string(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
13
|
+
|
14
|
+
type = arguments[0]
|
15
|
+
|
16
|
+
result = type.is_a?(String)
|
17
|
+
|
18
|
+
if result and (type == type.to_f.to_s or type == type.to_i.to_s) then
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
|
22
|
+
return result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# join.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:join, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function joins an array into a string using a separator.
|
8
|
+
|
9
|
+
*Examples:*
|
10
|
+
|
11
|
+
join(['a','b','c'], ",")
|
12
|
+
|
13
|
+
Would result in: "a,b,c"
|
14
|
+
EOS
|
15
|
+
) do |arguments|
|
16
|
+
|
17
|
+
# Technically we support two arguments but only first is mandatory ...
|
18
|
+
raise(Puppet::ParseError, "join(): 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, 'join(): Requires array to work with')
|
25
|
+
end
|
26
|
+
|
27
|
+
suffix = arguments[1] if arguments[1]
|
28
|
+
|
29
|
+
if suffix
|
30
|
+
unless suffix.is_a?(String)
|
31
|
+
raise(Puppet::ParseError, 'join(): Requires string to work with')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
result = suffix ? array.join(suffix) : array.join
|
36
|
+
|
37
|
+
return result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# vim: set ts=2 sw=2 et :
|
data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# join.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS
|
7
|
+
This function joins each key of a hash to that key's corresponding value with a
|
8
|
+
separator. Keys and values are cast to strings. The return value is an array in
|
9
|
+
which each element is one joined key/value pair.
|
10
|
+
|
11
|
+
*Examples:*
|
12
|
+
|
13
|
+
join_keys_to_values({'a'=>1,'b'=>2}, " is ")
|
14
|
+
|
15
|
+
Would result in: ["a is 1","b is 2"]
|
16
|
+
EOS
|
17
|
+
) do |arguments|
|
18
|
+
|
19
|
+
# Validate the number of arguments.
|
20
|
+
if arguments.size != 2
|
21
|
+
raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two " +
|
22
|
+
"arguments, but #{arguments.size} given.")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Validate the first argument.
|
26
|
+
hash = arguments[0]
|
27
|
+
if not hash.is_a?(Hash)
|
28
|
+
raise(TypeError, "join_keys_to_values(): The first argument must be a " +
|
29
|
+
"hash, but a #{hash.class} was given.")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Validate the second argument.
|
33
|
+
separator = arguments[1]
|
34
|
+
if not separator.is_a?(String)
|
35
|
+
raise(TypeError, "join_keys_to_values(): The second argument must be a " +
|
36
|
+
"string, but a #{separator.class} was given.")
|
37
|
+
end
|
38
|
+
|
39
|
+
# Join the keys to their values.
|
40
|
+
hash.map do |k,v|
|
41
|
+
String(k) + separator + String(v)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# keys.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:keys, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Returns the keys of a hash as an array.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "keys(): Wrong number of arguments " +
|
12
|
+
"given (#{arguments.size} for 1)") if arguments.size < 1
|
13
|
+
|
14
|
+
hash = arguments[0]
|
15
|
+
|
16
|
+
unless hash.is_a?(Hash)
|
17
|
+
raise(Puppet::ParseError, 'keys(): Requires hash to work with')
|
18
|
+
end
|
19
|
+
|
20
|
+
result = hash.keys
|
21
|
+
|
22
|
+
return result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
|
3
|
+
newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
4
|
+
Load a YAML file containing an array, string, or hash, and return the data
|
5
|
+
in the corresponding native data type.
|
6
|
+
|
7
|
+
For example:
|
8
|
+
|
9
|
+
$myhash = loadyaml('/etc/puppet/data/myhash.yaml')
|
10
|
+
ENDHEREDOC
|
11
|
+
|
12
|
+
unless args.length == 1
|
13
|
+
raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
|
14
|
+
end
|
15
|
+
|
16
|
+
YAML.load_file(args[0])
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# lstrip.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
module Puppet::Parser::Functions
|
6
|
+
newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS
|
7
|
+
Strips leading spaces to the left of a string.
|
8
|
+
EOS
|
9
|
+
) do |arguments|
|
10
|
+
|
11
|
+
raise(Puppet::ParseError, "lstrip(): 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, 'lstrip(): Requires either ' +
|
19
|
+
'array or string to work with')
|
20
|
+
end
|
21
|
+
|
22
|
+
if value.is_a?(Array)
|
23
|
+
# Numbers in Puppet are often string-encoded which is troublesome ...
|
24
|
+
result = value.collect { |i| i.is_a?(String) ? i.lstrip : i }
|
25
|
+
else
|
26
|
+
result = value.lstrip
|
27
|
+
end
|
28
|
+
|
29
|
+
return result
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:max, :type => :rvalue, :doc => <<-EOS
|
3
|
+
Returns the highest value of all arguments.
|
4
|
+
Requires at least one argument.
|
5
|
+
EOS
|
6
|
+
) do |args|
|
7
|
+
|
8
|
+
raise(Puppet::ParseError, "max(): Wrong number of arguments " +
|
9
|
+
"need at least one") if args.size == 0
|
10
|
+
|
11
|
+
# Sometimes we get numbers as numerics and sometimes as strings.
|
12
|
+
# We try to compare them as numbers when possible
|
13
|
+
return args.max do |a,b|
|
14
|
+
if a.to_s =~ /\A-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then
|
15
|
+
a.to_f <=> b.to_f
|
16
|
+
else
|
17
|
+
a.to_s <=> b.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# member.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
|
6
|
+
# TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
|
7
|
+
|
8
|
+
module Puppet::Parser::Functions
|
9
|
+
newfunction(:member, :type => :rvalue, :doc => <<-EOS
|
10
|
+
This function determines if a variable is a member of an array.
|
11
|
+
|
12
|
+
*Examples:*
|
13
|
+
|
14
|
+
member(['a','b'], 'b')
|
15
|
+
|
16
|
+
Would return: true
|
17
|
+
|
18
|
+
member(['a','b'], 'c')
|
19
|
+
|
20
|
+
Would return: false
|
21
|
+
EOS
|
22
|
+
) do |arguments|
|
23
|
+
|
24
|
+
raise(Puppet::ParseError, "member(): Wrong number of arguments " +
|
25
|
+
"given (#{arguments.size} for 2)") if arguments.size < 2
|
26
|
+
|
27
|
+
array = arguments[0]
|
28
|
+
|
29
|
+
unless array.is_a?(Array)
|
30
|
+
raise(Puppet::ParseError, 'member(): Requires array to work with')
|
31
|
+
end
|
32
|
+
|
33
|
+
item = arguments[1]
|
34
|
+
|
35
|
+
raise(Puppet::ParseError, 'member(): You must provide item ' +
|
36
|
+
'to search for within array given') if item.empty?
|
37
|
+
|
38
|
+
result = array.include?(item)
|
39
|
+
|
40
|
+
return result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# vim: set ts=2 sw=2 et :
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
3
|
+
Merges two or more hashes together and returns the resulting hash.
|
4
|
+
|
5
|
+
For example:
|
6
|
+
|
7
|
+
$hash1 = {'one' => 1, 'two', => 2}
|
8
|
+
$hash2 = {'two' => 'dos', 'three', => 'tres'}
|
9
|
+
$merged_hash = merge($hash1, $hash2)
|
10
|
+
# The resulting hash is equivalent to:
|
11
|
+
# $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
|
12
|
+
|
13
|
+
When there is a duplicate key, the key in the rightmost hash will "win."
|
14
|
+
|
15
|
+
ENDHEREDOC
|
16
|
+
|
17
|
+
if args.length < 2
|
18
|
+
raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)")
|
19
|
+
end
|
20
|
+
|
21
|
+
# The hash we accumulate into
|
22
|
+
accumulator = Hash.new
|
23
|
+
# Merge into the accumulator hash
|
24
|
+
args.each do |arg|
|
25
|
+
next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
|
26
|
+
unless arg.is_a?(Hash)
|
27
|
+
raise Puppet::ParseError, "merge: unexpected argument type #{arg.class}, only expects hash arguments"
|
28
|
+
end
|
29
|
+
accumulator.merge!(arg)
|
30
|
+
end
|
31
|
+
# Return the fully merged hash
|
32
|
+
accumulator
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Puppet::Parser::Functions
|
2
|
+
newfunction(:min, :type => :rvalue, :doc => <<-EOS
|
3
|
+
Returns the lowest value of all arguments.
|
4
|
+
Requires at least one argument.
|
5
|
+
EOS
|
6
|
+
) do |args|
|
7
|
+
|
8
|
+
raise(Puppet::ParseError, "min(): Wrong number of arguments " +
|
9
|
+
"need at least one") if args.size == 0
|
10
|
+
|
11
|
+
# Sometimes we get numbers as numerics and sometimes as strings.
|
12
|
+
# We try to compare them as numbers when possible
|
13
|
+
return args.min do |a,b|
|
14
|
+
if a.to_s =~ /\A^-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then
|
15
|
+
a.to_f <=> b.to_f
|
16
|
+
else
|
17
|
+
a.to_s <=> b.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|