├── README.md ├── Roles_and_profiles.graffle ├── Roles_and_profiles.key ├── Roles_and_profiles.pdf ├── Vagrantfile ├── manifests ├── old_site.pp └── site.pp └── modules ├── apache ├── .bundle │ └── config ├── .fixtures.yml ├── .nodeset.yml ├── .travis.yml ├── CHANGELOG ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── Modulefile ├── README.md ├── Rakefile ├── files │ └── httpd ├── lib │ └── puppet │ │ ├── provider │ │ ├── a2mod.rb │ │ └── a2mod │ │ │ ├── a2mod.rb │ │ │ ├── gentoo.rb │ │ │ ├── modfix.rb │ │ │ └── redhat.rb │ │ └── type │ │ └── a2mod.rb ├── manifests │ ├── balancer.pp │ ├── balancermember.pp │ ├── default_mods.pp │ ├── dev.pp │ ├── init.pp │ ├── listen.pp │ ├── mod.pp │ ├── mod │ │ ├── alias.pp │ │ ├── auth_basic.pp │ │ ├── auth_kerb.pp │ │ ├── autoindex.pp │ │ ├── cache.pp │ │ ├── cgi.pp │ │ ├── cgid.pp │ │ ├── dav.pp │ │ ├── dav_fs.pp │ │ ├── dav_svn.pp │ │ ├── deflate.pp │ │ ├── dev.pp │ │ ├── dir.pp │ │ ├── disk_cache.pp │ │ ├── fcgid.pp │ │ ├── headers.pp │ │ ├── info.pp │ │ ├── ldap.pp │ │ ├── mime.pp │ │ ├── mime_magic.pp │ │ ├── mpm_event.pp │ │ ├── negotiation.pp │ │ ├── passenger.pp │ │ ├── perl.pp │ │ ├── php.pp │ │ ├── prefork.pp │ │ ├── proxy.pp │ │ ├── proxy_html.pp │ │ ├── proxy_http.pp │ │ ├── python.pp │ │ ├── reqtimeout.pp │ │ ├── rewrite.pp │ │ ├── setenvif.pp │ │ ├── ssl.pp │ │ ├── status.pp │ │ ├── userdir.pp │ │ ├── vhost_alias.pp │ │ ├── worker.pp │ │ ├── wsgi.pp │ │ └── xsendfile.pp │ ├── namevirtualhost.pp │ ├── params.pp │ ├── php.pp │ ├── proxy.pp │ ├── python.pp │ ├── ssl.pp │ └── vhost.pp ├── metadata.json ├── spec │ ├── classes │ │ ├── apache_spec.rb │ │ ├── dev_spec.rb │ │ ├── mod │ │ │ ├── auth_kerb_spec.rb │ │ │ ├── dav_svn_spec.rb │ │ │ ├── dev_spec.rb │ │ │ ├── dir_spec.rb │ │ │ ├── fcgid_spec.rb │ │ │ ├── info_spec.rb │ │ │ ├── passenger_spec.rb │ │ │ ├── perl_spec.rb │ │ │ ├── php_spec.rb │ │ │ ├── prefork_spec.rb │ │ │ ├── proxy_html_spec.rb │ │ │ ├── python_spec.rb │ │ │ ├── ssl_spec.rb │ │ │ ├── worker_spec.rb │ │ │ └── wsgi_spec.rb │ │ └── params_spec.rb │ ├── defines │ │ ├── mod_spec.rb │ │ └── vhost_spec.rb │ ├── fixtures │ │ ├── modules │ │ │ └── site_apache │ │ │ │ └── templates │ │ │ │ └── fake.conf.erb │ │ └── system │ │ │ └── distro_commands.yaml │ ├── spec.opts │ ├── spec_helper.rb │ ├── spec_helper_system.rb │ ├── system │ │ ├── basic_spec.rb │ │ ├── class_spec.rb │ │ ├── mod_php_spec.rb │ │ ├── prefork_worker_spec.rb │ │ └── vhost_spec.rb │ └── unit │ │ └── provider │ │ └── a2mod │ │ └── gentoo_spec.rb ├── templates │ ├── httpd.conf.erb │ ├── listen.erb │ ├── mod │ │ ├── alias.conf.erb │ │ ├── autoindex.conf.erb │ │ ├── cgid.conf.erb │ │ ├── dav_fs.conf.erb │ │ ├── deflate.conf.erb │ │ ├── dir.conf.erb │ │ ├── disk_cache.conf.erb │ │ ├── info.conf.erb │ │ ├── ldap.conf.erb │ │ ├── mime.conf.erb │ │ ├── mime_magic.conf.erb │ │ ├── mpm_event.conf.erb │ │ ├── negotiation.conf.erb │ │ ├── passenger.conf.erb │ │ ├── php5.conf.erb │ │ ├── prefork.conf.erb │ │ ├── proxy.conf.erb │ │ ├── proxy_html.conf.erb │ │ ├── reqtimeout.conf.erb │ │ ├── setenvif.conf.erb │ │ ├── ssl.conf.erb │ │ ├── status.conf.erb │ │ ├── userdir.conf.erb │ │ └── worker.conf.erb │ ├── namevirtualhost.erb │ ├── ports_header.erb │ ├── vhost.conf.erb │ └── vhost │ │ ├── _aliases.erb │ │ ├── _block.erb │ │ ├── _custom_fragment.erb │ │ ├── _directories.erb │ │ ├── _proxy.erb │ │ ├── _rack.erb │ │ ├── _redirect.erb │ │ ├── _requestheader.erb │ │ ├── _rewrite.erb │ │ ├── _scriptalias.erb │ │ ├── _serveralias.erb │ │ ├── _setenv.erb │ │ └── _ssl.erb └── tests │ ├── apache.pp │ ├── dev.pp │ ├── init.pp │ ├── php.pp │ ├── vhost.pp │ ├── vhost_ip_based.pp │ ├── vhost_ssl.pp │ └── vhosts_without_listen.pp ├── concat ├── CHANGELOG ├── LICENSE ├── Modulefile ├── README.markdown ├── Rakefile ├── files │ ├── concatfragments.sh │ └── null │ │ └── .gitignore ├── lib │ └── facter │ │ └── concat_basedir.rb ├── manifests │ ├── fragment.pp │ ├── init.pp │ └── setup.pp ├── metadata.json └── spec │ ├── defines │ └── init_spec.rb │ ├── fixtures │ └── manifests │ │ └── site.pp │ └── spec_helper.rb ├── mysql ├── .bundle │ └── config ├── .fixtures.yml ├── .forge-release │ ├── pom.xml │ ├── publish │ ├── settings.xml │ └── validate ├── .nodeset.yml ├── .travis.yml ├── CHANGELOG ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── Modulefile ├── README.md ├── Rakefile ├── TODO ├── files │ └── mysqltuner.pl ├── lib │ └── puppet │ │ ├── parser │ │ └── functions │ │ │ └── mysql_password.rb │ │ ├── provider │ │ ├── database │ │ │ └── mysql.rb │ │ ├── database_grant │ │ │ └── mysql.rb │ │ └── database_user │ │ │ └── mysql.rb │ │ └── type │ │ ├── database.rb │ │ ├── database_grant.rb │ │ └── database_user.rb ├── manifests │ ├── backup.pp │ ├── config.pp │ ├── db.pp │ ├── init.pp │ ├── java.pp │ ├── params.pp │ ├── perl.pp │ ├── php.pp │ ├── python.pp │ ├── ruby.pp │ ├── server.pp │ └── server │ │ ├── account_security.pp │ │ ├── config.pp │ │ ├── monitor.pp │ │ └── mysqltuner.pp ├── metadata.json ├── spec │ ├── classes │ │ ├── mysql_backup_spec.rb │ │ ├── mysql_config_spec.rb │ │ ├── mysql_init_spec.rb │ │ ├── mysql_java_spec.rb │ │ ├── mysql_perl_spec.rb │ │ ├── mysql_php_spec.rb │ │ ├── mysql_python_spec.rb │ │ ├── mysql_ruby_spec.rb │ │ ├── mysql_server_account_security_spec.rb │ │ ├── mysql_server_monitor_spec.rb │ │ └── mysql_server_spec.rb │ ├── defines │ │ ├── mysql_db_spec.rb │ │ └── mysql_server_config_spec.rb │ ├── spec.opts │ ├── spec_helper.rb │ ├── spec_helper_system.rb │ ├── system │ │ └── mysql_spec.rb │ └── unit │ │ ├── mysql_password_spec.rb │ │ └── puppet │ │ └── provider │ │ ├── database │ │ └── mysql_spec.rb │ │ ├── database_grant │ │ └── mysql_spec.rb │ │ └── database_user │ │ └── mysql_spec.rb ├── templates │ ├── my.cnf.erb │ ├── my.cnf.pass.erb │ ├── my.conf.cnf.erb │ └── mysqlbackup.sh.erb └── tests │ ├── backup.pp │ ├── init.pp │ ├── java.pp │ ├── mysql_database.pp │ ├── mysql_grant.pp │ ├── mysql_user.pp │ ├── perl.pp │ ├── python.pp │ ├── ruby.pp │ ├── server.pp │ └── server │ ├── account_security.pp │ └── config.pp ├── profile └── manifests │ ├── base.pp │ ├── db.pp │ ├── db │ └── php.pp │ ├── ftp.pp │ ├── web.pp │ └── wordpress.pp ├── role └── manifests │ ├── init.pp │ └── wordpress.pp ├── stdlib ├── CHANGELOG ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── Modulefile ├── README.markdown ├── README_DEVELOPER.markdown ├── README_SPECS.markdown ├── RELEASE_PROCESS.markdown ├── Rakefile ├── lib │ ├── facter │ │ ├── facter_dot_d.rb │ │ ├── pe_version.rb │ │ ├── puppet_vardir.rb │ │ ├── root_home.rb │ │ └── util │ │ │ └── puppet_settings.rb │ └── puppet │ │ ├── parser │ │ └── functions │ │ │ ├── abs.rb │ │ │ ├── any2array.rb │ │ │ ├── bool2num.rb │ │ │ ├── capitalize.rb │ │ │ ├── chomp.rb │ │ │ ├── chop.rb │ │ │ ├── concat.rb │ │ │ ├── count.rb │ │ │ ├── defined_with_params.rb │ │ │ ├── delete.rb │ │ │ ├── delete_at.rb │ │ │ ├── dirname.rb │ │ │ ├── downcase.rb │ │ │ ├── empty.rb │ │ │ ├── ensure_packages.rb │ │ │ ├── ensure_resource.rb │ │ │ ├── flatten.rb │ │ │ ├── floor.rb │ │ │ ├── fqdn_rotate.rb │ │ │ ├── get_module_path.rb │ │ │ ├── getparam.rb │ │ │ ├── getvar.rb │ │ │ ├── grep.rb │ │ │ ├── has_interface_with.rb │ │ │ ├── has_ip_address.rb │ │ │ ├── has_ip_network.rb │ │ │ ├── has_key.rb │ │ │ ├── hash.rb │ │ │ ├── is_array.rb │ │ │ ├── is_domain_name.rb │ │ │ ├── is_float.rb │ │ │ ├── is_function_available.rb │ │ │ ├── is_hash.rb │ │ │ ├── is_integer.rb │ │ │ ├── is_ip_address.rb │ │ │ ├── is_mac_address.rb │ │ │ ├── is_numeric.rb │ │ │ ├── is_string.rb │ │ │ ├── join.rb │ │ │ ├── join_keys_to_values.rb │ │ │ ├── keys.rb │ │ │ ├── loadyaml.rb │ │ │ ├── lstrip.rb │ │ │ ├── max.rb │ │ │ ├── member.rb │ │ │ ├── merge.rb │ │ │ ├── min.rb │ │ │ ├── num2bool.rb │ │ │ ├── parsejson.rb │ │ │ ├── parseyaml.rb │ │ │ ├── pick.rb │ │ │ ├── prefix.rb │ │ │ ├── range.rb │ │ │ ├── reject.rb │ │ │ ├── reverse.rb │ │ │ ├── rstrip.rb │ │ │ ├── shuffle.rb │ │ │ ├── size.rb │ │ │ ├── sort.rb │ │ │ ├── squeeze.rb │ │ │ ├── str2bool.rb │ │ │ ├── str2saltedsha512.rb │ │ │ ├── strftime.rb │ │ │ ├── strip.rb │ │ │ ├── suffix.rb │ │ │ ├── swapcase.rb │ │ │ ├── time.rb │ │ │ ├── to_bytes.rb │ │ │ ├── type.rb │ │ │ ├── unique.rb │ │ │ ├── upcase.rb │ │ │ ├── uriescape.rb │ │ │ ├── validate_absolute_path.rb │ │ │ ├── validate_array.rb │ │ │ ├── validate_augeas.rb │ │ │ ├── validate_bool.rb │ │ │ ├── validate_cmd.rb │ │ │ ├── validate_hash.rb │ │ │ ├── validate_re.rb │ │ │ ├── validate_slength.rb │ │ │ ├── validate_string.rb │ │ │ ├── values.rb │ │ │ ├── values_at.rb │ │ │ └── zip.rb │ │ ├── provider │ │ └── file_line │ │ │ └── ruby.rb │ │ └── type │ │ ├── anchor.rb │ │ └── file_line.rb ├── manifests │ ├── init.pp │ └── stages.pp ├── metadata.json ├── spec │ ├── classes │ │ └── anchor_spec.rb │ ├── fixtures │ │ └── manifests │ │ │ └── site.pp │ ├── functions │ │ ├── defined_with_params_spec.rb │ │ ├── ensure_packages_spec.rb │ │ ├── ensure_resource_spec.rb │ │ └── getparam_spec.rb │ ├── monkey_patches │ │ ├── alias_should_to_must.rb │ │ └── publicize_methods.rb │ ├── spec.opts │ ├── spec_helper.rb │ ├── unit │ │ ├── facter │ │ │ ├── pe_required_facts_spec.rb │ │ │ ├── pe_version_spec.rb │ │ │ ├── root_home_spec.rb │ │ │ └── util │ │ │ │ └── puppet_settings_spec.rb │ │ └── puppet │ │ │ ├── parser │ │ │ └── functions │ │ │ │ ├── abs_spec.rb │ │ │ │ ├── any2array_spec.rb │ │ │ │ ├── bool2num_spec.rb │ │ │ │ ├── capitalize_spec.rb │ │ │ │ ├── chomp_spec.rb │ │ │ │ ├── chop_spec.rb │ │ │ │ ├── concat_spec.rb │ │ │ │ ├── count_spec.rb │ │ │ │ ├── delete_at_spec.rb │ │ │ │ ├── delete_spec.rb │ │ │ │ ├── dirname_spec.rb │ │ │ │ ├── downcase_spec.rb │ │ │ │ ├── empty_spec.rb │ │ │ │ ├── flatten_spec.rb │ │ │ │ ├── floor_spec.rb │ │ │ │ ├── fqdn_rotate_spec.rb │ │ │ │ ├── get_module_path_spec.rb │ │ │ │ ├── getvar_spec.rb │ │ │ │ ├── grep_spec.rb │ │ │ │ ├── has_interface_with_spec.rb │ │ │ │ ├── has_ip_address_spec.rb │ │ │ │ ├── has_ip_network_spec.rb │ │ │ │ ├── has_key_spec.rb │ │ │ │ ├── hash_spec.rb │ │ │ │ ├── is_array_spec.rb │ │ │ │ ├── is_domain_name_spec.rb │ │ │ │ ├── is_float_spec.rb │ │ │ │ ├── is_function_available.rb │ │ │ │ ├── is_hash_spec.rb │ │ │ │ ├── is_integer_spec.rb │ │ │ │ ├── is_ip_address_spec.rb │ │ │ │ ├── is_mac_address_spec.rb │ │ │ │ ├── is_numeric_spec.rb │ │ │ │ ├── is_string_spec.rb │ │ │ │ ├── join_keys_to_values_spec.rb │ │ │ │ ├── join_spec.rb │ │ │ │ ├── keys_spec.rb │ │ │ │ ├── lstrip_spec.rb │ │ │ │ ├── max_spec.rb │ │ │ │ ├── member_spec.rb │ │ │ │ ├── merge_spec.rb │ │ │ │ ├── min_spec.rb │ │ │ │ ├── num2bool_spec.rb │ │ │ │ ├── parsejson_spec.rb │ │ │ │ ├── parseyaml_spec.rb │ │ │ │ ├── pick_spec.rb │ │ │ │ ├── prefix_spec.rb │ │ │ │ ├── range_spec.rb │ │ │ │ ├── reject_spec.rb │ │ │ │ ├── reverse_spec.rb │ │ │ │ ├── rstrip_spec.rb │ │ │ │ ├── shuffle_spec.rb │ │ │ │ ├── size_spec.rb │ │ │ │ ├── sort_spec.rb │ │ │ │ ├── squeeze_spec.rb │ │ │ │ ├── str2bool_spec.rb │ │ │ │ ├── str2saltedsha512_spec.rb │ │ │ │ ├── strftime_spec.rb │ │ │ │ ├── strip_spec.rb │ │ │ │ ├── suffix_spec.rb │ │ │ │ ├── swapcase_spec.rb │ │ │ │ ├── time_spec.rb │ │ │ │ ├── to_bytes_spec.rb │ │ │ │ ├── type_spec.rb │ │ │ │ ├── unique_spec.rb │ │ │ │ ├── upcase_spec.rb │ │ │ │ ├── uriescape_spec.rb │ │ │ │ ├── validate_absolute_path_spec.rb │ │ │ │ ├── validate_array_spec.rb │ │ │ │ ├── validate_augeas_spec.rb │ │ │ │ ├── validate_bool_spec.rb │ │ │ │ ├── validate_cmd_spec.rb │ │ │ │ ├── validate_hash_spec.rb │ │ │ │ ├── validate_re_spec.rb │ │ │ │ ├── validate_slength_spec.rb │ │ │ │ ├── validate_string_spec.rb │ │ │ │ ├── values_at_spec.rb │ │ │ │ ├── values_spec.rb │ │ │ │ └── zip_spec.rb │ │ │ ├── provider │ │ │ └── file_line │ │ │ │ └── ruby_spec.rb │ │ │ └── type │ │ │ ├── anchor_spec.rb │ │ │ └── file_line_spec.rb │ └── watchr.rb └── tests │ ├── file_line.pp │ ├── has_interface_with.pp │ ├── has_ip_address.pp │ ├── has_ip_network.pp │ └── init.pp ├── vsftpd ├── ChangeLog ├── LICENSE ├── Modulefile ├── README.md ├── manifests │ └── init.pp ├── metadata.json ├── templates │ └── vsftpd.conf.erb └── tests │ └── init.pp └── wordpress ├── CHANGELOG ├── Modulefile ├── README.markdown ├── Rakefile ├── manifests ├── app.pp ├── db.pp └── init.pp ├── metadata.json ├── spec ├── classes │ └── wordpress_spec.rb ├── spec.opts └── spec_helper.rb ├── templates ├── wp-config.php.erb └── wp-keysalts.php.erb └── tests └── init.pp /README.md: -------------------------------------------------------------------------------- 1 | Roles & Profiles Example 2 | ======================== 3 | 4 | Converts `manifests/old_site.pp` to a roles and profiles version in `manifests/site.pp` and the `modules/role` and `modules/profile` modules. Uses these modules and their dependencies: 5 | 6 | - puppetlabs/apache 7 | - puppetlabs/mysql 8 | - thias/vsftpd 9 | - hunner/wordpress 10 | 11 | Usage 12 | ----- 13 | 14 | Run `vagrant up` to provision a wordpress instance with the roles & profiles pattern. Visit [http://localhost:8080/blog](http://localhost:8080/blog) to configure wordpress after vagrant provisioning finishes. 15 | -------------------------------------------------------------------------------- /Roles_and_profiles.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hunner/roles_and_profiles/43017ced23fcc181d66386a2daa5e4da9e40b316/Roles_and_profiles.key -------------------------------------------------------------------------------- /Roles_and_profiles.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hunner/roles_and_profiles/43017ced23fcc181d66386a2daa5e4da9e40b316/Roles_and_profiles.pdf -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure('2') do |config| 2 | config.vm.box = "precise32" 3 | config.vm.box_url = "http://files.vagrantup.com/precise32.box" 4 | 5 | config.vm.hostname = 'wordpress.example.com' 6 | config.vm.network :forwarded_port, guest: 80, host: 8080 7 | config.vm.provision :shell, :inline => 'apt-get update' 8 | config.vm.provision :puppet do |puppet| 9 | puppet.manifests_path = "manifests" 10 | puppet.manifest_file = "site.pp" 11 | puppet.module_path = "modules" 12 | end 13 | config.vm.provision :shell, :inline => 'echo Visit http://localhost:8080/blog to configure wordpress' 14 | 15 | end 16 | -------------------------------------------------------------------------------- /manifests/old_site.pp: -------------------------------------------------------------------------------- 1 | node default { 2 | ## Create user 3 | group { 'wordpress': 4 | ensure => present, 5 | } 6 | user { 'wordpress': 7 | ensure => present, 8 | gid => 'wordpress', 9 | password => '$1$jrm5tnjw$h8JJ9mCZLmJvIxvDLjw1M/', #puppet 10 | home => '/var/www/wordpress', 11 | } 12 | 13 | ## Configure mysql 14 | class { 'mysql::server': 15 | config_hash => { 'root_password' => '8ZcJZFHsvo7fINZcAvi0' } 16 | } 17 | include mysql::php 18 | 19 | ## Configure apache 20 | include apache 21 | include apache::mod::php 22 | apache::vhost { $::fqdn: 23 | port => '80', 24 | docroot => '/var/www/wordpress', 25 | } 26 | 27 | ## Configure ftp for installing updates/themes. Disallows root login 28 | include vsftpd 29 | 30 | ## Configure wordpress 31 | class { 'wordpress': 32 | install_dir => '/var/www/wordpress', 33 | db_name => 'wordpress', 34 | db_host => 'localhost', 35 | db_user => 'wordpress', 36 | db_password => 'wordpress', 37 | wp_owner => 'wordpress', 38 | wp_group => 'wordpress', 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /manifests/site.pp: -------------------------------------------------------------------------------- 1 | node default { 2 | include role::wordpress 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_WITHOUT: development 3 | -------------------------------------------------------------------------------- /modules/apache/.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" 4 | concat: "git://github.com/ripienaar/puppet-concat.git" 5 | symlinks: 6 | apache: "#{source_dir}" 7 | -------------------------------------------------------------------------------- /modules/apache/.nodeset.yml: -------------------------------------------------------------------------------- 1 | --- 2 | default_set: 'centos-64-x64' 3 | sets: 4 | 'centos-59-x64': 5 | nodes: 6 | "main.foo.vm": 7 | prefab: 'centos-59-x64' 8 | 'centos-64-x64': 9 | nodes: 10 | "main.foo.vm": 11 | prefab: 'centos-64-x64' 12 | 'fedora-18-x64': 13 | nodes: 14 | "main.foo.vm": 15 | prefab: 'fedora-18-x64' 16 | 'debian-607-x64': 17 | nodes: 18 | "main.foo.vm": 19 | prefab: 'debian-607-x64' 20 | 'debian-70rc1-x64': 21 | nodes: 22 | "main.foo.vm": 23 | prefab: 'debian-70rc1-x64' 24 | 'ubuntu-server-10044-x64': 25 | nodes: 26 | "main.foo.vm": 27 | prefab: 'ubuntu-server-10044-x64' 28 | 'ubuntu-server-12042-x64': 29 | nodes: 30 | "main.foo.vm": 31 | prefab: 'ubuntu-server-12042-x64' 32 | -------------------------------------------------------------------------------- /modules/apache/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | group :development, :test do 4 | gem 'rake', :require => false 5 | gem 'rspec-puppet', :require => false 6 | gem 'puppetlabs_spec_helper', :require => false 7 | gem 'serverspec', :require => false 8 | gem 'rspec-system', :require => false 9 | gem 'rspec-system-puppet', :require => false 10 | gem 'rspec-system-serverspec', :require => false 11 | gem 'puppet-lint', :require => false 12 | end 13 | 14 | if puppetversion = ENV['PUPPET_GEM_VERSION'] 15 | gem 'puppet', puppetversion, :require => false 16 | else 17 | gem 'puppet', :require => false 18 | end 19 | 20 | # vim:ft=ruby 21 | -------------------------------------------------------------------------------- /modules/apache/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012 Puppet Labs Inc 2 | 3 | Puppet Labs can be contacted at: info@puppetlabs.com 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | -------------------------------------------------------------------------------- /modules/apache/Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppetlabs-apache' 2 | version '0.8.1' 3 | source 'git://github.com/puppetlabs/puppetlabs-apache.git' 4 | author 'puppetlabs' 5 | license 'Apache 2.0' 6 | summary 'Puppet module for Apache' 7 | description 'Module for Apache configuration' 8 | project_page 'https://github.com/puppetlabs/puppetlabs-apache' 9 | 10 | ## Add dependencies, if any: 11 | dependency 'puppetlabs/stdlib', '>= 2.2.1' 12 | dependency 'ripienaar/concat', '>= 0.2.0' 13 | -------------------------------------------------------------------------------- /modules/apache/Rakefile: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/rake_tasks' 2 | require 'rspec-system/rake_task' 3 | -------------------------------------------------------------------------------- /modules/apache/files/httpd: -------------------------------------------------------------------------------- 1 | # Configuration file for the httpd service. 2 | 3 | # 4 | # The default processing model (MPM) is the process-based 5 | # 'prefork' model. A thread-based model, 'worker', is also 6 | # available, but does not work with some modules (such as PHP). 7 | # The service must be stopped before changing this variable. 8 | # 9 | #HTTPD=/usr/sbin/httpd.worker 10 | 11 | # 12 | # To pass additional options (for instance, -D definitions) to the 13 | # httpd binary at startup, set OPTIONS here. 14 | # 15 | #OPTIONS= 16 | #OPTIONS=-DDOWN 17 | 18 | # 19 | # By default, the httpd process is started in the C locale; to 20 | # change the locale in which the server runs, the HTTPD_LANG 21 | # variable can be set. 22 | # 23 | #HTTPD_LANG=C 24 | export SHORTHOST=`hostname -s` 25 | -------------------------------------------------------------------------------- /modules/apache/lib/puppet/provider/a2mod.rb: -------------------------------------------------------------------------------- 1 | class Puppet::Provider::A2mod < Puppet::Provider 2 | def self.prefetch(mods) 3 | instances.each do |prov| 4 | if mod = mods[prov.name] 5 | mod.provider = prov 6 | end 7 | end 8 | end 9 | 10 | def flush 11 | @property_hash.clear 12 | end 13 | 14 | def properties 15 | if @property_hash.empty? 16 | @property_hash = query || {:ensure => :absent} 17 | @property_hash[:ensure] = :absent if @property_hash.empty? 18 | end 19 | @property_hash.dup 20 | end 21 | 22 | def query 23 | self.class.instances.each do |mod| 24 | if mod.name == self.name or mod.name.downcase == self.name 25 | return mod.properties 26 | end 27 | end 28 | nil 29 | end 30 | 31 | def exists? 32 | properties[:ensure] != :absent 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /modules/apache/lib/puppet/provider/a2mod/a2mod.rb: -------------------------------------------------------------------------------- 1 | require 'puppet/provider/a2mod' 2 | 3 | Puppet::Type.type(:a2mod).provide(:a2mod, :parent => Puppet::Provider::A2mod) do 4 | desc "Manage Apache 2 modules on Debian and Ubuntu" 5 | 6 | optional_commands :encmd => "a2enmod" 7 | optional_commands :discmd => "a2dismod" 8 | commands :apache2ctl => "apache2ctl" 9 | 10 | confine :osfamily => :debian 11 | defaultfor :operatingsystem => [:debian, :ubuntu] 12 | 13 | def self.instances 14 | modules = apache2ctl("-M").collect { |line| 15 | m = line.match(/(\w+)_module \(shared\)$/) 16 | m[1] if m 17 | }.compact 18 | 19 | modules.map do |mod| 20 | new( 21 | :name => mod, 22 | :ensure => :present, 23 | :provider => :a2mod 24 | ) 25 | end 26 | end 27 | 28 | def create 29 | encmd resource[:name] 30 | end 31 | 32 | def destroy 33 | discmd resource[:name] 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /modules/apache/lib/puppet/provider/a2mod/modfix.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:a2mod).provide :modfix do 2 | desc "Dummy provider for A2mod. 3 | 4 | Fake nil resources when there is no crontab binary available. Allows 5 | puppetd to run on a bootstrapped machine before a Cron package has been 6 | installed. Workaround for: http://projects.puppetlabs.com/issues/2384 7 | " 8 | 9 | def self.instances 10 | [] 11 | end 12 | end -------------------------------------------------------------------------------- /modules/apache/lib/puppet/type/a2mod.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:a2mod) do 2 | @doc = "Manage Apache 2 modules" 3 | 4 | ensurable 5 | 6 | newparam(:name) do 7 | desc "The name of the module to be managed" 8 | 9 | isnamevar 10 | 11 | end 12 | 13 | newparam(:lib) do 14 | desc "The name of the .so library to be loaded" 15 | 16 | defaultto { "mod_#{@resource[:name]}.so" } 17 | end 18 | 19 | newparam(:identifier) do 20 | desc "Module identifier string used by LoadModule. Default: module-name_module" 21 | 22 | # http://httpd.apache.org/docs/2.2/mod/module-dict.html#ModuleIdentifier 23 | 24 | defaultto { "#{resource[:name]}_module" } 25 | end 26 | 27 | autorequire(:package) { catalog.resource(:package, 'httpd')} 28 | 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/manifests/dev.pp: -------------------------------------------------------------------------------- 1 | class apache::dev { 2 | include apache::params 3 | $packages = $apache::params::dev_packages 4 | package { $packages: 5 | ensure => present, 6 | require => Package['httpd'], 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /modules/apache/manifests/listen.pp: -------------------------------------------------------------------------------- 1 | define apache::listen { 2 | $listen_addr_port = $name 3 | include apache::params 4 | 5 | # Template uses: $listen_addr_port 6 | concat::fragment { "Listen ${listen_addr_port}": 7 | target => $apache::params::ports_file, 8 | content => template('apache/listen.erb'), 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/alias.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::alias { 2 | $icons_path = $::osfamily ? { 3 | 'debian' => '/usr/share/apache2/icons', 4 | 'redhat' => '/var/www/icons', 5 | } 6 | apache::mod { 'alias': } 7 | # Template uses $icons_path 8 | file { 'alias.conf': 9 | ensure => file, 10 | path => "${apache::mod_dir}/alias.conf", 11 | content => template('apache/mod/alias.conf.erb'), 12 | require => Exec["mkdir ${apache::mod_dir}"], 13 | before => File[$apache::mod_dir], 14 | notify => Service['httpd'], 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/auth_basic.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::auth_basic { 2 | apache::mod { 'auth_basic': } 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/auth_kerb.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::auth_kerb { 2 | apache::mod { 'auth_kerb': } 3 | } 4 | 5 | 6 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/autoindex.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::autoindex { 2 | apache::mod { 'autoindex': } 3 | # Template uses no variables 4 | file { 'autoindex.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/autoindex.conf", 7 | content => template('apache/mod/autoindex.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/cache.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::cache { 2 | apache::mod { 'cache': } 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/cgi.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::cgi { 2 | Class['apache::mod::prefork'] -> Class['apache::mod::cgi'] 3 | apache::mod { 'cgi': } 4 | } 5 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/cgid.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::cgid { 2 | Class['apache::mod::worker'] -> Class['apache::mod::cgid'] 3 | 4 | # Debian specifies it's cgid sock path, but RedHat uses the default value 5 | # with no config file 6 | $cgisock_path = $::osfamily ? { 7 | 'debian' => '${APACHE_RUN_DIR}/cgisock', 8 | default => undef, 9 | } 10 | apache::mod { 'cgid': } 11 | if $cgisock_path { 12 | # Template uses $cgisock_path 13 | file { 'cgid.conf': 14 | ensure => file, 15 | path => "${apache::mod_dir}/cgid.conf", 16 | content => template('apache/mod/cgid.conf.erb'), 17 | require => Exec["mkdir ${apache::mod_dir}"], 18 | before => File[$apache::mod_dir], 19 | notify => Service['httpd'], 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/dav.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::dav { 2 | apache::mod { 'dav': } 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/dav_fs.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::dav_fs { 2 | $dav_lock = $::osfamily ? { 3 | 'debian' => '${APACHE_LOCK_DIR}/DAVLock', 4 | default => '/var/lib/dav/lockdb', 5 | } 6 | 7 | Class['apache::mod::dav'] -> Class['apache::mod::dav_fs'] 8 | apache::mod { 'dav_fs': } 9 | 10 | # Template uses: $dav_lock 11 | file { 'dav_fs.conf': 12 | ensure => file, 13 | path => "${apache::mod_dir}/dav_fs.conf", 14 | content => template('apache/mod/dav_fs.conf.erb'), 15 | require => Exec["mkdir ${apache::mod_dir}"], 16 | before => File[$apache::mod_dir], 17 | notify => Service['httpd'], 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/dav_svn.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::dav_svn { 2 | include apache::mod::dav 3 | apache::mod { 'dav_svn': } 4 | } 5 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/deflate.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::deflate { 2 | apache::mod { 'deflate': } 3 | # Template uses no variables 4 | file { 'deflate.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/deflate.conf", 7 | content => template('apache/mod/deflate.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/dev.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::dev { 2 | # Development packages are not apache modules 3 | warning('apache::mod::dev is deprecated; please use apache::dev') 4 | include apache::dev 5 | } 6 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/dir.pp: -------------------------------------------------------------------------------- 1 | # Note: this sets the global DirectoryIndex directive, it may be necessary to consider being able to modify the apache::vhost to declare DirectoryIndex statements in a vhost configuration 2 | # Parameters: 3 | # - $indexes provides a string for the DirectoryIndex directive http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex 4 | class apache::mod::dir ( 5 | $dir = 'public_html', 6 | $indexes = ['index.html','index.html.var','index.cgi','index.pl','index.php','index.xhtml'], 7 | ) { 8 | validate_array($indexes) 9 | apache::mod { 'dir': } 10 | 11 | # Template uses 12 | # - $indexes 13 | file { 'dir.conf': 14 | ensure => file, 15 | path => "${apache::mod_dir}/dir.conf", 16 | content => template('apache/mod/dir.conf.erb'), 17 | require => Exec["mkdir ${apache::mod_dir}"], 18 | before => File[$apache::mod_dir], 19 | notify => Service['httpd'], 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/disk_cache.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::disk_cache { 2 | $cache_root = $::osfamily ? { 3 | 'debian' => '/var/cache/apache2/mod_disk_cache', 4 | 'redhat' => '/var/cache/mod_proxy', 5 | } 6 | Class['apache::mod::proxy'] -> Class['apache::mod::disk_cache'] 7 | Class['apache::mod::cache'] -> Class['apache::mod::disk_cache'] 8 | 9 | apache::mod { 'disk_cache': } 10 | # Template uses $cache_proxy 11 | file { 'disk_cache.conf': 12 | ensure => file, 13 | path => "${apache::mod_dir}/disk_cache.conf", 14 | content => template('apache/mod/disk_cache.conf.erb'), 15 | require => Exec["mkdir ${apache::mod_dir}"], 16 | before => File[$apache::mod_dir], 17 | notify => Service['httpd'], 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/fcgid.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::fcgid { 2 | apache::mod { 'fcgid': } 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/headers.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::headers { 2 | apache::mod { 'headers': } 3 | } -------------------------------------------------------------------------------- /modules/apache/manifests/mod/info.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::info ( 2 | $allow_from = ['127.0.0.1','::1'], 3 | ){ 4 | apache::mod { 'info': } 5 | # Template uses $allow_from 6 | file { 'info.conf': 7 | ensure => file, 8 | path => "${apache::mod_dir}/info.conf", 9 | content => template('apache/mod/info.conf.erb'), 10 | require => Exec["mkdir ${apache::mod_dir}"], 11 | before => File[$apache::mod_dir], 12 | notify => Service['httpd'], 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/ldap.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::ldap { 2 | apache::mod { 'ldap': } 3 | # Template uses no variables 4 | file { 'ldap.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/ldap.conf", 7 | content => template('apache/mod/ldap.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/mime.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::mime { 2 | apache::mod { 'mime': } 3 | # Template uses no variables 4 | file { 'mime.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/mime.conf", 7 | content => template('apache/mod/mime.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/mime_magic.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::mime_magic { 2 | apache::mod { 'mime_magic': } 3 | # Template uses no variables 4 | file { 'mime_magic.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/mime_magic.conf", 7 | content => template('apache/mod/mime_magic.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/mpm_event.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::mpm_event { 2 | # Template uses no variables 3 | file { 'mpm_event.conf': 4 | ensure => file, 5 | path => "${apache::mod_dir}/mpm_event.conf", 6 | content => template('apache/mod/mpm_event.conf.erb'), 7 | require => Exec["mkdir ${apache::mod_dir}"], 8 | before => File[$apache::mod_dir], 9 | notify => Service['httpd'], 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/negotiation.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::negotiation { 2 | apache::mod { 'negotiation': } 3 | # Template uses no variables 4 | file { 'negotiation.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/negotiation.conf", 7 | content => template('apache/mod/negotiation.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/passenger.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::passenger ( 2 | $passenger_root = $apache::params::passenger_root, 3 | $passenger_ruby = $apache::params::passenger_ruby, 4 | $passenger_max_pool_size = undef, 5 | ) { 6 | apache::mod { 'passenger': } 7 | # Template uses: $passenger_root, $passenger_ruby, $passenger_max_pool_size 8 | file { 'passenger.conf': 9 | ensure => file, 10 | path => "${apache::mod_dir}/passenger.conf", 11 | content => template('apache/mod/passenger.conf.erb'), 12 | require => Exec["mkdir ${apache::mod_dir}"], 13 | before => File[$apache::mod_dir], 14 | notify => Service['httpd'], 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/perl.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::perl { 2 | apache::mod { 'perl': } 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/php.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::php { 2 | if ! defined(Class['apache::mod::prefork']) { 3 | fail('apache::mod::php requires apache::mod::prefork; please enable mpm_module => \'prefork\' on Class[\'apache\']') 4 | } 5 | apache::mod { 'php5': } 6 | file { 'php5.conf': 7 | ensure => file, 8 | path => "${apache::mod_dir}/php5.conf", 9 | content => template('apache/mod/php5.conf.erb'), 10 | require => [ 11 | Class['apache::mod::prefork'], 12 | Exec["mkdir ${apache::mod_dir}"], 13 | ], 14 | before => File[$apache::mod_dir], 15 | notify => Service['httpd'], 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/proxy.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::proxy ( 2 | $proxy_requests = 'Off', 3 | $allow_from = ['127.0.0.1','::1'], 4 | ) { 5 | apache::mod { 'proxy': } 6 | # Template uses $proxy_requests 7 | file { 'proxy.conf': 8 | ensure => file, 9 | path => "${apache::mod_dir}/proxy.conf", 10 | content => template('apache/mod/proxy.conf.erb'), 11 | require => Exec["mkdir ${apache::mod_dir}"], 12 | before => File[$apache::mod_dir], 13 | notify => Service['httpd'], 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/proxy_html.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::proxy_html { 2 | Class['apache::mod::proxy'] -> Class['apache::mod::proxy_html'] 3 | Class['apache::mod::proxy_http'] -> Class['apache::mod::proxy_html'] 4 | apache::mod { 'proxy_html': } 5 | case $::osfamily { 6 | 'RedHat': { 7 | apache::mod { 'xml2enc': } 8 | } 9 | 'Debian': { 10 | $proxy_html_loadfiles = $apache::params::distrelease ? { 11 | '6' => '/usr/lib/libxml2.so.2', 12 | default => "/usr/lib/${::hardwaremodel}-linux-gnu/libxml2.so.2", 13 | } 14 | } 15 | } 16 | # Template uses $icons_path 17 | file { 'proxy_html.conf': 18 | ensure => file, 19 | path => "${apache::mod_dir}/proxy_html.conf", 20 | content => template('apache/mod/proxy_html.conf.erb'), 21 | require => Exec["mkdir ${apache::mod_dir}"], 22 | before => File[$apache::mod_dir], 23 | notify => Service['httpd'], 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/proxy_http.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::proxy_http { 2 | Class['apache::mod::proxy'] -> Class['apache::mod::proxy_http'] 3 | apache::mod { 'proxy_http': } 4 | } 5 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/python.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::python { 2 | apache::mod { 'python': } 3 | } 4 | 5 | 6 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/reqtimeout.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::reqtimeout { 2 | apache::mod { 'reqtimeout': } 3 | # Template uses no variables 4 | file { 'reqtimeout.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/reqtimeout.conf", 7 | content => template('apache/mod/reqtimeout.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/rewrite.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::rewrite { 2 | include apache::params 3 | apache::mod { 'rewrite': } 4 | } 5 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/setenvif.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::setenvif { 2 | apache::mod { 'setenvif': } 3 | # Template uses no variables 4 | file { 'setenvif.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/setenvif.conf", 7 | content => template('apache/mod/setenvif.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/ssl.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::ssl ( 2 | $ssl_compression = false, 3 | ) { 4 | $session_cache = $::osfamily ? { 5 | 'debian' => '${APACHE_RUN_DIR}/ssl_scache(512000)', 6 | 'redhat' => '/var/cache/mod_ssl/scache(512000)', 7 | } 8 | $ssl_mutex = $::osfamily ? { 9 | 'debian' => 'file:${APACHE_RUN_DIR}/ssl_mutex', 10 | 'redhat' => 'default', 11 | } 12 | apache::mod { 'ssl': } 13 | 14 | # Template uses $ssl_compression, $session_cache, $ssl_mutex 15 | file { 'ssl.conf': 16 | ensure => file, 17 | path => "${apache::mod_dir}/ssl.conf", 18 | content => template('apache/mod/ssl.conf.erb'), 19 | require => Exec["mkdir ${apache::mod_dir}"], 20 | before => File[$apache::mod_dir], 21 | notify => Service['httpd'], 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/status.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::status { 2 | apache::mod { 'status': } 3 | # Template uses no variables 4 | file { 'status.conf': 5 | ensure => file, 6 | path => "${apache::mod_dir}/status.conf", 7 | content => template('apache/mod/status.conf.erb'), 8 | require => Exec["mkdir ${apache::mod_dir}"], 9 | before => File[$apache::mod_dir], 10 | notify => Service['httpd'], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/userdir.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::userdir ( 2 | $home = '/home', 3 | $dir = 'public_html', 4 | $disable_root = true, 5 | ) { 6 | apache::mod { 'userdir': } 7 | 8 | # Template uses $home, $dir, $disable_root 9 | file { 'userdir.conf': 10 | ensure => file, 11 | path => "${apache::mod_dir}/userdir.conf", 12 | content => template('apache/mod/userdir.conf.erb'), 13 | require => Exec["mkdir ${apache::mod_dir}"], 14 | before => File[$apache::mod_dir], 15 | notify => Service['httpd'], 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/vhost_alias.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::vhost_alias { 2 | apache::mod { 'vhost_alias': } 3 | } 4 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/wsgi.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::wsgi { 2 | apache::mod { 'wsgi': } 3 | } 4 | 5 | -------------------------------------------------------------------------------- /modules/apache/manifests/mod/xsendfile.pp: -------------------------------------------------------------------------------- 1 | class apache::mod::xsendfile { 2 | include apache::params 3 | apache::mod { 'xsendfile': } 4 | } 5 | -------------------------------------------------------------------------------- /modules/apache/manifests/namevirtualhost.pp: -------------------------------------------------------------------------------- 1 | define apache::namevirtualhost { 2 | $addr_port = $name 3 | include apache::params 4 | 5 | # Template uses: $addr_port 6 | concat::fragment { "NameVirtualHost ${addr_port}": 7 | target => $apache::params::ports_file, 8 | content => template('apache/namevirtualhost.erb'), 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /modules/apache/manifests/php.pp: -------------------------------------------------------------------------------- 1 | # Class: apache::php 2 | # 3 | # This class installs PHP for Apache 4 | # 5 | # Parameters: 6 | # - $php_package 7 | # 8 | # Actions: 9 | # - Install Apache PHP package 10 | # 11 | # Requires: 12 | # 13 | # Sample Usage: 14 | # 15 | class apache::php { 16 | warning('apache::php is deprecated; please use apache::mod::php') 17 | include apache::mod::php 18 | } 19 | -------------------------------------------------------------------------------- /modules/apache/manifests/proxy.pp: -------------------------------------------------------------------------------- 1 | # Class: apache::proxy 2 | # 3 | # This class enabled the proxy module for Apache 4 | # 5 | # Actions: 6 | # - Enables Apache Proxy module 7 | # 8 | # Requires: 9 | # 10 | # Sample Usage: 11 | # 12 | class apache::proxy { 13 | warning('apache::proxy is deprecated; please use apache::mod::proxy') 14 | include apache::mod::proxy 15 | } 16 | -------------------------------------------------------------------------------- /modules/apache/manifests/python.pp: -------------------------------------------------------------------------------- 1 | # Class: apache::python 2 | # 3 | # This class installs Python for Apache 4 | # 5 | # Parameters: 6 | # - $php_package 7 | # 8 | # Actions: 9 | # - Install Apache Python package 10 | # 11 | # Requires: 12 | # 13 | # Sample Usage: 14 | # 15 | class apache::python { 16 | warning('apache::python is deprecated; please use apache::mod::python') 17 | include apache::mod::python 18 | } 19 | -------------------------------------------------------------------------------- /modules/apache/manifests/ssl.pp: -------------------------------------------------------------------------------- 1 | # Class: apache::ssl 2 | # 3 | # This class installs Apache SSL capabilities 4 | # 5 | # Parameters: 6 | # - The $ssl_package name from the apache::params class 7 | # 8 | # Actions: 9 | # - Install Apache SSL capabilities 10 | # 11 | # Requires: 12 | # 13 | # Sample Usage: 14 | # 15 | class apache::ssl { 16 | warning('apache::ssl is deprecated; please use apache::mod::ssl') 17 | include apache::mod::ssl 18 | } 19 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/dev_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'apache::dev', :type => :class do 4 | context "on a Debian OS" do 5 | let :facts do 6 | { 7 | :osfamily => 'Debian', 8 | :operatingsystemrelease => '6', 9 | } 10 | end 11 | it { should include_class("apache::params") } 12 | it { should contain_package("libaprutil1-dev") } 13 | it { should contain_package("libapr1-dev") } 14 | it { should contain_package("apache2-prefork-dev") } 15 | end 16 | context "on a RedHat OS" do 17 | let :facts do 18 | { 19 | :osfamily => 'RedHat', 20 | :operatingsystemrelease => '6', 21 | } 22 | end 23 | it { should include_class("apache::params") } 24 | it { should contain_package("httpd-devel") } 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/auth_kerb_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::auth_kerb', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod("auth_kerb") } 15 | it { should contain_package("libapache2-mod-auth-kerb") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod("auth_kerb") } 27 | it { should contain_package("mod_auth_kerb") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/dav_svn_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::dav_svn', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod('dav_svn') } 15 | it { should contain_package("libapache2-svn") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod('dav_svn') } 27 | it { should contain_package("mod_dav_svn") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/dev_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::dev', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should contain_package("libaprutil1-dev") } 14 | it { should contain_package("libapr1-dev") } 15 | it { should contain_package("apache2-prefork-dev") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should contain_package("httpd-devel") } 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/fcgid_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::fcgid', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod('fcgid') } 15 | it { should contain_package("libapache2-mod-fcgid") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod('fcgid') } 27 | it { should contain_package("mod_fcgid") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/passenger_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::passenger', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod('passenger') } 15 | it { should contain_package("libapache2-mod-passenger") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod('passenger') } 27 | it { should contain_package("mod_passenger") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/perl_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::perl', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod('perl') } 15 | it { should contain_package("libapache2-mod-perl2") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod('perl') } 27 | it { should contain_package("mod_perl") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/proxy_html_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::proxy_html', :type => :class do 2 | let :pre_condition do 3 | [ 4 | 'include apache', 5 | 'include apache::mod::proxy', 6 | 'include apache::mod::proxy_http', 7 | ] 8 | end 9 | context "on a Debian OS" do 10 | let :facts do 11 | { 12 | :osfamily => 'Debian', 13 | :operatingsystemrelease => '6', 14 | :concat_basedir => '/dne', 15 | } 16 | end 17 | it { should include_class("apache::params") } 18 | it { should contain_apache__mod('proxy_html') } 19 | it { should contain_package("libapache2-mod-proxy-html") } 20 | end 21 | context "on a RedHat OS" do 22 | let :facts do 23 | { 24 | :osfamily => 'RedHat', 25 | :operatingsystemrelease => '6', 26 | :concat_basedir => '/dne', 27 | } 28 | end 29 | it { should include_class("apache::params") } 30 | it { should contain_apache__mod('proxy_html') } 31 | it { should contain_package("mod_proxy_html") } 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/python_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::python', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod("python") } 15 | it { should contain_package("libapache2-mod-python") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod("python") } 27 | it { should contain_package("mod_python") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/mod/wsgi_spec.rb: -------------------------------------------------------------------------------- 1 | describe 'apache::mod::wsgi', :type => :class do 2 | let :pre_condition do 3 | 'include apache' 4 | end 5 | context "on a Debian OS" do 6 | let :facts do 7 | { 8 | :osfamily => 'Debian', 9 | :operatingsystemrelease => '6', 10 | :concat_basedir => '/dne', 11 | } 12 | end 13 | it { should include_class("apache::params") } 14 | it { should contain_apache__mod('wsgi') } 15 | it { should contain_package("libapache2-mod-wsgi") } 16 | end 17 | context "on a RedHat OS" do 18 | let :facts do 19 | { 20 | :osfamily => 'RedHat', 21 | :operatingsystemrelease => '6', 22 | :concat_basedir => '/dne', 23 | } 24 | end 25 | it { should include_class("apache::params") } 26 | it { should contain_apache__mod('wsgi') } 27 | it { should contain_package("mod_wsgi") } 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/apache/spec/classes/params_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'apache::params', :type => :class do 4 | context "On a Debian OS" do 5 | let :facts do 6 | { 7 | :osfamily => 'Debian', 8 | :operatingsystemrelease => '6', 9 | :concat_basedir => '/dne', 10 | } 11 | end 12 | it { should contain_apache__params } 13 | 14 | # There are 4 resources in this class currently 15 | # there should not be any more resources because it is a params class 16 | # The resources are class[apache::params], class[main], class[settings], stage[main] 17 | it "Should not contain any resources" do 18 | subject.resources.size.should == 4 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /modules/apache/spec/fixtures/modules/site_apache/templates/fake.conf.erb: -------------------------------------------------------------------------------- 1 | Fake template for rspec. 2 | -------------------------------------------------------------------------------- /modules/apache/spec/fixtures/system/distro_commands.yaml: -------------------------------------------------------------------------------- 1 | Debian: 2 | package_check: 3 | command: '/usr/bin/dpkg --get-selections apache2' 4 | stdout: !ruby/regexp '/^apache2\s+install$/' 5 | service_check: 6 | command: '/usr/sbin/service apache2 status' 7 | stdout: '' 8 | RedHat: 9 | package_check: 10 | command: 'rpm -q httpd' 11 | stdout: !ruby/regexp '/httpd/' 12 | service_check: 13 | command: '/sbin/service httpd status' 14 | stdout: '' 15 | 16 | -------------------------------------------------------------------------------- /modules/apache/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --format s 2 | --colour 3 | --loadby mtime 4 | --backtrace 5 | -------------------------------------------------------------------------------- /modules/apache/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/module_spec_helper' 2 | -------------------------------------------------------------------------------- /modules/apache/spec/spec_helper_system.rb: -------------------------------------------------------------------------------- 1 | require 'rspec-system/spec_helper' 2 | require 'rspec-system-puppet/helpers' 3 | require 'rspec-system-serverspec/helpers' 4 | include Serverspec::Helper::RSpecSystem 5 | include Serverspec::Helper::DetectOS 6 | include RSpecSystemPuppet::Helpers 7 | 8 | RSpec.configure do |c| 9 | # Project root 10 | proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 11 | 12 | # Enable colour 13 | c.tty = true 14 | 15 | c.include RSpecSystemPuppet::Helpers 16 | 17 | # This is where we 'setup' the nodes before running our tests 18 | c.before :suite do 19 | # Install puppet 20 | puppet_install 21 | 22 | # Install modules and dependencies 23 | puppet_module_install(:source => proj_root, :module_name => 'apache') 24 | shell('puppet module install ripienaar-concat') 25 | shell('puppet module install puppetlabs-stdlib') 26 | end 27 | end 28 | 29 | -------------------------------------------------------------------------------- /modules/apache/spec/system/basic_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_system' 2 | 3 | describe 'basic tests:' do 4 | # Using puppet_apply as a subject 5 | context puppet_apply 'notice("foo")' do 6 | its(:stdout) { should =~ /foo/ } 7 | its(:stderr) { should be_empty } 8 | its(:exit_code) { should be_zero } 9 | end 10 | end 11 | 12 | describe 'disable selinux:' do 13 | context puppet_apply ' 14 | exec { "setenforce 0": 15 | path => "/bin:/sbin:/usr/bin:/usr/sbin", 16 | onlyif => "which setenforce && getenforce | grep Enforcing", 17 | } 18 | ' do 19 | its(:stderr) { should be_empty } 20 | its(:exit_code) { should_not == 1 } 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /modules/apache/templates/listen.erb: -------------------------------------------------------------------------------- 1 | <%# Listen should always be one of: 2 | - 3 | - : 4 | - [ 5 | -%> 6 | Listen <%= @listen_addr_port %> 7 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/alias.conf.erb: -------------------------------------------------------------------------------- 1 | Alias /icons/ "<%= @icons_path %>/" 2 | "> 3 | Options Indexes MultiViews 4 | AllowOverride None 5 | Order allow,deny 6 | Allow from all 7 | 8 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/cgid.conf.erb: -------------------------------------------------------------------------------- 1 | ScriptSock <%= @cgisock_path %> 2 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/dav_fs.conf.erb: -------------------------------------------------------------------------------- 1 | DAVLockDB <%= @dav_lock %> 2 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/deflate.conf.erb: -------------------------------------------------------------------------------- 1 | AddOutputFilterByType DEFLATE text/html text/plain text/xml 2 | AddOutputFilterByType DEFLATE text/css 3 | AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript 4 | AddOutputFilterByType DEFLATE application/rss+xml 5 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/dir.conf.erb: -------------------------------------------------------------------------------- 1 | DirectoryIndex <%= @indexes.join(' ') %> 2 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/disk_cache.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | CacheEnable disk / 4 | CacheRoot "<%= @cache_root %>" 5 | CacheDirLevels 2 6 | CacheDirLength 1 7 | 8 | 9 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/info.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | SetHandler server-info 3 | Order deny,allow 4 | Deny from all 5 | Allow from <%= Array(@allow_from).join(" ") %> 6 | 7 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/ldap.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | SetHandler ldap-status 3 | Order deny,allow 4 | Deny from all 5 | Allow from 127.0.0.1 ::1 6 | Satisfy all 7 | 8 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/mime.conf.erb: -------------------------------------------------------------------------------- 1 | TypesConfig /etc/mime.types 2 | 3 | AddType application/x-compress .Z 4 | AddType application/x-gzip .gz .tgz 5 | AddType application/x-bzip2 .bz2 6 | 7 | AddLanguage ca .ca 8 | AddLanguage cs .cz .cs 9 | AddLanguage da .dk 10 | AddLanguage de .de 11 | AddLanguage el .el 12 | AddLanguage en .en 13 | AddLanguage eo .eo 14 | AddLanguage es .es 15 | AddLanguage et .et 16 | AddLanguage fr .fr 17 | AddLanguage he .he 18 | AddLanguage hr .hr 19 | AddLanguage it .it 20 | AddLanguage ja .ja 21 | AddLanguage ko .ko 22 | AddLanguage ltz .ltz 23 | AddLanguage nl .nl 24 | AddLanguage nn .nn 25 | AddLanguage no .no 26 | AddLanguage pl .po 27 | AddLanguage pt .pt 28 | AddLanguage pt-BR .pt-br 29 | AddLanguage ru .ru 30 | AddLanguage sv .sv 31 | AddLanguage zh-CN .zh-cn 32 | AddLanguage zh-TW .zh-tw 33 | 34 | AddHandler type-map var 35 | AddType text/html .shtml 36 | AddOutputFilter INCLUDES .shtml 37 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/mime_magic.conf.erb: -------------------------------------------------------------------------------- 1 | MIMEMagicFile conf/magic 2 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/mpm_event.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | StartServers 2 3 | MinSpareThreads 25 4 | MaxSpareThreads 75 5 | ThreadLimit 64 6 | ThreadsPerChild 25 7 | MaxClients 150 8 | MaxRequestsPerChild 0 9 | 10 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/negotiation.conf.erb: -------------------------------------------------------------------------------- 1 | LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW 2 | ForceLanguagePriority Prefer Fallback 3 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/passenger.conf.erb: -------------------------------------------------------------------------------- 1 | PassengerRoot <%= @passenger_root %> 2 | PassengerRuby <%= @passenger_ruby %> 3 | <% if @passenger_max_pool_size -%> 4 | PassengerMaxPoolSize <%= @passenger_max_pool_size %> 5 | <% end -%> 6 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/php5.conf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # PHP is an HTML-embedded scripting language which attempts to make it 3 | # easy for developers to write dynamically generated webpages. 4 | # 5 | # 6 | # LoadModule php5_module modules/libphp5.so 7 | # 8 | # 9 | # # Use of the "ZTS" build with worker is experimental, and no shared 10 | # # modules are supported. 11 | # LoadModule php5_module modules/libphp5-zts.so 12 | # 13 | 14 | # 15 | # Cause the PHP interpreter to handle files with a .php extension. 16 | # 17 | AddHandler php5-script .php 18 | AddType text/html .php 19 | 20 | # 21 | # Add index.php to the list of files that will be served as directory 22 | # indexes. 23 | # 24 | DirectoryIndex index.php 25 | 26 | # 27 | # Uncomment the following line to allow PHP to pretty-print .phps 28 | # files as PHP source code: 29 | # 30 | #AddType application/x-httpd-php-source .phps 31 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/prefork.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | StartServers <%= @startservers %> 3 | MinSpareServers <%= @minspareservers %> 4 | MaxSpareServers <%= @maxspareservers %> 5 | ServerLimit <%= @serverlimit %> 6 | MaxClients <%= @maxclients %> 7 | MaxRequestsPerChild <%= @maxrequestsperchild %> 8 | 9 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/proxy.conf.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Proxy Server directives. Uncomment the following lines to 3 | # enable the proxy server: 4 | # 5 | 6 | # Do not enable proxying with ProxyRequests until you have secured your 7 | # server. Open proxy servers are dangerous both to your network and to the 8 | # Internet at large. 9 | ProxyRequests <%= @proxy_requests %> 10 | 11 | 12 | Order deny,allow 13 | Deny from all 14 | Allow from <%= Array(@allow_from).join(" ") %> 15 | 16 | 17 | # Enable/disable the handling of HTTP/1.1 "Via:" headers. 18 | # ("Full" adds the server version; "Block" removes all outgoing Via: headers) 19 | # Set to one of: Off | On | Full | Block 20 | ProxyVia On 21 | 22 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/proxy_html.conf.erb: -------------------------------------------------------------------------------- 1 | <% if @proxy_html_loadfiles -%> 2 | <% Array(@proxy_html_loadfiles).each do |loadfile| -%> 3 | LoadFile <%= loadfile %> 4 | <% end -%> 5 | 6 | <% end -%> 7 | ProxyHTMLLinks a href 8 | ProxyHTMLLinks area href 9 | ProxyHTMLLinks link href 10 | ProxyHTMLLinks img src longdesc usemap 11 | ProxyHTMLLinks object classid codebase data usemap 12 | ProxyHTMLLinks q cite 13 | ProxyHTMLLinks blockquote cite 14 | ProxyHTMLLinks ins cite 15 | ProxyHTMLLinks del cite 16 | ProxyHTMLLinks form action 17 | ProxyHTMLLinks input src usemap 18 | ProxyHTMLLinks head profileProxyHTMLLinks base href 19 | ProxyHTMLLinks script src for 20 | 21 | ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \ 22 | onmouseover onmousemove onmouseout onkeypress \ 23 | onkeydown onkeyup onfocus onblur onload \ 24 | onunload onsubmit onreset onselect onchange 25 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/reqtimeout.conf.erb: -------------------------------------------------------------------------------- 1 | RequestReadTimeout header=20-40,minrate=500 2 | RequestReadTimeout body=10,minrate=500 3 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/ssl.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | SSLRandomSeed startup builtin 3 | SSLRandomSeed startup file:/dev/urandom 512 4 | SSLRandomSeed connect builtin 5 | SSLRandomSeed connect file:/dev/urandom 512 6 | 7 | AddType application/x-x509-ca-cert .crt 8 | AddType application/x-pkcs7-crl .crl 9 | 10 | SSLPassPhraseDialog builtin 11 | SSLSessionCache shmcb:<%= @session_cache %> 12 | SSLSessionCacheTimeout 300 13 | <% if @ssl_compression -%> 14 | SSLCompression Off 15 | <% end -%> 16 | SSLMutex <%= @ssl_mutex %> 17 | SSLCryptoDevice builtin 18 | SSLHonorCipherOrder On 19 | SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 20 | SSLProtocol all -SSLv2 21 | 22 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/status.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | SetHandler server-status 3 | Order deny,allow 4 | Deny from all 5 | Allow from 127.0.0.1 ::1 6 | 7 | ExtendedStatus On 8 | 9 | 10 | # Show Proxy LoadBalancer status in mod_status 11 | ProxyStatus On 12 | 13 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/userdir.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | <% if @disable_root -%> 3 | UserDir disabled root 4 | <% end -%> 5 | UserDir <%= @dir %> 6 | 7 | /*/<%= @dir %>> 8 | AllowOverride FileInfo AuthConfig Limit Indexes 9 | Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec 10 | 11 | Order allow,deny 12 | Allow from all 13 | 14 | 15 | Order deny,allow 16 | Deny from all 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /modules/apache/templates/mod/worker.conf.erb: -------------------------------------------------------------------------------- 1 | 2 | ServerLimit <%= @serverlimit %> 3 | StartServers <%= @startservers %> 4 | MaxClients <%= @maxclients %> 5 | MinSpareThreads <%= @minsparethreads %> 6 | MaxSpareThreads <%= @maxsparethreads %> 7 | ThreadsPerChild <%= @threadsperchild %> 8 | MaxRequestsPerChild <%= @maxrequestsperchild %> 9 | 10 | -------------------------------------------------------------------------------- /modules/apache/templates/namevirtualhost.erb: -------------------------------------------------------------------------------- 1 | <%# NameVirtualHost should always be one of: 2 | - * 3 | - *: 4 | - _default_: 5 | - 6 | - : 7 | -%> 8 | NameVirtualHost <%= @addr_port %> 9 | -------------------------------------------------------------------------------- /modules/apache/templates/ports_header.erb: -------------------------------------------------------------------------------- 1 | # ************************************ 2 | # Listen & NameVirtualHost resources in module puppetlabs-apache 3 | # Managed by Puppet 4 | # ************************************ 5 | 6 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_aliases.erb: -------------------------------------------------------------------------------- 1 | <% if @aliases and ! @aliases.empty? -%> 2 | ## Alias declarations for resources outside the DocumentRoot 3 | <%- Array(@aliases).each do |alias_statement| -%> 4 | <%- if alias_statement["alias"] != '' and alias_statement["path"] != ''-%> 5 | Alias <%= alias_statement["alias"] %> <%= alias_statement["path"] %> 6 | <%- end -%> 7 | <%- end -%> 8 | <% end -%> -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_block.erb: -------------------------------------------------------------------------------- 1 | <% if @block and ! @block.empty? -%> 2 | 3 | ## Block access statements 4 | <% if @block.include? 'scm' -%> 5 | # Block access to SCM directories. 6 | 7 | Deny From All 8 | 9 | <% end -%> 10 | <% end -%> 11 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_custom_fragment.erb: -------------------------------------------------------------------------------- 1 | <% if @custom_fragment -%> 2 | 3 | ## Custom fragment 4 | <%= @custom_fragment %> 5 | <% end -%> 6 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_proxy.erb: -------------------------------------------------------------------------------- 1 | <% if @proxy_dest or @proxy_pass -%> 2 | 3 | ## Proxy rules 4 | ProxyRequests Off 5 | 6 | Order deny,allow 7 | Allow from all 8 | 9 | <%- end -%> 10 | <% Array(@proxy_pass).each do |proxy| %> 11 | ProxyPass <%= proxy['path'] %> <%= proxy['url'] %> 12 | ProxyPassReverse <%= proxy['path'] %> <%= proxy['url'] %> 13 | <% end %> 14 | <% if @proxy_dest -%> 15 | <% Array(@no_proxy_uris).each do |uri| %> 16 | ProxyPass <%= uri %> ! 17 | <% end %> 18 | ProxyPass / <%= @proxy_dest %>/ 19 | ProxyPassReverse / <%= @proxy_dest %>/ 20 | ProxyPreserveHost On 21 | <% end -%> 22 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_rack.erb: -------------------------------------------------------------------------------- 1 | <% if @rack_base_uris -%> 2 | 3 | ## Enable rack 4 | <% Array(@rack_base_uris).each do |uri| -%> 5 | RackBaseURI <%= uri %> 6 | <% end -%> 7 | <% end -%> 8 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_redirect.erb: -------------------------------------------------------------------------------- 1 | <% if @redirect_source and @redirect_dest -%> 2 | <% @redirect_dest_a = Array(@redirect_dest) -%> 3 | <% @redirect_source_a = Array(@redirect_source) -%> 4 | <% @redirect_status_a = Array(@redirect_status) -%> 5 | 6 | ## Redirect rules 7 | <% @redirect_source_a.each_with_index do |source, i| -%> 8 | <% @redirect_dest_a[i] ||= @redirect_dest_a[0] -%> 9 | <% @redirect_status_a[i] ||= @redirect_status_a[0] -%> 10 | Redirect <%= "#{@redirect_status_a[i]} " %><%= source %> <%= @redirect_dest_a[i] %> 11 | <% end -%> 12 | <% end -%> 13 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_requestheader.erb: -------------------------------------------------------------------------------- 1 | <% if @request_headers and ! @request_headers.empty? -%> 2 | 3 | ## Request header rules 4 | ## as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader 5 | <%- Array(@request_headers).each do |request_statement| -%> 6 | <%- if request_statement != '' -%> 7 | RequestHeader <%= request_statement %> 8 | <%- end -%> 9 | <%- end -%> 10 | <% end -%> 11 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_rewrite.erb: -------------------------------------------------------------------------------- 1 | <% if @rewrite_rule -%> 2 | 3 | ## Rewrite rules 4 | RewriteEngine On 5 | <% if @rewrite_base -%> 6 | RewriteBase <%= @rewrite_base -%> 7 | <% end -%> 8 | <% if @rewrite_cond -%> 9 | <% Array(@rewrite_cond).each do |cond| -%> 10 | RewriteCond <%= cond %> 11 | <% end -%> 12 | <% end -%> 13 | RewriteRule <%= @rewrite_rule %> 14 | <% end -%> 15 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_scriptalias.erb: -------------------------------------------------------------------------------- 1 | <% if @scriptalias -%> 2 | 3 | ## Script alias directives 4 | ScriptAlias /cgi-bin/ "<%= @scriptalias %>/" 5 | "> 6 | AllowOverride None 7 | Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 8 | Order allow,deny 9 | Allow from all 10 | <% if @ssl -%> 11 | SSLOptions +StdEnvVars 12 | <% end -%> 13 | 14 | <% end -%> 15 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_serveralias.erb: -------------------------------------------------------------------------------- 1 | <% if @serveraliases and ! @serveraliases.empty? -%> 2 | 3 | ## Server aliases 4 | <% Array(@serveraliases).each do |serveralias| -%> 5 | ServerAlias <%= serveralias %> 6 | <% end -%> 7 | <% end -%> 8 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_setenv.erb: -------------------------------------------------------------------------------- 1 | <% if @setenv and ! @setenv.empty? -%> 2 | 3 | ## SetEnv/SetEnvIf for environment variables 4 | <% Array(@setenv).each do |envvar| -%> 5 | SetEnv <%= envvar %> 6 | <% end -%> 7 | <% end -%> 8 | <% if @setenvif and ! @setenvif.empty? -%> 9 | <% Array(@setenvif).each do |envifvar| -%> 10 | SetEnvIf <%= envifvar %> 11 | <% end -%> 12 | <% end -%> 13 | -------------------------------------------------------------------------------- /modules/apache/templates/vhost/_ssl.erb: -------------------------------------------------------------------------------- 1 | <% if @ssl -%> 2 | 3 | ## SSL directives 4 | SSLEngine on 5 | SSLCertificateFile <%= @ssl_cert %> 6 | SSLCertificateKeyFile <%= @ssl_key %> 7 | <% if @ssl_chain -%> 8 | SSLCertificateChainFile <%= @ssl_chain %> 9 | <% end -%> 10 | SSLCACertificatePath <%= @ssl_certs_dir %> 11 | <% if @ssl_ca -%> 12 | SSLCACertificateFile <%= @ssl_ca %> 13 | <% end -%> 14 | <% if @ssl_crl_path -%> 15 | SSLCARevocationPath <%= @ssl_crl_path %> 16 | <% end -%> 17 | <% if @ssl_crl -%> 18 | SSLCARevocationFile <%= @ssl_crl %> 19 | <% end -%> 20 | 21 | SSLOptions +StdEnvVars 22 | 23 | <% end -%> 24 | -------------------------------------------------------------------------------- /modules/apache/tests/apache.pp: -------------------------------------------------------------------------------- 1 | include apache 2 | include apache::mod::php 3 | include apache::mod::cgi 4 | include apache::mod::userdir 5 | include apache::mod::disk_cache 6 | include apache::mod::proxy_http 7 | -------------------------------------------------------------------------------- /modules/apache/tests/dev.pp: -------------------------------------------------------------------------------- 1 | include apache::dev 2 | -------------------------------------------------------------------------------- /modules/apache/tests/init.pp: -------------------------------------------------------------------------------- 1 | include apache 2 | -------------------------------------------------------------------------------- /modules/apache/tests/php.pp: -------------------------------------------------------------------------------- 1 | include apache::php 2 | -------------------------------------------------------------------------------- /modules/apache/tests/vhost_ip_based.pp: -------------------------------------------------------------------------------- 1 | ## IP-based vhosts on any listen port 2 | # IP-based vhosts respond to requests on specific IP addresses. 3 | 4 | # Base class. Turn off the default vhosts; we will be declaring 5 | # all vhosts below. 6 | class { 'apache': 7 | default_vhost => false, 8 | } 9 | 10 | # Listen on port 80 and 81; required because the following vhosts 11 | # are not declared with a port parameter. 12 | apache::listen { '80': } 13 | apache::listen { '81': } 14 | 15 | # IP-based vhosts 16 | apache::vhost { 'first.example.com': 17 | ip => '10.0.0.10', 18 | docroot => '/var/www/first', 19 | ip_based => true, 20 | } 21 | apache::vhost { 'second.example.com': 22 | ip => '10.0.0.11', 23 | docroot => '/var/www/second', 24 | ip_based => true, 25 | } 26 | -------------------------------------------------------------------------------- /modules/apache/tests/vhost_ssl.pp: -------------------------------------------------------------------------------- 1 | ## SSL-enabled vhosts 2 | # SSL-enabled vhosts respond only to HTTPS queries. 3 | 4 | # Base class. Turn off the default vhosts; we will be declaring 5 | # all vhosts below. 6 | class { 'apache': 7 | default_vhost => false, 8 | } 9 | 10 | # Non-ssl vhost 11 | apache::vhost { 'first.example.com non-ssl': 12 | servername => 'first.example.com', 13 | port => '80', 14 | docroot => '/var/www/first', 15 | } 16 | 17 | # SSL vhost at the same domain 18 | apache::vhost { 'first.example.com ssl': 19 | servername => 'first.example.com', 20 | port => '443', 21 | docroot => '/var/www/first', 22 | ssl => true, 23 | } 24 | -------------------------------------------------------------------------------- /modules/concat/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 R.I.Pienaar 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /modules/concat/Modulefile: -------------------------------------------------------------------------------- 1 | name 'ripienaar-concat' 2 | version '0.2.0' 3 | source 'git://github.com/ripienaar/puppet-concat.git' 4 | author 'R.I.Pienaar' 5 | license 'Apache' 6 | summary 'Concat module' 7 | description 'Concat module' 8 | project_page 'http://github.com/ripienaar/puppet-concat' 9 | -------------------------------------------------------------------------------- /modules/concat/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | -------------------------------------------------------------------------------- /modules/concat/files/null/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hunner/roles_and_profiles/43017ced23fcc181d66386a2daa5e4da9e40b316/modules/concat/files/null/.gitignore -------------------------------------------------------------------------------- /modules/concat/lib/facter/concat_basedir.rb: -------------------------------------------------------------------------------- 1 | Facter.add("concat_basedir") do 2 | setcode do 3 | File.join(Puppet[:vardir],"concat") 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /modules/concat/spec/fixtures/manifests/site.pp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hunner/roles_and_profiles/43017ced23fcc181d66386a2daa5e4da9e40b316/modules/concat/spec/fixtures/manifests/site.pp -------------------------------------------------------------------------------- /modules/concat/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/module_spec_helper' 2 | -------------------------------------------------------------------------------- /modules/mysql/.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_WITHOUT: development 3 | -------------------------------------------------------------------------------- /modules/mysql/.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib" 4 | symlinks: 5 | "mysql": "#{source_dir}" 6 | -------------------------------------------------------------------------------- /modules/mysql/.forge-release/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | puppetlabs 5 | ghpublisher 6 | 1.0.0-rc1 7 | puppet-module 8 | ghpublisher 9 | 10 | 11 | ${env.PUBLISHER_LOGIN} 12 | ${env.PUBLISHER_PASSWORD} 13 | 14 | 15 | 16 | 17 | 18 | org.cloudsmith.geppetto 19 | forge-maven-plugin 20 | 3.2.0-rc1 21 | true 22 | 23 | false 24 | ${project.build.directory}/forgeCache 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /modules/mysql/.forge-release/publish: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Perform GitHub publish 4 | if [ -z "$PUBLISHER_LOGIN" ] 5 | then 6 | echo "Environment variable PUBLISHER_LOGIN must be set" 7 | exit 1 8 | fi 9 | 10 | if [ -z "$PUBLISHER_PASSWORD" ] 11 | then 12 | echo "Environment variable PUBLISHER_PASSWORD must be set" 13 | exit 1 14 | fi 15 | 16 | MODULES_ROOT=`pwd` 17 | cd $(dirname $0) 18 | mvn -q -s settings.xml -Dforge.modules.root="$MODULES_ROOT" deploy -------------------------------------------------------------------------------- /modules/mysql/.forge-release/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | cloudsmith 5 | 6 | 7 | cloudsmith 8 | https://am0.cloudsmith.com/nexus/content/repositories/releases/ 9 | 10 | true 11 | 12 | 13 | false 14 | 15 | 16 | 17 | 18 | 19 | cloudsmith 20 | https://am0.cloudsmith.com/nexus/content/repositories/releases/ 21 | 22 | true 23 | 24 | 25 | false 26 | 27 | 28 | 29 | 30 | 31 | 32 | cloudsmith 33 | 34 | 35 | -------------------------------------------------------------------------------- /modules/mysql/.forge-release/validate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Perform GitHub publish 4 | MODULES_ROOT=`pwd` 5 | cd $(dirname $0) 6 | mvn -q -s settings.xml -Dforge.modules.root="$MODULES_ROOT" compile -------------------------------------------------------------------------------- /modules/mysql/.nodeset.yml: -------------------------------------------------------------------------------- 1 | --- 2 | default_set: 'centos-64-x64' 3 | sets: 4 | 'centos-59-x64': 5 | nodes: 6 | "main.foo.vm": 7 | prefab: 'centos-59-x64' 8 | 'centos-64-x64': 9 | nodes: 10 | "main.foo.vm": 11 | prefab: 'centos-64-x64' 12 | 'fedora-18-x64': 13 | nodes: 14 | "main.foo.vm": 15 | prefab: 'fedora-18-x64' 16 | 'debian-607-x64': 17 | nodes: 18 | "main.foo.vm": 19 | prefab: 'debian-607-x64' 20 | 'debian-70rc1-x64': 21 | nodes: 22 | "main.foo.vm": 23 | prefab: 'debian-70rc1-x64' 24 | 'ubuntu-server-10044-x64': 25 | nodes: 26 | "main.foo.vm": 27 | prefab: 'ubuntu-server-10044-x64' 28 | 'ubuntu-server-12042-x64': 29 | nodes: 30 | "main.foo.vm": 31 | prefab: 'ubuntu-server-12042-x64' 32 | -------------------------------------------------------------------------------- /modules/mysql/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | group :development, :test do 4 | gem 'rake', :require => false 5 | gem 'rspec-puppet', :require => false 6 | gem 'puppetlabs_spec_helper', :require => false 7 | gem 'rspec-system', :require => false 8 | gem 'rspec-system-puppet', :require => false 9 | gem 'rspec-system-serverspec', :require => false 10 | gem 'serverspec', :require => false 11 | gem 'puppet-lint', :require => false 12 | end 13 | 14 | if puppetversion = ENV['PUPPET_GEM_VERSION'] 15 | gem 'puppet', puppetversion, :require => false 16 | else 17 | gem 'puppet', :require => false 18 | end 19 | 20 | # vim:ft=ruby 21 | -------------------------------------------------------------------------------- /modules/mysql/Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppetlabs-mysql' 2 | version '0.9.0' 3 | source 'git://github.com/puppetlabs/puppetlabs-mysql.git' 4 | author 'Puppet Labs' 5 | license 'Apache 2.0' 6 | summary 'Mysql module' 7 | description 'Mysql module' 8 | project_page 'http://github.com/puppetlabs/puppetlabs-mysql' 9 | dependency 'puppetlabs/stdlib', '>= 2.2.1' 10 | -------------------------------------------------------------------------------- /modules/mysql/Rakefile: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/rake_tasks' 2 | require 'rspec-system/rake_task' 3 | -------------------------------------------------------------------------------- /modules/mysql/TODO: -------------------------------------------------------------------------------- 1 | The best that I can tell is that this code traces back to David Schmitt. It has been forked many times since then :) 2 | 3 | 1. you cannot add databases to an instance that has a root password 4 | 2. you have to specify username as USER@BLAH or it cannot be found 5 | 3. mysql_grant does not complain if user does not exist 6 | 4. Needs support for pre-seeding on debian 7 | 5. the types may need to take user/password 8 | 6. rather or not to configure /etc/.my.cnf should be configurable 9 | -------------------------------------------------------------------------------- /modules/mysql/lib/puppet/parser/functions/mysql_password.rb: -------------------------------------------------------------------------------- 1 | # hash a string as mysql's "PASSWORD()" function would do it 2 | require 'digest/sha1' 3 | 4 | module Puppet::Parser::Functions 5 | newfunction(:mysql_password, :type => :rvalue, :doc => <<-EOS 6 | Returns the mysql password hash from the clear text password. 7 | EOS 8 | ) do |args| 9 | 10 | raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' + 11 | "given (#{args.size} for 1)") if args.size != 1 12 | 13 | '*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /modules/mysql/lib/puppet/type/database.rb: -------------------------------------------------------------------------------- 1 | # This has to be a separate type to enable collecting 2 | Puppet::Type.newtype(:database) do 3 | @doc = 'Manage databases.' 4 | 5 | ensurable 6 | 7 | newparam(:name, :namevar=>true) do 8 | desc 'The name of the database.' 9 | end 10 | 11 | newproperty(:charset) do 12 | desc 'The characterset to use for a database' 13 | defaultto :utf8 14 | newvalue(/^\S+$/) 15 | end 16 | 17 | end 18 | -------------------------------------------------------------------------------- /modules/mysql/manifests/java.pp: -------------------------------------------------------------------------------- 1 | # Class: mysql::java 2 | # 3 | # This class installs the mysql-java-connector. 4 | # 5 | # Parameters: 6 | # [*package_name*] - The name of the mysql java package. 7 | # [*package_ensure*] - Ensure state for package. Can be specified as version. 8 | # Actions: 9 | # 10 | # Requires: 11 | # 12 | # Sample Usage: 13 | # 14 | class mysql::java ( 15 | $package_ensure = 'present', 16 | $package_name = $mysql::java_package_name 17 | ) inherits mysql { 18 | 19 | package { 'mysql-connector-java': 20 | ensure => $package_ensure, 21 | name => $package_name, 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /modules/mysql/manifests/perl.pp: -------------------------------------------------------------------------------- 1 | # Class: mysql::perl 2 | # 3 | # installs the perl bindings for mysql 4 | # 5 | # Parameters: 6 | # [*package_ensure*] - Ensure state for package. Can be specified as version. 7 | # [*package_name*] - name of package 8 | # [*package_provider*] - The provider to use to install the package 9 | # 10 | # Actions: 11 | # 12 | # Requires: 13 | # 14 | # Sample Usage: 15 | # 16 | class mysql::perl ( 17 | $package_ensure = 'present', 18 | $package_name = $mysql::perl_package_name, 19 | $package_provider = $mysql::perl_package_provider 20 | ) inherits mysql { 21 | 22 | package{ 'perl_mysql': 23 | ensure => $package_ensure, 24 | name => $package_name, 25 | provider => $package_provider, 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /modules/mysql/manifests/php.pp: -------------------------------------------------------------------------------- 1 | # Class: mysql::php 2 | # 3 | # This class installs the php libs for mysql. 4 | # 5 | # Parameters: 6 | # [*package_ensure*] - Ensure state for package. Can be specified as version. 7 | # [*package_name*] - The name of package 8 | # 9 | class mysql::php( 10 | $package_ensure = 'present', 11 | $package_name = $mysql::php_package_name 12 | ) inherits mysql { 13 | 14 | package { 'php-mysql': 15 | ensure => $package_ensure, 16 | name => $package_name, 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /modules/mysql/manifests/python.pp: -------------------------------------------------------------------------------- 1 | # Class: mysql::python 2 | # 3 | # This class installs the python libs for mysql. 4 | # 5 | # Parameters: 6 | # [*package_ensure*] - Ensure state for package. Can be specified as version. 7 | # [*package_name*] - Name of package 8 | # 9 | # Actions: 10 | # 11 | # Requires: 12 | # 13 | # Sample Usage: 14 | # 15 | class mysql::python( 16 | $package_ensure = 'present', 17 | $package_name = $mysql::python_package_name 18 | ) inherits mysql { 19 | 20 | package { 'python-mysqldb': 21 | ensure => $package_ensure, 22 | name => $package_name, 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /modules/mysql/manifests/ruby.pp: -------------------------------------------------------------------------------- 1 | # Class: mysql::ruby 2 | # 3 | # installs the ruby bindings for mysql 4 | # 5 | # Parameters: 6 | # [*package_ensure*] - Ensure state for package. Can be specified as version. 7 | # [*package_name*] - name of package 8 | # [*package_provider*] - The provider to use to install the package 9 | # 10 | # Actions: 11 | # 12 | # Requires: 13 | # 14 | # Sample Usage: 15 | # 16 | class mysql::ruby ( 17 | $package_ensure = 'present', 18 | $package_name = $mysql::ruby_package_name, 19 | $package_provider = $mysql::ruby_package_provider 20 | ) inherits mysql { 21 | 22 | package{ 'ruby_mysql': 23 | ensure => $package_ensure, 24 | name => $package_name, 25 | provider => $package_provider, 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /modules/mysql/manifests/server/account_security.pp: -------------------------------------------------------------------------------- 1 | # Some installations have some default users which are not required. 2 | # We remove them here. You can subclass this class to overwrite this behavior. 3 | class mysql::server::account_security { 4 | database_user { 5 | [ "root@${::fqdn}", 6 | 'root@127.0.0.1', 7 | 'root@::1', 8 | "@${::fqdn}", 9 | '@localhost', 10 | '@%']: 11 | ensure => 'absent', 12 | require => Class['mysql::config'], 13 | } 14 | if ($::fqdn != $::hostname) { 15 | database_user { ["root@${::hostname}", "@${::hostname}"]: 16 | ensure => 'absent', 17 | require => Class['mysql::config'], 18 | } 19 | } 20 | database { 'test': 21 | ensure => 'absent', 22 | require => Class['mysql::config'], 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /modules/mysql/manifests/server/monitor.pp: -------------------------------------------------------------------------------- 1 | #This is a helper class to add a monitoring user to the database 2 | # 3 | class mysql::server::monitor ( 4 | $mysql_monitor_username, 5 | $mysql_monitor_password, 6 | $mysql_monitor_hostname 7 | ) { 8 | 9 | Class['mysql::server'] -> Class['mysql::server::monitor'] 10 | 11 | database_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}": 12 | ensure => present, 13 | password_hash => mysql_password($mysql_monitor_password), 14 | } 15 | 16 | database_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}": 17 | privileges => [ 'process_priv', 'super_priv' ], 18 | require => Database_user["${mysql_monitor_username}@${mysql_monitor_hostname}"], 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /modules/mysql/manifests/server/mysqltuner.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2009 Larry Ludwig (larrylud@gmail.com) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 | # use this file except in compliance with the License. You may obtain a copy of 5 | # the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations under 13 | # the License. 14 | # 15 | class mysql::server::mysqltuner { 16 | # mysql performance tester 17 | file { '/usr/bin/mysqltuner': 18 | ensure => present, 19 | mode => '0550', 20 | source => 'puppet:///modules/mysql/mysqltuner.pl', 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /modules/mysql/spec/classes/mysql_server_monitor_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | describe 'mysql::server::monitor' do 3 | let :facts do 4 | { :osfamily => 'Debian', :root_home => '/root' } 5 | end 6 | let :pre_condition do 7 | "include 'mysql::server'" 8 | end 9 | let :params do 10 | { 11 | :mysql_monitor_username => 'monitoruser', 12 | :mysql_monitor_password => 'monitorpass', 13 | :mysql_monitor_hostname => 'monitorhost' 14 | } 15 | end 16 | 17 | it { should contain_database_user('monitoruser@monitorhost')} 18 | end 19 | -------------------------------------------------------------------------------- /modules/mysql/spec/defines/mysql_server_config_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'mysql::server::config', :type => :define do 4 | filename = '/etc/mysql/conf.d/test_config.cnf' 5 | 6 | let :facts do 7 | { :osfamily => 'Debian', :root_home => '/root'} 8 | end 9 | 10 | let(:title) { File.basename(filename, '.cnf') } 11 | 12 | let(:params) { 13 | { 'settings' => { 14 | 'mysqld' => { 15 | 'bind-address' => '0.0.0.0' 16 | } 17 | } 18 | } 19 | } 20 | 21 | it 'should notify the mysql daemon' do 22 | should contain_file(filename).with_notify('Exec[mysqld-restart]') 23 | end 24 | 25 | it 'should contain config parameter in content' do 26 | should contain_file(filename).with_content("### MANAGED BY PUPPET ###\n[mysqld]\nbind-address = 0.0.0.0\n\n") 27 | end 28 | 29 | it 'should not notify the mysql daemon' do 30 | params.merge!({ 'notify_service' => false }) 31 | should contain_file(filename).without_notify 32 | end 33 | 34 | it 'should require on the mysql-server package' do 35 | should contain_file(filename).with_require('Package[mysql-server]') 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /modules/mysql/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --format 2 | s 3 | --colour 4 | --loadby 5 | mtime 6 | --backtrace 7 | -------------------------------------------------------------------------------- /modules/mysql/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/module_spec_helper' 2 | -------------------------------------------------------------------------------- /modules/mysql/spec/spec_helper_system.rb: -------------------------------------------------------------------------------- 1 | require 'rspec-system/spec_helper' 2 | require 'rspec-system-puppet/helpers' 3 | require 'rspec-system-serverspec/helpers' 4 | 5 | include RSpecSystemPuppet::Helpers 6 | 7 | include Serverspec::Helper::RSpecSystem 8 | include Serverspec::Helper::DetectOS 9 | 10 | RSpec.configure do |c| 11 | # Project root 12 | proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 13 | 14 | # Enable colour 15 | c.tty = true 16 | 17 | c.include RSpecSystemPuppet::Helpers 18 | 19 | # This is where we 'setup' the nodes before running our tests 20 | c.before :suite do 21 | # Install puppet 22 | puppet_install 23 | 24 | # Install modules and dependencies 25 | puppet_module_install(:source => proj_root, :module_name => 'mysql') 26 | shell('puppet module install puppetlabs-stdlib') 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /modules/mysql/spec/system/mysql_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_system' 2 | 3 | describe 'mysql class' do 4 | describe 'running puppet code' do 5 | # Using puppet_apply as a helper 6 | it 'should work with no errors' do 7 | pp = <<-EOS 8 | class { 'mysql': } 9 | EOS 10 | 11 | # Run it twice and test for idempotency 12 | puppet_apply(pp) do |r| 13 | r.exit_code.should_not == 1 14 | r.refresh 15 | r.exit_code.should be_zero 16 | end 17 | end 18 | end 19 | 20 | describe package('mysql') do 21 | it { should be_installed } 22 | end 23 | 24 | describe service('mysql') do 25 | it { should_not be_running } 26 | it { should_not be_enabled } 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /modules/mysql/templates/my.cnf.pass.erb: -------------------------------------------------------------------------------- 1 | [client] 2 | user=root 3 | host=localhost 4 | <% unless @root_password == 'UNSET' -%> 5 | password='<%= @root_password %>' 6 | <% end -%> 7 | -------------------------------------------------------------------------------- /modules/mysql/templates/my.conf.cnf.erb: -------------------------------------------------------------------------------- 1 | ### MANAGED BY PUPPET ### 2 | <% @settings.sort.each do |section, content| -%> 3 | [<%= section %>] 4 | <% content.sort.each do |key, values| -%> 5 | <% [values].flatten.sort.each do |value| -%> 6 | <%= !value ? '#' : '' %><%= key -%><%= 7 | case value 8 | when true, false 9 | '' 10 | else 11 | " = #{value}" 12 | end 13 | %> 14 | <% end -%> 15 | <% end -%> 16 | 17 | <% end -%> 18 | -------------------------------------------------------------------------------- /modules/mysql/tests/backup.pp: -------------------------------------------------------------------------------- 1 | class { 'mysql::server': 2 | config_hash => {'root_password' => 'password'} 3 | } 4 | class { 'mysql::backup': 5 | backupuser => 'myuser', 6 | backuppassword => 'mypassword', 7 | backupdir => '/tmp/backups', 8 | } 9 | -------------------------------------------------------------------------------- /modules/mysql/tests/init.pp: -------------------------------------------------------------------------------- 1 | include mysql 2 | -------------------------------------------------------------------------------- /modules/mysql/tests/java.pp: -------------------------------------------------------------------------------- 1 | class { 'mysql::java':} 2 | -------------------------------------------------------------------------------- /modules/mysql/tests/mysql_database.pp: -------------------------------------------------------------------------------- 1 | class { 'mysql::server': 2 | config_hash => {'root_password' => 'password'} 3 | } 4 | database{ ['test1', 'test2', 'test3']: 5 | ensure => present, 6 | charset => 'utf8', 7 | require => Class['mysql::server'], 8 | } 9 | database{ 'test4': 10 | ensure => present, 11 | charset => 'latin1', 12 | } 13 | -------------------------------------------------------------------------------- /modules/mysql/tests/mysql_grant.pp: -------------------------------------------------------------------------------- 1 | database_grant{'test1@localhost/redmine': 2 | privileges => [update], 3 | } 4 | -------------------------------------------------------------------------------- /modules/mysql/tests/mysql_user.pp: -------------------------------------------------------------------------------- 1 | $mysql_root_pw = 'password' 2 | 3 | class { 'mysql::server': 4 | config_hash => { 5 | root_password => 'password', 6 | } 7 | } 8 | 9 | database_user{ 'redmine@localhost': 10 | ensure => present, 11 | password_hash => mysql_password('redmine'), 12 | require => Class['mysql::server'], 13 | } 14 | 15 | database_user{ 'dan@localhost': 16 | ensure => present, 17 | password_hash => mysql_password('blah') 18 | } 19 | 20 | database_user{ 'dan@%': 21 | ensure => present, 22 | password_hash => mysql_password('blah'), 23 | } 24 | -------------------------------------------------------------------------------- /modules/mysql/tests/perl.pp: -------------------------------------------------------------------------------- 1 | include mysql::perl 2 | -------------------------------------------------------------------------------- /modules/mysql/tests/python.pp: -------------------------------------------------------------------------------- 1 | class { 'mysql::python':} 2 | -------------------------------------------------------------------------------- /modules/mysql/tests/ruby.pp: -------------------------------------------------------------------------------- 1 | include mysql::ruby 2 | -------------------------------------------------------------------------------- /modules/mysql/tests/server.pp: -------------------------------------------------------------------------------- 1 | class { 'mysql::server': 2 | config_hash => { 'root_password' => 'password', }, 3 | } 4 | -------------------------------------------------------------------------------- /modules/mysql/tests/server/account_security.pp: -------------------------------------------------------------------------------- 1 | class { 'mysql::server': 2 | config_hash => { 'root_password' => 'password', }, 3 | } 4 | class { 'mysql::server::account_security': } 5 | -------------------------------------------------------------------------------- /modules/mysql/tests/server/config.pp: -------------------------------------------------------------------------------- 1 | mysql::server::config { 'testfile': 2 | settings => { 3 | 'mysqld' => { 4 | 'bind-address' => '0.0.0.0', 5 | 'read-only' => true, 6 | }, 7 | 'client' => { 8 | 'port' => '3306' 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /modules/profile/manifests/base.pp: -------------------------------------------------------------------------------- 1 | class profile::base { 2 | } 3 | -------------------------------------------------------------------------------- /modules/profile/manifests/db.pp: -------------------------------------------------------------------------------- 1 | class profile::db { 2 | class { 'mysql::server': 3 | config_hash => { 'root_password' => '8ZcJZFHsvo7fINZcAvi0' } 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /modules/profile/manifests/db/php.pp: -------------------------------------------------------------------------------- 1 | class profile::db::php { 2 | include mysql::php 3 | } 4 | -------------------------------------------------------------------------------- /modules/profile/manifests/ftp.pp: -------------------------------------------------------------------------------- 1 | class profile::ftp { 2 | include vsftpd 3 | } 4 | -------------------------------------------------------------------------------- /modules/profile/manifests/web.pp: -------------------------------------------------------------------------------- 1 | class profile::web { 2 | ## Configure apache 3 | class { 'apache': 4 | mpm_module => 'prefork', 5 | } 6 | include apache::mod::php 7 | #$vhosts = hiera_hash('apache::vhosts') 8 | #create_resources('apache::vhost', $vhosts) 9 | } 10 | -------------------------------------------------------------------------------- /modules/profile/manifests/wordpress.pp: -------------------------------------------------------------------------------- 1 | class profile::wordpress { 2 | include profile::web 3 | ## Create user 4 | group { 'wordpress': 5 | ensure => present, 6 | } 7 | user { 'wordpress': 8 | ensure => present, 9 | gid => 'wordpress', 10 | password => '$1$jrm5tnjw$h8JJ9mCZLmJvIxvDLjw1M/', #puppet 11 | home => '/var/www/site/blog', 12 | } 13 | ## Configure wordpress 14 | class { '::wordpress': 15 | install_dir => '/var/www/site/blog', 16 | db_name => 'wordpress', 17 | db_host => 'localhost', 18 | db_user => 'wordpress', 19 | db_password => 'wordpress', 20 | wp_owner => 'wordpress', 21 | wp_group => 'wordpress', 22 | } 23 | ## Configure vhost for wordpress 24 | apache::vhost { $::fqdn: 25 | port => '80', 26 | docroot => '/var/www/site', 27 | default_vhost => true, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /modules/role/manifests/init.pp: -------------------------------------------------------------------------------- 1 | class role { 2 | include profile::base 3 | } 4 | -------------------------------------------------------------------------------- /modules/role/manifests/wordpress.pp: -------------------------------------------------------------------------------- 1 | class role::wordpress inherits role { 2 | include profile::db 3 | include profile::db::php 4 | include profile::wordpress 5 | } 6 | -------------------------------------------------------------------------------- /modules/stdlib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 Puppet Labs Inc 2 | 3 | and some parts: 4 | 5 | Copyright (C) 2011 Krzysztof Wilczynski 6 | 7 | Puppet Labs can be contacted at: info@puppetlabs.com 8 | 9 | Licensed under the Apache License, Version 2.0 (the "License"); 10 | you may not use this file except in compliance with the License. 11 | You may obtain a copy of the License at 12 | 13 | http://www.apache.org/licenses/LICENSE-2.0 14 | 15 | Unless required by applicable law or agreed to in writing, software 16 | distributed under the License is distributed on an "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | See the License for the specific language governing permissions and 19 | limitations under the License. 20 | -------------------------------------------------------------------------------- /modules/stdlib/Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppetlabs-stdlib' 2 | version '4.1.0' 3 | source 'git://github.com/puppetlabs/puppetlabs-stdlib.git' 4 | author 'puppetlabs' 5 | license 'Apache 2.0' 6 | summary 'Puppet Module Standard Library' 7 | description 'Standard Library for Puppet Modules' 8 | project_page 'https://github.com/puppetlabs/puppetlabs-stdlib' 9 | 10 | ## Add dependencies, if any: 11 | # dependency 'username/name', '>= 1.2.0' 12 | -------------------------------------------------------------------------------- /modules/stdlib/README_SPECS.markdown: -------------------------------------------------------------------------------- 1 | NOTE 2 | ==== 3 | 4 | This project's specs depend on puppet core, and thus they require the 5 | `puppetlabs_spec_helper` project. For more information please see the README 6 | in that project, which can be found here: [puppetlabs spec 7 | helper](https://github.com/puppetlabs/puppetlabs_spec_helper) 8 | -------------------------------------------------------------------------------- /modules/stdlib/RELEASE_PROCESS.markdown: -------------------------------------------------------------------------------- 1 | # Contributing to this module # 2 | 3 | * Work in a topic branch 4 | * Submit a github pull request 5 | * Address any comments / feeback 6 | * Merge into master using --no-ff 7 | 8 | # Releasing this module # 9 | 10 | * This module adheres to http://semver.org/ 11 | * Look for API breaking changes using git diff vX.Y.Z..master 12 | * If no API breaking changes, the minor version may be bumped. 13 | * If there are API breaking changes, the major version must be bumped. 14 | * If there are only small minor changes, the patch version may be bumped. 15 | * Update the CHANGELOG 16 | * Update the Modulefile 17 | * Commit these changes with a message along the lines of "Update CHANGELOG and 18 | Modulefile for release" 19 | * Create an annotated tag with git tag -a vX.Y.Z -m 'version X.Y.Z' (NOTE the 20 | leading v as per semver.org) 21 | * Push the tag with git push origin --tags 22 | * Build a new package with puppet-module or the rake build task if it exists 23 | * Publish the new package to the forge 24 | * Bonus points for an announcement to puppet-users. 25 | -------------------------------------------------------------------------------- /modules/stdlib/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | -------------------------------------------------------------------------------- /modules/stdlib/lib/facter/puppet_vardir.rb: -------------------------------------------------------------------------------- 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 27 | -------------------------------------------------------------------------------- /modules/stdlib/lib/facter/root_home.rb: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /modules/stdlib/lib/facter/util/puppet_settings.rb: -------------------------------------------------------------------------------- 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 22 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/abs.rb: -------------------------------------------------------------------------------- 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 : 37 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/any2array.rb: -------------------------------------------------------------------------------- 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 : 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/capitalize.rb: -------------------------------------------------------------------------------- 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 : 35 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/chomp.rb: -------------------------------------------------------------------------------- 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 : 36 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/concat.rb: -------------------------------------------------------------------------------- 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 both args are arrays. 27 | unless a.is_a?(Array) and b.is_a?(Array) 28 | raise(Puppet::ParseError, 'concat(): Requires array to work with') 29 | end 30 | 31 | result = a.concat(b) 32 | 33 | return result 34 | end 35 | end 36 | 37 | # vim: set ts=2 sw=2 et : 38 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/count.rb: -------------------------------------------------------------------------------- 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 23 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/dirname.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:dirname, :type => :rvalue, :doc => <<-EOS 3 | Returns the dirname of a path. 4 | EOS 5 | ) do |arguments| 6 | 7 | raise(Puppet::ParseError, "dirname(): Wrong number of arguments " + 8 | "given (#{arguments.size} for 1)") if arguments.size < 1 9 | 10 | path = arguments[0] 11 | return File.dirname(path) 12 | end 13 | end 14 | 15 | # vim: set ts=2 sw=2 et : 16 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/downcase.rb: -------------------------------------------------------------------------------- 1 | # 2 | # downcase.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:downcase, :type => :rvalue, :doc => <<-EOS 7 | Converts the case of a string or all strings in an array to lower case. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "downcase(): 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, 'downcase(): 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.downcase : i } 25 | else 26 | result = value.downcase 27 | end 28 | 29 | return result 30 | end 31 | end 32 | 33 | # vim: set ts=2 sw=2 et : 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/empty.rb: -------------------------------------------------------------------------------- 1 | # 2 | # empty.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:empty, :type => :rvalue, :doc => <<-EOS 7 | Returns true if the variable is empty. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "empty(): 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, Hash, String].include?(klass) 18 | raise(Puppet::ParseError, 'empty(): Requires either ' + 19 | 'array, hash or string to work with') 20 | end 21 | 22 | result = value.empty? 23 | 24 | return result 25 | end 26 | end 27 | 28 | # vim: set ts=2 sw=2 et : 29 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb: -------------------------------------------------------------------------------- 1 | # 2 | # ensure_packages.rb 3 | # 4 | require 'puppet/parser/functions' 5 | 6 | module Puppet::Parser::Functions 7 | newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS 8 | Takes a list of packages and only installs them if they don't already exist. 9 | EOS 10 | ) do |arguments| 11 | 12 | raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " + 13 | "given (#{arguments.size} for 1)") if arguments.size != 1 14 | raise(Puppet::ParseError, "ensure_packages(): Requires array " + 15 | "given (#{arguments[0].class})") if !arguments[0].kind_of?(Array) 16 | 17 | Puppet::Parser::Functions.function(:ensure_resource) 18 | arguments[0].each { |package_name| 19 | function_ensure_resource(['package', package_name, {'ensure' => 'present' } ]) 20 | } 21 | end 22 | end 23 | 24 | # vim: set ts=2 sw=2 et : 25 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/flatten.rb: -------------------------------------------------------------------------------- 1 | # 2 | # flatten.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:flatten, :type => :rvalue, :doc => <<-EOS 7 | This function flattens any deeply nested arrays and returns a single flat array 8 | as a result. 9 | 10 | *Examples:* 11 | 12 | flatten(['a', ['b', ['c']]]) 13 | 14 | Would return: ['a','b','c'] 15 | EOS 16 | ) do |arguments| 17 | 18 | raise(Puppet::ParseError, "flatten(): 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, 'flatten(): Requires array to work with') 25 | end 26 | 27 | result = array.flatten 28 | 29 | return result 30 | end 31 | end 32 | 33 | # vim: set ts=2 sw=2 et : 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/floor.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:floor, :type => :rvalue, :doc => <<-EOS 3 | Returns the largest integer less or equal to the argument. 4 | Takes a single numeric value as an argument. 5 | EOS 6 | ) do |arguments| 7 | 8 | raise(Puppet::ParseError, "floor(): Wrong number of arguments " + 9 | "given (#{arguments.size} for 1)") if arguments.size != 1 10 | 11 | arg = arguments[0] 12 | 13 | raise(Puppet::ParseError, "floor(): Wrong argument type " + 14 | "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false 15 | 16 | arg.floor 17 | end 18 | end 19 | 20 | # vim: set ts=2 sw=2 et : 21 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/get_module_path.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT 3 | Returns the absolute path of the specified module for the current 4 | environment. 5 | 6 | Example: 7 | $module_path = get_module_path('stdlib') 8 | EOT 9 | ) do |args| 10 | raise(Puppet::ParseError, "get_module_path(): Wrong number of arguments, expects one") unless args.size == 1 11 | if module_path = Puppet::Module.find(args[0], compiler.environment.to_s) 12 | module_path.path 13 | else 14 | raise(Puppet::ParseError, "Could not find module #{args[0]} in environment #{compiler.environment}") 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/getparam.rb: -------------------------------------------------------------------------------- 1 | # Test whether a given class or definition is defined 2 | require 'puppet/parser/functions' 3 | 4 | Puppet::Parser::Functions.newfunction(:getparam, 5 | :type => :rvalue, 6 | :doc => <<-'ENDOFDOC' 7 | Takes a resource reference and name of the parameter and 8 | returns value of resource's parameter. 9 | 10 | *Examples:* 11 | 12 | define example_resource($param) { 13 | } 14 | 15 | example_resource { "example_resource_instance": 16 | param => "param_value" 17 | } 18 | 19 | getparam(Example_resource["example_resource_instance"], "param") 20 | 21 | Would return: param_value 22 | ENDOFDOC 23 | ) do |vals| 24 | reference, param = vals 25 | raise(ArgumentError, 'Must specify a reference') unless reference 26 | raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String 27 | 28 | return '' if param.empty? 29 | 30 | if resource = findresource(reference.to_s) 31 | return resource[param] if resource[param] 32 | end 33 | 34 | return '' 35 | end 36 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/getvar.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | 3 | newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| 4 | Lookup a variable in a remote namespace. 5 | 6 | For example: 7 | 8 | $foo = getvar('site::data::foo') 9 | # Equivalent to $foo = $site::data::foo 10 | 11 | This is useful if the namespace itself is stored in a string: 12 | 13 | $datalocation = 'site::data' 14 | $bar = getvar("${datalocation}::bar") 15 | # Equivalent to $bar = $site::data::bar 16 | ENDHEREDOC 17 | 18 | unless args.length == 1 19 | raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)") 20 | end 21 | 22 | self.lookupvar("#{args[0]}") 23 | 24 | end 25 | 26 | end 27 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/grep.rb: -------------------------------------------------------------------------------- 1 | # 2 | # grep.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:grep, :type => :rvalue, :doc => <<-EOS 7 | This function searches through an array and returns any elements that match 8 | the provided regular expression. 9 | 10 | *Examples:* 11 | 12 | grep(['aaa','bbb','ccc','aaaddd'], 'aaa') 13 | 14 | Would return: 15 | 16 | ['aaa','aaaddd'] 17 | EOS 18 | ) do |arguments| 19 | 20 | if (arguments.size != 2) then 21 | raise(Puppet::ParseError, "grep(): Wrong number of arguments "+ 22 | "given #{arguments.size} for 2") 23 | end 24 | 25 | a = arguments[0] 26 | pattern = Regexp.new(arguments[1]) 27 | 28 | a.grep(pattern) 29 | 30 | end 31 | end 32 | 33 | # vim: set ts=2 sw=2 et : 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb: -------------------------------------------------------------------------------- 1 | # 2 | # has_ip_address 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS 7 | Returns true if the client has the requested IP address on some interface. 8 | 9 | This function iterates through the 'interfaces' fact and checks the 10 | 'ipaddress_IFACE' facts, performing a simple string comparison. 11 | EOS 12 | ) do |args| 13 | 14 | raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments " + 15 | "given (#{args.size} for 1)") if args.size != 1 16 | 17 | Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ 18 | unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) 19 | 20 | function_has_interface_with(['ipaddress', args[0]]) 21 | 22 | end 23 | end 24 | 25 | # vim:sts=2 sw=2 26 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb: -------------------------------------------------------------------------------- 1 | # 2 | # has_ip_network 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS 7 | Returns true if the client has an IP address within the requested network. 8 | 9 | This function iterates through the 'interfaces' fact and checks the 10 | 'network_IFACE' facts, performing a simple string comparision. 11 | EOS 12 | ) do |args| 13 | 14 | raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments " + 15 | "given (#{args.size} for 1)") if args.size != 1 16 | 17 | Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ 18 | unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) 19 | 20 | function_has_interface_with(['network', args[0]]) 21 | 22 | end 23 | end 24 | 25 | # vim:sts=2 sw=2 26 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/has_key.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | 3 | newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| 4 | Determine if a hash has a certain key value. 5 | 6 | Example: 7 | 8 | $my_hash = {'key_one' => 'value_one'} 9 | if has_key($my_hash, 'key_two') { 10 | notice('we will not reach here') 11 | } 12 | if has_key($my_hash, 'key_one') { 13 | notice('this will be printed') 14 | } 15 | 16 | ENDHEREDOC 17 | 18 | unless args.length == 2 19 | raise Puppet::ParseError, ("has_key(): wrong number of arguments (#{args.length}; must be 2)") 20 | end 21 | unless args[0].is_a?(Hash) 22 | raise Puppet::ParseError, "has_key(): expects the first argument to be a hash, got #{args[0].inspect} which is of type #{args[0].class}" 23 | end 24 | args[0].has_key?(args[1]) 25 | 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/hash.rb: -------------------------------------------------------------------------------- 1 | # 2 | # hash.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:hash, :type => :rvalue, :doc => <<-EOS 7 | This function converts an array into a hash. 8 | 9 | *Examples:* 10 | 11 | hash(['a',1,'b',2,'c',3]) 12 | 13 | Would return: {'a'=>1,'b'=>2,'c'=>3} 14 | EOS 15 | ) do |arguments| 16 | 17 | raise(Puppet::ParseError, "hash(): Wrong number of arguments " + 18 | "given (#{arguments.size} for 1)") if arguments.size < 1 19 | 20 | array = arguments[0] 21 | 22 | unless array.is_a?(Array) 23 | raise(Puppet::ParseError, 'hash(): Requires array to work with') 24 | end 25 | 26 | result = {} 27 | 28 | begin 29 | # This is to make it compatible with older version of Ruby ... 30 | array = array.flatten 31 | result = Hash[*array] 32 | rescue Exception 33 | raise(Puppet::ParseError, 'hash(): Unable to compute ' + 34 | 'hash from array given') 35 | end 36 | 37 | return result 38 | end 39 | end 40 | 41 | # vim: set ts=2 sw=2 et : 42 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_array.rb: -------------------------------------------------------------------------------- 1 | # 2 | # is_array.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:is_array, :type => :rvalue, :doc => <<-EOS 7 | Returns true if the variable passed to this function is an array. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "is_array(): 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?(Array) 17 | 18 | return result 19 | end 20 | end 21 | 22 | # vim: set ts=2 sw=2 et : 23 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_float.rb: -------------------------------------------------------------------------------- 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 | if value != value.to_f.to_s and !value.is_a? Float then 19 | return false 20 | else 21 | return true 22 | end 23 | 24 | end 25 | end 26 | 27 | # vim: set ts=2 sw=2 et : 28 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_function_available.rb: -------------------------------------------------------------------------------- 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 | function = Puppet::Parser::Functions.function(arguments[0].to_sym) 19 | function.is_a?(String) and not function.empty? 20 | end 21 | end 22 | 23 | # vim: set ts=2 sw=2 et : 24 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_hash.rb: -------------------------------------------------------------------------------- 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 : 23 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_integer.rb: -------------------------------------------------------------------------------- 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 returned to this string is an integer. 8 | EOS 9 | ) do |arguments| 10 | 11 | if (arguments.size != 1) then 12 | raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+ 13 | "given #{arguments.size} for 1") 14 | end 15 | 16 | value = arguments[0] 17 | 18 | if value != value.to_i.to_s and !value.is_a? Fixnum then 19 | return false 20 | else 21 | return true 22 | end 23 | 24 | end 25 | end 26 | 27 | # vim: set ts=2 sw=2 et : 28 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb: -------------------------------------------------------------------------------- 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 : 33 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb: -------------------------------------------------------------------------------- 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 : 28 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_numeric.rb: -------------------------------------------------------------------------------- 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 variable passed to this function is a number. 8 | EOS 9 | ) do |arguments| 10 | 11 | if (arguments.size != 1) then 12 | raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+ 13 | "given #{arguments.size} for 1") 14 | end 15 | 16 | value = arguments[0] 17 | 18 | if value == value.to_f.to_s or value == value.to_i.to_s or value.is_a? Numeric 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 : 28 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/is_string.rb: -------------------------------------------------------------------------------- 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 : 27 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/join.rb: -------------------------------------------------------------------------------- 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 seperator. 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 : 42 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/keys.rb: -------------------------------------------------------------------------------- 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 : 27 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/loadyaml.rb: -------------------------------------------------------------------------------- 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 21 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/lstrip.rb: -------------------------------------------------------------------------------- 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 : 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/max.rb: -------------------------------------------------------------------------------- 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 22 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/min.rb: -------------------------------------------------------------------------------- 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 22 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/parsejson.rb: -------------------------------------------------------------------------------- 1 | # 2 | # parsejson.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS 7 | This function accepts JSON as a string and converts into the correct Puppet 8 | structure. 9 | EOS 10 | ) do |arguments| 11 | 12 | if (arguments.size != 1) then 13 | raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+ 14 | "given #{arguments.size} for 1") 15 | end 16 | 17 | json = arguments[0] 18 | 19 | # PSON is natively available in puppet 20 | PSON.load(json) 21 | end 22 | end 23 | 24 | # vim: set ts=2 sw=2 et : 25 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/parseyaml.rb: -------------------------------------------------------------------------------- 1 | # 2 | # parseyaml.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS 7 | This function accepts YAML as a string and converts it into the correct 8 | Puppet structure. 9 | EOS 10 | ) do |arguments| 11 | 12 | if (arguments.size != 1) then 13 | raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+ 14 | "given #{arguments.size} for 1") 15 | end 16 | 17 | require 'yaml' 18 | 19 | YAML::load(arguments[0]) 20 | 21 | end 22 | end 23 | 24 | # vim: set ts=2 sw=2 et : 25 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/pick.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:pick, :type => :rvalue, :doc => <<-EOS 3 | 4 | This function is similar to a coalesce function in SQL in that it will return 5 | the first value in a list of values that is not undefined or an empty string 6 | (two things in Puppet that will return a boolean false value). Typically, 7 | this function is used to check for a value in the Puppet Dashboard/Enterprise 8 | Console, and failover to a default value like the following: 9 | 10 | $real_jenkins_version = pick($::jenkins_version, '1.449') 11 | 12 | The value of $real_jenkins_version will first look for a top-scope variable 13 | called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ 14 | Enterprise Console are brought into Puppet as top-scope variables), and, 15 | failing that, will use a default value of 1.449. 16 | 17 | EOS 18 | ) do |args| 19 | args = args.compact 20 | args.delete(:undef) 21 | args.delete(:undefined) 22 | args.delete("") 23 | if args[0].to_s.empty? then 24 | fail "Must provide non empty value." 25 | else 26 | return args[0] 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/reject.rb: -------------------------------------------------------------------------------- 1 | # 2 | # reject.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args| 7 | This function searches through an array and rejects all elements that match 8 | the provided regular expression. 9 | 10 | *Examples:* 11 | 12 | reject(['aaa','bbb','ccc','aaaddd'], 'aaa') 13 | 14 | Would return: 15 | 16 | ['bbb','ccc'] 17 | EOS 18 | 19 | if (args.size != 2) 20 | raise Puppet::ParseError, 21 | "reject(): Wrong number of arguments given #{args.size} for 2" 22 | end 23 | 24 | ary = args[0] 25 | pattern = Regexp.new(args[1]) 26 | 27 | ary.reject { |e| e =~ pattern } 28 | end 29 | end 30 | 31 | # vim: set ts=2 sw=2 et : 32 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/reverse.rb: -------------------------------------------------------------------------------- 1 | # 2 | # reverse.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:reverse, :type => :rvalue, :doc => <<-EOS 7 | Reverses the order of a string or array. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "reverse(): Wrong number of arguments " + 12 | "given (#{arguments.size} for 1)") if arguments.size < 1 13 | 14 | value = arguments[0] 15 | klass = value.class 16 | 17 | unless [Array, String].include?(klass) 18 | raise(Puppet::ParseError, 'reverse(): Requires either ' + 19 | 'array or string to work with') 20 | end 21 | 22 | result = value.reverse 23 | 24 | return result 25 | end 26 | end 27 | 28 | # vim: set ts=2 sw=2 et : 29 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/rstrip.rb: -------------------------------------------------------------------------------- 1 | # 2 | # rstrip.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS 7 | Strips leading spaces to the right of the string. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " + 12 | "given (#{arguments.size} for 1)") if arguments.size < 1 13 | 14 | value = arguments[0] 15 | klass = value.class 16 | 17 | unless [Array, String].include?(klass) 18 | raise(Puppet::ParseError, 'rstrip(): Requires either ' + 19 | 'array or string to work with') 20 | end 21 | 22 | if value.is_a?(Array) 23 | result = value.collect { |i| i.is_a?(String) ? i.rstrip : i } 24 | else 25 | result = value.rstrip 26 | end 27 | 28 | return result 29 | end 30 | end 31 | 32 | # vim: set ts=2 sw=2 et : 33 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/sort.rb: -------------------------------------------------------------------------------- 1 | # 2 | # sort.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:sort, :type => :rvalue, :doc => <<-EOS 7 | Sorts strings and arrays lexically. 8 | EOS 9 | ) do |arguments| 10 | 11 | if (arguments.size != 1) then 12 | raise(Puppet::ParseError, "sort(): Wrong number of arguments "+ 13 | "given #{arguments.size} for 1") 14 | end 15 | 16 | value = arguments[0] 17 | 18 | if value.is_a?(Array) then 19 | value.sort 20 | elsif value.is_a?(String) then 21 | value.split("").sort.join("") 22 | end 23 | 24 | end 25 | end 26 | 27 | # vim: set ts=2 sw=2 et : 28 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/squeeze.rb: -------------------------------------------------------------------------------- 1 | # 2 | # squeeze.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS 7 | Returns a new string where runs of the same character that occur in this set are replaced by a single character. 8 | EOS 9 | ) do |arguments| 10 | 11 | if ((arguments.size != 2) and (arguments.size != 1)) then 12 | raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+ 13 | "given #{arguments.size} for 2 or 1") 14 | end 15 | 16 | item = arguments[0] 17 | squeezeval = arguments[1] 18 | 19 | if item.is_a?(Array) then 20 | if squeezeval then 21 | item.collect { |i| i.squeeze(squeezeval) } 22 | else 23 | item.collect { |i| i.squeeze } 24 | end 25 | else 26 | if squeezeval then 27 | item.squeeze(squeezeval) 28 | else 29 | item.squeeze 30 | end 31 | end 32 | 33 | end 34 | end 35 | 36 | # vim: set ts=2 sw=2 et : 37 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/strip.rb: -------------------------------------------------------------------------------- 1 | # 2 | # strip.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:strip, :type => :rvalue, :doc => <<-EOS 7 | This function removes leading and trailing whitespace from a string or from 8 | every string inside an array. 9 | 10 | *Examples:* 11 | 12 | strip(" aaa ") 13 | 14 | Would result in: "aaa" 15 | EOS 16 | ) do |arguments| 17 | 18 | raise(Puppet::ParseError, "strip(): Wrong number of arguments " + 19 | "given (#{arguments.size} for 1)") if arguments.size < 1 20 | 21 | value = arguments[0] 22 | klass = value.class 23 | 24 | unless [Array, String].include?(klass) 25 | raise(Puppet::ParseError, 'strip(): Requires either ' + 26 | 'array or string to work with') 27 | end 28 | 29 | if value.is_a?(Array) 30 | result = value.collect { |i| i.is_a?(String) ? i.strip : i } 31 | else 32 | result = value.strip 33 | end 34 | 35 | return result 36 | end 37 | end 38 | 39 | # vim: set ts=2 sw=2 et : 40 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/swapcase.rb: -------------------------------------------------------------------------------- 1 | # 2 | # swapcase.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS 7 | This function will swap the existing case of a string. 8 | 9 | *Examples:* 10 | 11 | swapcase("aBcD") 12 | 13 | Would result in: "AbCd" 14 | EOS 15 | ) do |arguments| 16 | 17 | raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " + 18 | "given (#{arguments.size} for 1)") if arguments.size < 1 19 | 20 | value = arguments[0] 21 | klass = value.class 22 | 23 | unless [Array, String].include?(klass) 24 | raise(Puppet::ParseError, 'swapcase(): Requires either ' + 25 | 'array or string to work with') 26 | end 27 | 28 | if value.is_a?(Array) 29 | # Numbers in Puppet are often string-encoded which is troublesome ... 30 | result = value.collect { |i| i.is_a?(String) ? i.swapcase : i } 31 | else 32 | result = value.swapcase 33 | end 34 | 35 | return result 36 | end 37 | end 38 | 39 | # vim: set ts=2 sw=2 et : 40 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/to_bytes.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS 3 | Converts the argument into bytes, for example 4 kB becomes 4096. 4 | Takes a single string value as an argument. 5 | EOS 6 | ) do |arguments| 7 | 8 | raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " + 9 | "given (#{arguments.size} for 1)") if arguments.size != 1 10 | 11 | arg = arguments[0] 12 | 13 | return arg if arg.is_a? Numeric 14 | 15 | value,prefix = */([0-9.e+-]*)\s*([^bB]?)/.match(arg)[1,2] 16 | 17 | value = value.to_f 18 | case prefix 19 | when '' then return value.to_i 20 | when 'k' then return (value*(1<<10)).to_i 21 | when 'M' then return (value*(1<<20)).to_i 22 | when 'G' then return (value*(1<<30)).to_i 23 | when 'T' then return (value*(1<<40)).to_i 24 | when 'E' then return (value*(1<<50)).to_i 25 | else raise Puppet::ParseError, "to_bytes(): Unknown prefix #{prefix}" 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/upcase.rb: -------------------------------------------------------------------------------- 1 | # 2 | # upcase.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:upcase, :type => :rvalue, :doc => <<-EOS 7 | Converts a string or an array of strings to uppercase. 8 | 9 | *Examples:* 10 | 11 | upcase("abcd") 12 | 13 | Will return: 14 | 15 | ASDF 16 | EOS 17 | ) do |arguments| 18 | 19 | raise(Puppet::ParseError, "upcase(): Wrong number of arguments " + 20 | "given (#{arguments.size} for 1)") if arguments.size < 1 21 | 22 | value = arguments[0] 23 | klass = value.class 24 | 25 | unless [Array, String].include?(klass) 26 | raise(Puppet::ParseError, 'upcase(): Requires either ' + 27 | 'array or string to work with') 28 | end 29 | 30 | if value.is_a?(Array) 31 | # Numbers in Puppet are often string-encoded which is troublesome ... 32 | result = value.collect { |i| i.is_a?(String) ? i.upcase : i } 33 | else 34 | result = value.upcase 35 | end 36 | 37 | return result 38 | end 39 | end 40 | 41 | # vim: set ts=2 sw=2 et : 42 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/uriescape.rb: -------------------------------------------------------------------------------- 1 | # 2 | # uriescape.rb 3 | # 4 | require 'uri' 5 | 6 | module Puppet::Parser::Functions 7 | newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS 8 | Urlencodes a string or array of strings. 9 | Requires either a single string or an array as an input. 10 | EOS 11 | ) do |arguments| 12 | 13 | raise(Puppet::ParseError, "uriescape(): Wrong number of arguments " + 14 | "given (#{arguments.size} for 1)") if arguments.size < 1 15 | 16 | value = arguments[0] 17 | klass = value.class 18 | unsafe = ":/?#[]@!$&'()*+,;= " 19 | 20 | unless [Array, String].include?(klass) 21 | raise(Puppet::ParseError, 'uriescape(): Requires either ' + 22 | 'array or string to work with') 23 | end 24 | 25 | if value.is_a?(Array) 26 | # Numbers in Puppet are often string-encoded which is troublesome ... 27 | result = value.collect { |i| i.is_a?(String) ? URI.escape(i,unsafe) : i } 28 | else 29 | result = URI.escape(value,unsafe) 30 | end 31 | 32 | return result 33 | end 34 | end 35 | 36 | # vim: set ts=2 sw=2 et : 37 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/validate_array.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | 3 | newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args| 4 | Validate that all passed values are array data structures. Abort catalog 5 | compilation if any value fails this check. 6 | 7 | The following values will pass: 8 | 9 | $my_array = [ 'one', 'two' ] 10 | validate_array($my_array) 11 | 12 | The following values will fail, causing compilation to abort: 13 | 14 | validate_array(true) 15 | validate_array('some_string') 16 | $undefined = undef 17 | validate_array($undefined) 18 | 19 | ENDHEREDOC 20 | 21 | unless args.length > 0 then 22 | raise Puppet::ParseError, ("validate_array(): wrong number of arguments (#{args.length}; must be > 0)") 23 | end 24 | 25 | args.each do |arg| 26 | unless arg.is_a?(Array) 27 | raise Puppet::ParseError, ("#{arg.inspect} is not an Array. It looks to be a #{arg.class}") 28 | end 29 | end 30 | 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/validate_bool.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | 3 | newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args| 4 | Validate that all passed values are either true or false. Abort catalog 5 | compilation if any value fails this check. 6 | 7 | The following values will pass: 8 | 9 | $iamtrue = true 10 | validate_bool(true) 11 | validate_bool(true, true, false, $iamtrue) 12 | 13 | The following values will fail, causing compilation to abort: 14 | 15 | $some_array = [ true ] 16 | validate_bool("false") 17 | validate_bool("true") 18 | validate_bool($some_array) 19 | 20 | ENDHEREDOC 21 | 22 | unless args.length > 0 then 23 | raise Puppet::ParseError, ("validate_bool(): wrong number of arguments (#{args.length}; must be > 0)") 24 | end 25 | 26 | args.each do |arg| 27 | unless (arg.is_a?(TrueClass) || arg.is_a?(FalseClass)) 28 | raise Puppet::ParseError, ("#{arg.inspect} is not a boolean. It looks to be a #{arg.class}") 29 | end 30 | end 31 | 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/validate_hash.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | 3 | newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args| 4 | Validate that all passed values are hash data structures. Abort catalog 5 | compilation if any value fails this check. 6 | 7 | The following values will pass: 8 | 9 | $my_hash = { 'one' => 'two' } 10 | validate_hash($my_hash) 11 | 12 | The following values will fail, causing compilation to abort: 13 | 14 | validate_hash(true) 15 | validate_hash('some_string') 16 | $undefined = undef 17 | validate_hash($undefined) 18 | 19 | ENDHEREDOC 20 | 21 | unless args.length > 0 then 22 | raise Puppet::ParseError, ("validate_hash(): wrong number of arguments (#{args.length}; must be > 0)") 23 | end 24 | 25 | args.each do |arg| 26 | unless arg.is_a?(Hash) 27 | raise Puppet::ParseError, ("#{arg.inspect} is not a Hash. It looks to be a #{arg.class}") 28 | end 29 | end 30 | 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/validate_string.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | 3 | newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args| 4 | Validate that all passed values are string data structures. Abort catalog 5 | compilation if any value fails this check. 6 | 7 | The following values will pass: 8 | 9 | $my_string = "one two" 10 | validate_string($my_string, 'three') 11 | 12 | The following values will fail, causing compilation to abort: 13 | 14 | validate_string(true) 15 | validate_string([ 'some', 'array' ]) 16 | $undefined = undef 17 | validate_string($undefined) 18 | 19 | ENDHEREDOC 20 | 21 | unless args.length > 0 then 22 | raise Puppet::ParseError, ("validate_string(): wrong number of arguments (#{args.length}; must be > 0)") 23 | end 24 | 25 | args.each do |arg| 26 | unless arg.is_a?(String) 27 | raise Puppet::ParseError, ("#{arg.inspect} is not a string. It looks to be a #{arg.class}") 28 | end 29 | end 30 | 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /modules/stdlib/lib/puppet/parser/functions/values.rb: -------------------------------------------------------------------------------- 1 | # 2 | # values.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:values, :type => :rvalue, :doc => <<-EOS 7 | When given a hash this function will return the values of that hash. 8 | 9 | *Examples:* 10 | 11 | $hash = { 12 | 'a' => 1, 13 | 'b' => 2, 14 | 'c' => 3, 15 | } 16 | values($hash) 17 | 18 | This example would return: 19 | 20 | [1,2,3] 21 | EOS 22 | ) do |arguments| 23 | 24 | raise(Puppet::ParseError, "values(): Wrong number of arguments " + 25 | "given (#{arguments.size} for 1)") if arguments.size < 1 26 | 27 | hash = arguments[0] 28 | 29 | unless hash.is_a?(Hash) 30 | raise(Puppet::ParseError, 'values(): Requires hash to work with') 31 | end 32 | 33 | result = hash.values 34 | 35 | return result 36 | end 37 | end 38 | 39 | # vim: set ts=2 sw=2 et : 40 | -------------------------------------------------------------------------------- /modules/stdlib/manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Class: stdlib 2 | # 3 | # This module manages stdlib. Most of stdlib's features are automatically 4 | # loaded by Puppet, but this class should be declared in order to use the 5 | # standardized run stages. 6 | # 7 | # Parameters: none 8 | # 9 | # Actions: 10 | # 11 | # Declares all other classes in the stdlib module. Currently, this consists 12 | # of stdlib::stages. 13 | # 14 | # Requires: nothing 15 | # 16 | class stdlib { 17 | 18 | class { 'stdlib::stages': } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /modules/stdlib/manifests/stages.pp: -------------------------------------------------------------------------------- 1 | # Class: stdlib::stages 2 | # 3 | # This class manages a standard set of run stages for Puppet. It is managed by 4 | # the stdlib class, and should not be declared independently. 5 | # 6 | # The high level stages are (in order): 7 | # 8 | # * setup 9 | # * main 10 | # * runtime 11 | # * setup_infra 12 | # * deploy_infra 13 | # * setup_app 14 | # * deploy_app 15 | # * deploy 16 | # 17 | # Parameters: none 18 | # 19 | # Actions: 20 | # 21 | # Declares various run-stages for deploying infrastructure, 22 | # language runtimes, and application layers. 23 | # 24 | # Requires: nothing 25 | # 26 | # Sample Usage: 27 | # 28 | # node default { 29 | # include stdlib 30 | # class { java: stage => 'runtime' } 31 | # } 32 | # 33 | class stdlib::stages { 34 | 35 | stage { 'setup': before => Stage['main'] } 36 | stage { 'runtime': require => Stage['main'] } 37 | -> stage { 'setup_infra': } 38 | -> stage { 'deploy_infra': } 39 | -> stage { 'setup_app': } 40 | -> stage { 'deploy_app': } 41 | -> stage { 'deploy': } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /modules/stdlib/spec/classes/anchor_spec.rb: -------------------------------------------------------------------------------- 1 | require 'puppet' 2 | require 'rspec-puppet' 3 | 4 | describe "anchorrefresh" do 5 | let(:node) { 'testhost.example.com' } 6 | let :pre_condition do 7 | <<-ANCHORCLASS 8 | class anchored { 9 | anchor { 'anchored::begin': } 10 | ~> anchor { 'anchored::end': } 11 | } 12 | 13 | class anchorrefresh { 14 | notify { 'first': } 15 | ~> class { 'anchored': } 16 | ~> anchor { 'final': } 17 | } 18 | ANCHORCLASS 19 | end 20 | 21 | def apply_catalog_and_return_exec_rsrc 22 | catalog = subject.to_ral 23 | transaction = catalog.apply 24 | transaction.resource_status("Anchor[final]") 25 | end 26 | 27 | it 'propagates events through the anchored class' do 28 | resource = apply_catalog_and_return_exec_rsrc 29 | 30 | expect(resource.restarted).to eq(true) 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /modules/stdlib/spec/fixtures/manifests/site.pp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hunner/roles_and_profiles/43017ced23fcc181d66386a2daa5e4da9e40b316/modules/stdlib/spec/fixtures/manifests/site.pp -------------------------------------------------------------------------------- /modules/stdlib/spec/monkey_patches/alias_should_to_must.rb: -------------------------------------------------------------------------------- 1 | require 'rspec' 2 | 3 | class Object 4 | # This is necessary because the RAL has a 'should' 5 | # method. 6 | alias :must :should 7 | alias :must_not :should_not 8 | end 9 | -------------------------------------------------------------------------------- /modules/stdlib/spec/monkey_patches/publicize_methods.rb: -------------------------------------------------------------------------------- 1 | # Some monkey-patching to allow us to test private methods. 2 | class Class 3 | def publicize_methods(*methods) 4 | saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods 5 | 6 | self.class_eval { public(*saved_private_instance_methods) } 7 | yield 8 | self.class_eval { private(*saved_private_instance_methods) } 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /modules/stdlib/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --format 2 | s 3 | --colour 4 | --loadby 5 | mtime 6 | --backtrace 7 | -------------------------------------------------------------------------------- /modules/stdlib/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.dirname(__FILE__)) 2 | $LOAD_PATH.unshift File.join(dir, 'lib') 3 | 4 | # Don't want puppet getting the command line arguments for rake or autotest 5 | ARGV.clear 6 | 7 | require 'puppet' 8 | require 'facter' 9 | require 'mocha' 10 | gem 'rspec', '>=2.0.0' 11 | require 'rspec/expectations' 12 | 13 | require 'puppetlabs_spec_helper/module_spec_helper' 14 | 15 | RSpec.configure do |config| 16 | # FIXME REVISIT - We may want to delegate to Facter like we do in 17 | # Puppet::PuppetSpecInitializer.initialize_via_testhelper(config) because 18 | # this behavior is a duplication of the spec_helper in Facter. 19 | config.before :each do 20 | # Ensure that we don't accidentally cache facts and environment between 21 | # test cases. This requires each example group to explicitly load the 22 | # facts being exercised with something like 23 | # Facter.collection.loader.load(:ipaddress) 24 | Facter::Util::Loader.any_instance.stubs(:load_all) 25 | Facter.clear 26 | Facter.clear_messages 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require 'facter/util/puppet_settings' 3 | 4 | describe Facter::Util::PuppetSettings do 5 | 6 | describe "#with_puppet" do 7 | context "Without Puppet loaded" do 8 | before(:each) do 9 | Module.expects(:const_get).with("Puppet").raises(NameError) 10 | end 11 | 12 | it 'should be nil' do 13 | subject.with_puppet { Puppet[:vardir] }.should be_nil 14 | end 15 | it 'should not yield to the block' do 16 | Puppet.expects(:[]).never 17 | subject.with_puppet { Puppet[:vardir] }.should be_nil 18 | end 19 | end 20 | context "With Puppet loaded" do 21 | module Puppet; end 22 | let(:vardir) { "/var/lib/puppet" } 23 | 24 | before :each do 25 | Puppet.expects(:[]).with(:vardir).returns vardir 26 | end 27 | it 'should yield to the block' do 28 | subject.with_puppet { Puppet[:vardir] } 29 | end 30 | it 'should return the nodes vardir' do 31 | subject.with_puppet { Puppet[:vardir] }.should eq vardir 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/abs_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | 3 | require 'spec_helper' 4 | 5 | describe "the abs function" do 6 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 7 | 8 | it "should exist" do 9 | Puppet::Parser::Functions.function("abs").should == "function_abs" 10 | end 11 | 12 | it "should raise a ParseError if there is less than 1 arguments" do 13 | lambda { scope.function_abs([]) }.should( raise_error(Puppet::ParseError)) 14 | end 15 | 16 | it "should convert a negative number into a positive" do 17 | result = scope.function_abs(["-34"]) 18 | result.should(eq(34)) 19 | end 20 | 21 | it "should do nothing with a positive number" do 22 | result = scope.function_abs(["5678"]) 23 | result.should(eq(5678)) 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/bool2num_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the bool2num function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("bool2num").should == "function_bool2num" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should convert true to 1" do 16 | result = scope.function_bool2num([true]) 17 | result.should(eq(1)) 18 | end 19 | 20 | it "should convert false to 0" do 21 | result = scope.function_bool2num([false]) 22 | result.should(eq(0)) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/capitalize_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the capitalize function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("capitalize").should == "function_capitalize" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should capitalize the beginning of a string" do 16 | result = scope.function_capitalize(["abc"]) 17 | result.should(eq("Abc")) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/chomp_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the chomp function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("chomp").should == "function_chomp" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_chomp([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should chomp the end of a string" do 16 | result = scope.function_chomp(["abc\n"]) 17 | result.should(eq("abc")) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/chop_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the chop function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("chop").should == "function_chop" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_chop([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should chop the end of a string" do 16 | result = scope.function_chop(["asdf\n"]) 17 | result.should(eq("asdf")) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/concat_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the concat function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should raise a ParseError if there is less than 1 arguments" do 8 | lambda { scope.function_concat([]) }.should( raise_error(Puppet::ParseError)) 9 | end 10 | 11 | it "should be able to concat an array" do 12 | result = scope.function_concat([['1','2','3'],['4','5','6']]) 13 | result.should(eq(['1','2','3','4','5','6'])) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/count_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | 3 | require 'spec_helper' 4 | 5 | describe "the count function" do 6 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 7 | 8 | it "should exist" do 9 | Puppet::Parser::Functions.function("count").should == "function_count" 10 | end 11 | 12 | it "should raise a ArgumentError if there is more than 2 arguments" do 13 | lambda { scope.function_count(['foo', 'bar', 'baz']) }.should( raise_error(ArgumentError)) 14 | end 15 | 16 | it "should be able to count arrays" do 17 | scope.function_count([["1","2","3"]]).should(eq(3)) 18 | end 19 | 20 | it "should be able to count matching elements in arrays" do 21 | scope.function_count([["1", "2", "2"], "2"]).should(eq(2)) 22 | end 23 | 24 | it "should not count nil or empty strings" do 25 | scope.function_count([["foo","bar",nil,""]]).should(eq(2)) 26 | end 27 | 28 | it 'does not count an undefined hash key or an out of bound array index (which are both :undef)' do 29 | expect(scope.function_count([["foo",:undef,:undef]])).to eq(1) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/delete_at_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the delete_at function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("delete_at").should == "function_delete_at" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_delete_at([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should delete an item at specified location from an array" do 16 | result = scope.function_delete_at([['a','b','c'],1]) 17 | result.should(eq(['a','c'])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/dirname_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the dirname function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("dirname").should == "function_dirname" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_dirname([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return dirname for an absolute path" do 16 | result = scope.function_dirname(['/path/to/a/file.ext']) 17 | result.should(eq('/path/to/a')) 18 | end 19 | 20 | it "should return dirname for a relative path" do 21 | result = scope.function_dirname(['path/to/a/file.ext']) 22 | result.should(eq('path/to/a')) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/downcase_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the downcase function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("downcase").should == "function_downcase" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_downcase([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should downcase a string" do 16 | result = scope.function_downcase(["ASFD"]) 17 | result.should(eq("asfd")) 18 | end 19 | 20 | it "should do nothing to a string that is already downcase" do 21 | result = scope.function_downcase(["asdf asdf"]) 22 | result.should(eq("asdf asdf")) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/empty_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the empty function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | it "should exist" do 7 | Puppet::Parser::Functions.function("empty").should == "function_empty" 8 | end 9 | 10 | it "should raise a ParseError if there is less than 1 arguments" do 11 | lambda { scope.function_empty([]) }.should( raise_error(Puppet::ParseError)) 12 | end 13 | 14 | it "should return a true for an empty string" do 15 | result = scope.function_empty(['']) 16 | result.should(eq(true)) 17 | end 18 | 19 | it "should return a false for a non-empty string" do 20 | result = scope.function_empty(['asdf']) 21 | result.should(eq(false)) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/flatten_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the flatten function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | it "should exist" do 7 | Puppet::Parser::Functions.function("flatten").should == "function_flatten" 8 | end 9 | 10 | it "should raise a ParseError if there is less than 1 arguments" do 11 | lambda { scope.function_flatten([]) }.should( raise_error(Puppet::ParseError)) 12 | end 13 | 14 | it "should raise a ParseError if there is more than 1 argument" do 15 | lambda { scope.function_flatten([[], []]) }.should( raise_error(Puppet::ParseError)) 16 | end 17 | 18 | it "should flatten a complex data structure" do 19 | result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]]) 20 | result.should(eq(["a","b","c","d","e","f","g"])) 21 | end 22 | 23 | it "should do nothing to a structure that is already flat" do 24 | result = scope.function_flatten([["a","b","c","d"]]) 25 | result.should(eq(["a","b","c","d"])) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/grep_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the grep function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("grep").should == "function_grep" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_grep([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should grep contents from an array" do 16 | result = scope.function_grep([["aaabbb","bbbccc","dddeee"], "bbb"]) 17 | result.should(eq(["aaabbb","bbbccc"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/hash_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the hash function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("hash").should == "function_hash" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_hash([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should convert an array to a hash" do 16 | result = scope.function_hash([['a',1,'b',2,'c',3]]) 17 | result.should(eq({'a'=>1,'b'=>2,'c'=>3})) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_array_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_array function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("is_array").should == "function_is_array" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_is_array([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if passed an array" do 16 | result = scope.function_is_array([[1,2,3]]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if passed a hash" do 21 | result = scope.function_is_array([{'a'=>1}]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return false if passed a string" do 26 | result = scope.function_is_array(["asdf"]) 27 | result.should(eq(false)) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_float_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_float function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("is_float").should == "function_is_float" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_is_float([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if a float" do 16 | result = scope.function_is_float(["0.12"]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if a string" do 21 | result = scope.function_is_float(["asdf"]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return false if an integer" do 26 | result = scope.function_is_float(["3"]) 27 | result.should(eq(false)) 28 | end 29 | it "should return true if a float is created from an arithmetical operation" do 30 | result = scope.function_is_float([3.2*2]) 31 | result.should(eq(true)) 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_function_available.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_function_available function" do 5 | before :all do 6 | Puppet::Parser::Functions.autoloader.loadall 7 | end 8 | 9 | before :each do 10 | @scope = Puppet::Parser::Scope.new 11 | end 12 | 13 | it "should exist" do 14 | Puppet::Parser::Functions.function("is_function_available").should == "function_is_function_available" 15 | end 16 | 17 | it "should raise a ParseError if there is less than 1 arguments" do 18 | lambda { @scope.function_is_function_available([]) }.should( raise_error(Puppet::ParseError)) 19 | end 20 | 21 | it "should return false if a nonexistent function is passed" do 22 | result = @scope.function_is_function_available(['jeff_mccunes_left_sock']) 23 | result.should(eq(false)) 24 | end 25 | 26 | it "should return true if an available function is passed" do 27 | result = @scope.function_is_function_available(['require']) 28 | result.should(eq(true)) 29 | end 30 | 31 | end 32 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_hash_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_hash function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("is_hash").should == "function_is_hash" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_is_hash([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if passed a hash" do 16 | result = scope.function_is_hash([{"a"=>1,"b"=>2}]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if passed an array" do 21 | result = scope.function_is_hash([["a","b"]]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return false if passed a string" do 26 | result = scope.function_is_hash(["asdf"]) 27 | result.should(eq(false)) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_integer_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_integer function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("is_integer").should == "function_is_integer" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_is_integer([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if an integer" do 16 | result = scope.function_is_integer(["3"]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if a float" do 21 | result = scope.function_is_integer(["3.2"]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return false if a string" do 26 | result = scope.function_is_integer(["asdf"]) 27 | result.should(eq(false)) 28 | end 29 | 30 | it "should return true if an integer is created from an arithmetical operation" do 31 | result = scope.function_is_integer([3*2]) 32 | result.should(eq(true)) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_mac_address_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_mac_address function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if a valid mac address" do 16 | result = scope.function_is_mac_address(["00:a0:1f:12:7f:a0"]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if octets are out of range" do 21 | result = scope.function_is_mac_address(["00:a0:1f:12:7f:g0"]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return false if not valid" do 26 | result = scope.function_is_mac_address(["not valid"]) 27 | result.should(eq(false)) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/is_string_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the is_string function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("is_string").should == "function_is_string" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_is_string([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if a string" do 16 | result = scope.function_is_string(["asdf"]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if an integer" do 21 | result = scope.function_is_string(["3"]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return false if a float" do 26 | result = scope.function_is_string(["3.23"]) 27 | result.should(eq(false)) 28 | end 29 | 30 | it "should return false if an array" do 31 | result = scope.function_is_string([["a","b","c"]]) 32 | result.should(eq(false)) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/join_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the join function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("join").should == "function_join" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_join([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should join an array into a string" do 16 | result = scope.function_join([["a","b","c"], ":"]) 17 | result.should(eq("a:b:c")) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/keys_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the keys function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("keys").should == "function_keys" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_keys([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return an array of keys when given a hash" do 16 | result = scope.function_keys([{'a'=>1, 'b'=>2}]) 17 | # =~ performs 'array with same elements' (set) matching 18 | # For more info see RSpec::Matchers::MatchArray 19 | result.should =~ ['a','b'] 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/lstrip_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the lstrip function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("lstrip").should == "function_lstrip" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_lstrip([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should lstrip a string" do 16 | result = scope.function_lstrip([" asdf"]) 17 | result.should(eq('asdf')) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/max_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | 3 | require 'spec_helper' 4 | 5 | describe "the max function" do 6 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 7 | 8 | it "should exist" do 9 | Puppet::Parser::Functions.function("max").should == "function_max" 10 | end 11 | 12 | it "should raise a ParseError if there is less than 1 arguments" do 13 | lambda { scope.function_max([]) }.should( raise_error(Puppet::ParseError)) 14 | end 15 | 16 | it "should be able to compare strings" do 17 | scope.function_max(["albatross","dog","horse"]).should(eq("horse")) 18 | end 19 | 20 | it "should be able to compare numbers" do 21 | scope.function_max([6,8,4]).should(eq(8)) 22 | end 23 | 24 | it "should be able to compare a number with a stringified number" do 25 | scope.function_max([1,"2"]).should(eq("2")) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/member_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the member function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("member").should == "function_member" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_member([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return true if a member is in an array" do 16 | result = scope.function_member([["a","b","c"], "a"]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should return false if a member is not in an array" do 21 | result = scope.function_member([["a","b","c"], "d"]) 22 | result.should(eq(false)) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/min_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | 3 | require 'spec_helper' 4 | 5 | describe "the min function" do 6 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 7 | 8 | it "should exist" do 9 | Puppet::Parser::Functions.function("min").should == "function_min" 10 | end 11 | 12 | it "should raise a ParseError if there is less than 1 arguments" do 13 | lambda { scope.function_min([]) }.should( raise_error(Puppet::ParseError)) 14 | end 15 | 16 | it "should be able to compare strings" do 17 | scope.function_min(["albatross","dog","horse"]).should(eq("albatross")) 18 | end 19 | 20 | it "should be able to compare numbers" do 21 | scope.function_min([6,8,4]).should(eq(4)) 22 | end 23 | 24 | it "should be able to compare a number with a stringified number" do 25 | scope.function_min([1,"2"]).should(eq(1)) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/parsejson_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the parsejson function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("parsejson").should == "function_parsejson" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should convert JSON to a data structure" do 16 | json = <<-EOS 17 | ["aaa","bbb","ccc"] 18 | EOS 19 | result = scope.function_parsejson([json]) 20 | result.should(eq(['aaa','bbb','ccc'])) 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/parseyaml_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the parseyaml function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should convert YAML to a data structure" do 16 | yaml = <<-EOS 17 | - aaa 18 | - bbb 19 | - ccc 20 | EOS 21 | result = scope.function_parseyaml([yaml]) 22 | result.should(eq(['aaa','bbb','ccc'])) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/pick_spec.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the pick function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("pick").should == "function_pick" 9 | end 10 | 11 | it 'should return the correct value' do 12 | scope.function_pick(['first', 'second']).should == 'first' 13 | end 14 | 15 | it 'should return the correct value if the first value is empty' do 16 | scope.function_pick(['', 'second']).should == 'second' 17 | end 18 | 19 | it 'should remove empty string values' do 20 | scope.function_pick(['', 'first']).should == 'first' 21 | end 22 | 23 | it 'should remove :undef values' do 24 | scope.function_pick([:undef, 'first']).should == 'first' 25 | end 26 | 27 | it 'should remove :undefined values' do 28 | scope.function_pick([:undefined, 'first']).should == 'first' 29 | end 30 | 31 | it 'should error if no values are passed' do 32 | expect { scope.function_pick([]) }.to raise_error(Puppet::Error, /Must provide non empty value./) 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/prefix_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the prefix function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("prefix").should == "function_prefix" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_prefix([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return a prefixed array" do 16 | result = scope.function_prefix([['a','b','c'], 'p']) 17 | result.should(eq(['pa','pb','pc'])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/range_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the range function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("range").should == "function_range" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_range([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return a letter range" do 16 | result = scope.function_range(["a","d"]) 17 | result.should(eq(['a','b','c','d'])) 18 | end 19 | 20 | it "should return a number range" do 21 | result = scope.function_range(["1","4"]) 22 | result.should(eq([1,2,3,4])) 23 | end 24 | 25 | it "should work with padded hostname like strings" do 26 | expected = ("host01".."host10").to_a 27 | scope.function_range(["host01","host10"]).should eq expected 28 | end 29 | 30 | it "should coerce zero padded digits to integers" do 31 | expected = (0..10).to_a 32 | scope.function_range(["00", "10"]).should eq expected 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/reject_spec.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'spec_helper' 4 | 5 | describe "the reject function" do 6 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 7 | 8 | it "should exist" do 9 | Puppet::Parser::Functions.function("reject").should == "function_reject" 10 | end 11 | 12 | it "should raise a ParseError if there is less than 1 arguments" do 13 | lambda { scope.function_reject([]) }.should( raise_error(Puppet::ParseError)) 14 | end 15 | 16 | it "should reject contents from an array" do 17 | result = scope.function_reject([["1111", "aaabbb","bbbccc","dddeee"], "bbb"]) 18 | result.should(eq(["1111", "dddeee"])) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/reverse_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the reverse function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("reverse").should == "function_reverse" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_reverse([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should reverse a string" do 16 | result = scope.function_reverse(["asdfghijkl"]) 17 | result.should(eq('lkjihgfdsa')) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/rstrip_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the rstrip function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("rstrip").should == "function_rstrip" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_rstrip([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should rstrip a string" do 16 | result = scope.function_rstrip(["asdf "]) 17 | result.should(eq('asdf')) 18 | end 19 | 20 | it "should rstrip each element in an array" do 21 | result = scope.function_rstrip([["a ","b ", "c "]]) 22 | result.should(eq(['a','b','c'])) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/shuffle_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the shuffle function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("shuffle").should == "function_shuffle" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should shuffle a string and the result should be the same size" do 16 | result = scope.function_shuffle(["asdf"]) 17 | result.size.should(eq(4)) 18 | end 19 | 20 | it "should shuffle a string but the sorted contents should still be the same" do 21 | result = scope.function_shuffle(["adfs"]) 22 | result.split("").sort.join("").should(eq("adfs")) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/size_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the size function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("size").should == "function_size" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_size([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return the size of a string" do 16 | result = scope.function_size(["asdf"]) 17 | result.should(eq(4)) 18 | end 19 | 20 | it "should return the size of an array" do 21 | result = scope.function_size([["a","b","c"]]) 22 | result.should(eq(3)) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/sort_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the sort function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("sort").should == "function_sort" 9 | end 10 | 11 | it "should raise a ParseError if there is not 1 arguments" do 12 | lambda { scope.function_sort(['','']) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should sort an array" do 16 | result = scope.function_sort([["a","c","b"]]) 17 | result.should(eq(['a','b','c'])) 18 | end 19 | 20 | it "should sort a string" do 21 | result = scope.function_sort(["acb"]) 22 | result.should(eq('abc')) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/squeeze_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the squeeze function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("squeeze").should == "function_squeeze" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 2 arguments" do 12 | lambda { scope.function_squeeze([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should squeeze a string" do 16 | result = scope.function_squeeze(["aaabbbbcccc"]) 17 | result.should(eq('abc')) 18 | end 19 | 20 | it "should squeeze all elements in an array" do 21 | result = scope.function_squeeze([["aaabbbbcccc","dddfff"]]) 22 | result.should(eq(['abc','df'])) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/str2bool_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the str2bool function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("str2bool").should == "function_str2bool" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_str2bool([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should convert string 'true' to true" do 16 | result = scope.function_str2bool(["true"]) 17 | result.should(eq(true)) 18 | end 19 | 20 | it "should convert string 'undef' to false" do 21 | result = scope.function_str2bool(["undef"]) 22 | result.should(eq(false)) 23 | end 24 | 25 | it "should return the boolean it was called with" do 26 | result = scope.function_str2bool([true]) 27 | result.should(eq(true)) 28 | result = scope.function_str2bool([false]) 29 | result.should(eq(false)) 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/strftime_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the strftime function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("strftime").should == "function_strftime" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_strftime([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "using %s should be higher then when I wrote this test" do 16 | result = scope.function_strftime(["%s"]) 17 | result.to_i.should(be > 1311953157) 18 | end 19 | 20 | it "using %s should be lower then 1.5 trillion" do 21 | result = scope.function_strftime(["%s"]) 22 | result.to_i.should(be < 1500000000) 23 | end 24 | 25 | it "should return a date when given %Y-%m-%d" do 26 | result = scope.function_strftime(["%Y-%m-%d"]) 27 | result.should =~ /^\d{4}-\d{2}-\d{2}$/ 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/strip_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the strip function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | it "should exist" do 7 | Puppet::Parser::Functions.function("strip").should == "function_strip" 8 | end 9 | 10 | it "should raise a ParseError if there is less than 1 arguments" do 11 | lambda { scope.function_strip([]) }.should( raise_error(Puppet::ParseError)) 12 | end 13 | 14 | it "should strip a string" do 15 | result = scope.function_strip([" ab cd "]) 16 | result.should(eq('ab cd')) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/suffix_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the suffix function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("suffix").should == "function_suffix" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_suffix([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return a suffixed array" do 16 | result = scope.function_suffix([['a','b','c'], 'p']) 17 | result.should(eq(['ap','bp','cp'])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/swapcase_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the swapcase function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("swapcase").should == "function_swapcase" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_swapcase([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should swapcase a string" do 16 | result = scope.function_swapcase(["aaBBccDD"]) 17 | result.should(eq('AAbbCCdd')) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/time_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the time function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("time").should == "function_time" 9 | end 10 | 11 | it "should raise a ParseError if there is more than 2 arguments" do 12 | lambda { scope.function_time(['','']) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return a number" do 16 | result = scope.function_time([]) 17 | result.should be_an(Integer) 18 | end 19 | 20 | it "should be higher then when I wrote this test" do 21 | result = scope.function_time([]) 22 | result.should(be > 1311953157) 23 | end 24 | 25 | it "should be lower then 1.5 trillion" do 26 | result = scope.function_time([]) 27 | result.should(be < 1500000000) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/unique_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the unique function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("unique").should == "function_unique" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_unique([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should remove duplicate elements in a string" do 16 | result = scope.function_unique(["aabbc"]) 17 | result.should(eq('abc')) 18 | end 19 | 20 | it "should remove duplicate elements in an array" do 21 | result = scope.function_unique([["a","a","b","b","c"]]) 22 | result.should(eq(['a','b','c'])) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/upcase_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the upcase function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("upcase").should == "function_upcase" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_upcase([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should upcase a string" do 16 | result = scope.function_upcase(["abc"]) 17 | result.should(eq('ABC')) 18 | end 19 | 20 | it "should do nothing if a string is already upcase" do 21 | result = scope.function_upcase(["ABC"]) 22 | result.should(eq('ABC')) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/uriescape_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the uriescape function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("uriescape").should == "function_uriescape" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_uriescape([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should uriescape a string" do 16 | result = scope.function_uriescape([":/?#[]@!$&'()*+,;= "]) 17 | result.should(eq('%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%20')) 18 | end 19 | 20 | it "should do nothing if a string is already safe" do 21 | result = scope.function_uriescape(["ABCdef"]) 22 | result.should(eq('ABCdef')) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/parser/functions/zip_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the zip function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should raise a ParseError if there is less than 1 arguments" do 8 | lambda { scope.function_zip([]) }.should( raise_error(Puppet::ParseError)) 9 | end 10 | 11 | it "should be able to zip an array" do 12 | result = scope.function_zip([['1','2','3'],['4','5','6']]) 13 | result.should(eq([["1", "4"], ["2", "5"], ["3", "6"]])) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /modules/stdlib/spec/unit/puppet/type/anchor_spec.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'puppet' 4 | 5 | anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin") 6 | 7 | describe anchor do 8 | it "should stringify normally" do 9 | anchor.to_s.should == "Anchor[ntp::begin]" 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /modules/stdlib/tests/file_line.pp: -------------------------------------------------------------------------------- 1 | # This is a simple smoke test 2 | # of the file_line resource type. 3 | file { '/tmp/dansfile': 4 | ensure => present 5 | }-> 6 | file_line { 'dans_line': 7 | line => 'dan is awesome', 8 | path => '/tmp/dansfile', 9 | } 10 | -------------------------------------------------------------------------------- /modules/stdlib/tests/has_interface_with.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | info('has_interface_with(\'lo\'):', has_interface_with('lo')) 3 | info('has_interface_with(\'loX\'):', has_interface_with('loX')) 4 | info('has_interface_with(\'ipaddress\', \'127.0.0.1\'):', has_interface_with('ipaddress', '127.0.0.1')) 5 | info('has_interface_with(\'ipaddress\', \'127.0.0.100\'):', has_interface_with('ipaddress', '127.0.0.100')) 6 | info('has_interface_with(\'network\', \'127.0.0.0\'):', has_interface_with('network', '127.0.0.0')) 7 | info('has_interface_with(\'network\', \'128.0.0.0\'):', has_interface_with('network', '128.0.0.0')) 8 | info('has_interface_with(\'netmask\', \'255.0.0.0\'):', has_interface_with('netmask', '255.0.0.0')) 9 | info('has_interface_with(\'netmask\', \'256.0.0.0\'):', has_interface_with('netmask', '256.0.0.0')) 10 | 11 | -------------------------------------------------------------------------------- /modules/stdlib/tests/has_ip_address.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | info('has_ip_address(\'192.168.1.256\'):', has_ip_address('192.168.1.256')) 3 | info('has_ip_address(\'127.0.0.1\'):', has_ip_address('127.0.0.1')) 4 | -------------------------------------------------------------------------------- /modules/stdlib/tests/has_ip_network.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | info('has_ip_network(\'127.0.0.0\'):', has_ip_network('127.0.0.0')) 3 | info('has_ip_network(\'128.0.0.0\'):', has_ip_network('128.0.0.0')) 4 | 5 | -------------------------------------------------------------------------------- /modules/stdlib/tests/init.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | -------------------------------------------------------------------------------- /modules/vsftpd/ChangeLog: -------------------------------------------------------------------------------- 1 | 2013-07-22 - 0.1.3 2 | * Add 8 additional vsftpd.conf configuration options (Joshua Hoblitt). 3 | * Clean default parameters from false to undef for when they're not set. 4 | 5 | 2013-05-20 - 0.1.2 6 | * Update README and use markdown. 7 | * Change to 2-space indent. 8 | 9 | 2012-04-20 - 0.1.1 10 | * Add hide_file support. 11 | 12 | 2012-04-03 - 0.1.0 13 | * Clean up module for public release. 14 | 15 | -------------------------------------------------------------------------------- /modules/vsftpd/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011-2013 Matthias Saou 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | -------------------------------------------------------------------------------- /modules/vsftpd/Modulefile: -------------------------------------------------------------------------------- 1 | name 'thias-vsftpd' 2 | version '0.1.3' 3 | source 'git://github.com/thias/puppet-vsftpd' 4 | author 'Matthias Saou' 5 | license 'Apache 2.0' 6 | summary 'vsftpd FTP server' 7 | description "Install and enable the vsftpd FTP server, a secure and fast FTP 8 | server for UNIX-like systems." 9 | project_page 'https://github.com/thias/puppet-vsftpd' 10 | -------------------------------------------------------------------------------- /modules/vsftpd/README.md: -------------------------------------------------------------------------------- 1 | # puppet-vsftpd 2 | 3 | ## Overview 4 | 5 | This module enables and configures a vsftpd FTP server instance. 6 | 7 | * `vsftpd` : Enable and configure the vsftpd FTP server 8 | 9 | ## Examples 10 | 11 | With all of the module's default settings : 12 | 13 | include vsftpd 14 | 15 | Tweaking a few settings : 16 | 17 | class { 'vsftpd': 18 | anonymous_enable => 'NO', 19 | write_enable => 'YES', 20 | ftpd_banner => 'Marmotte FTP Server', 21 | chroot_local_user => 'YES', 22 | } 23 | 24 | -------------------------------------------------------------------------------- /modules/vsftpd/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_page": "https://github.com/thias/puppet-vsftpd", 3 | "license": "Apache 2.0", 4 | "source": "git://github.com/thias/puppet-vsftpd", 5 | "checksums": { 6 | "README.md": "7018ce8a1da5c975327ed866ed56fde2", 7 | "templates/vsftpd.conf.orig": "e9c7483434e90193a7c618c3691e22aa", 8 | "LICENSE": "99219472697a01561e7630d63aaecdc1", 9 | "manifests/init.pp": "094d1dafcbe2d35ec7587c3bea18943a", 10 | "Modulefile": "c4415660bf5ea7efb6ffa0a44daa0ae4", 11 | "ChangeLog": "9a475b32f6c94a0efb315696d030eeed", 12 | "templates/vsftpd.conf.erb": "75956b59ddf37a59199954177970a803", 13 | "tests/init.pp": "e4f59a341418a2b869778c9b629f53a4" 14 | }, 15 | "description": "Install and enable the vsftpd FTP server, a secure and fast FTP\n server for UNIX-like systems.", 16 | "version": "0.1.3", 17 | "types": [ 18 | 19 | ], 20 | "summary": "vsftpd FTP server", 21 | "name": "thias-vsftpd", 22 | "author": "Matthias Saou", 23 | "dependencies": [ 24 | 25 | ] 26 | } -------------------------------------------------------------------------------- /modules/vsftpd/tests/init.pp: -------------------------------------------------------------------------------- 1 | # Very basic test 2 | include vsftpd 3 | -------------------------------------------------------------------------------- /modules/wordpress/CHANGELOG: -------------------------------------------------------------------------------- 1 | 2013-06-17 Release 0.4.0 2 | Features: 3 | - Add `wordpress::wp_lang` parameter 4 | - Add `wordpress::wp_plugin_dir` parameter 5 | 6 | Bugfixes: 7 | - Add class anchors 8 | - Conditionalize directory management 9 | - Fix `@db_host` template variable 10 | 11 | 2012-12-31 Release 0.2.3 12 | Changes: 13 | - Remove Apache php configuration; that responsibility falls outside of this module. 14 | 15 | 2012-12-28 Release 0.2.2 16 | Bugfixes: 17 | - Pass required parameters 18 | 19 | 2012-12-28 Release 0.2.1 20 | Bugfixes: 21 | - Remove extraneous files from module. 22 | 23 | 2012-12-28 Release 0.2.0 24 | Changes: 25 | - Add `install_url` parameter to download tarball from other location 26 | 27 | 2012-12-28 Release 0.1.0 28 | - Initial rewrite from jonhadfield/master 29 | -------------------------------------------------------------------------------- /modules/wordpress/Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppet-wordpress' 2 | version '0.4.0' 3 | source 'https://github.com/hunner/puppet-wordpress' 4 | author 'Hunter Haugen' 5 | license 'Apache2' 6 | summary 'Puppet module to set up an instance of wordpress' 7 | description 'Installs wordpress and required mysql db/user.' 8 | project_page 'https://github.com/hunner/puppet-wordpress' 9 | 10 | ## Add dependencies, if any: 11 | dependency 'ripienaar/concat', '>= 0.2.0' 12 | dependency 'puppetlabs/mysql', '>= 0.5.0' 13 | dependency 'puppetlabs/stdlib', '>= 2.3.1' 14 | -------------------------------------------------------------------------------- /modules/wordpress/Rakefile: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/rake_tasks' 2 | -------------------------------------------------------------------------------- /modules/wordpress/manifests/db.pp: -------------------------------------------------------------------------------- 1 | class wordpress::db ( 2 | $create_db, 3 | $create_db_user, 4 | $db_name, 5 | $db_host, 6 | $db_user, 7 | $db_password, 8 | ) { 9 | validate_bool($create_db,$create_db_user) 10 | validate_string($db_name,$db_host,$db_user,$db_password) 11 | 12 | ## Set up DB using puppetlabs-mysql defined type 13 | if $create_db { 14 | database { $db_name: 15 | charset => 'utf8', 16 | require => Class['wordpress::app'], 17 | } 18 | } 19 | if $create_db_user { 20 | database_user { "${db_user}@${db_host}": 21 | password_hash => mysql_password($db_password), 22 | require => Class['wordpress::app'], 23 | } 24 | database_grant { "${db_user}@${db_host}/${db_name}": 25 | privileges => ['all'], 26 | require => Class['wordpress::app'], 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /modules/wordpress/spec/classes/wordpress_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'wordpress', :type => :class do 4 | context "on a RedHat 5 OS" do 5 | let :facts do 6 | { 7 | :osfamily => 'RedHat', 8 | :lsbmajdistrelease => '5', 9 | :concat_basedir => '/dne', 10 | } 11 | end 12 | it { should include_class("wordpress::app") } 13 | it { should include_class("wordpress::db") } 14 | end 15 | context "on a RedHat 6 OS" do 16 | let :facts do 17 | { 18 | :osfamily => 'RedHat', 19 | :lsbmajdistrelease => '6', 20 | :concat_basedir => '/dne', 21 | } 22 | end 23 | it { should include_class("wordpress::app") } 24 | it { should include_class("wordpress::db") } 25 | end 26 | context "on a Debian OS" do 27 | let :facts do 28 | { 29 | :osfamily => 'Debian', 30 | :concat_basedir => '/dne', 31 | } 32 | end 33 | it { should include_class("wordpress::app") } 34 | it { should include_class("wordpress::db") } 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /modules/wordpress/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --format s 2 | --colour 3 | --loadby mtime 4 | --backtrace 5 | -------------------------------------------------------------------------------- /modules/wordpress/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/module_spec_helper' 2 | -------------------------------------------------------------------------------- /modules/wordpress/templates/wp-keysalts.php.erb: -------------------------------------------------------------------------------- 1 | '); 12 | define('SECURE_AUTH_KEY', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 13 | define('LOGGED_IN_KEY', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 14 | define('NONCE_KEY', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 15 | define('AUTH_SALT', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 16 | define('SECURE_AUTH_SALT', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 17 | define('LOGGED_IN_SALT', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 18 | define('NONCE_SALT', '<%= (1..50).map{(rand(86)+40).chr}.join %>'); 19 | 20 | /**#@-*/ 21 | 22 | -------------------------------------------------------------------------------- /modules/wordpress/tests/init.pp: -------------------------------------------------------------------------------- 1 | class { 'wordpress': 2 | install_dir => '/var/www/wordpress', 3 | db_name => 'wordpress', 4 | db_host => 'localhost', 5 | db_user => 'wordpress', 6 | db_password => 'insecure password', 7 | } 8 | --------------------------------------------------------------------------------