├── .htaccess
├── LICENSE
├── README.md
├── config
└── config.ini
├── controllers
├── BaseController.php
├── Controller.php
├── ExampleController.php
└── RESTController.php
├── data
├── database.sqlite
└── princesses.sql
├── exceptions
└── HTTPException.php
├── index.php
├── models
└── Princess.php
├── responses
├── CSVResponse.php
├── JSONResponse.php
└── Response.php
├── routes
├── collections
│ └── example.php
└── routeLoader.php
└── vagrant-phalcon-rest
├── .vagrant
└── machines
│ └── default
│ └── virtualbox
│ └── id
├── README.md
├── Vagrantfile
├── composer.json
├── manifests
└── default.pp
├── modules
├── apache
│ ├── .fixtures.yml
│ ├── .gemfile
│ ├── .gitignore
│ ├── .project
│ ├── .travis.yml
│ ├── Modulefile
│ ├── README.md
│ ├── Rakefile
│ ├── manifests
│ │ ├── dotconf.pp
│ │ ├── htpasswd.pp
│ │ ├── init.pp
│ │ ├── module.pp
│ │ ├── params.pp
│ │ ├── passenger.pp
│ │ ├── redhat.pp
│ │ ├── spec.pp
│ │ ├── ssl.pp
│ │ ├── vhost.pp
│ │ └── virtualhost.pp
│ ├── spec
│ │ ├── classes
│ │ │ └── apache_spec.rb
│ │ ├── defines
│ │ │ └── apache_virtualhost_spec.rb
│ │ └── spec_helper.rb
│ ├── templates
│ │ ├── 00-NameVirtualHost.conf.erb
│ │ ├── module
│ │ │ └── proxy.conf.erb
│ │ ├── spec.erb
│ │ └── virtualhost
│ │ │ ├── vhost.conf.erb
│ │ │ └── virtualhost.conf.erb
│ └── tests
│ │ └── vhost.pp
├── apt
│ ├── .fixtures.yml
│ ├── .travis.yml
│ ├── CHANGELOG
│ ├── Gemfile
│ ├── LICENSE
│ ├── Modulefile
│ ├── README.md
│ ├── Rakefile
│ ├── manifests
│ │ ├── backports.pp
│ │ ├── builddep.pp
│ │ ├── conf.pp
│ │ ├── debian
│ │ │ ├── testing.pp
│ │ │ └── unstable.pp
│ │ ├── force.pp
│ │ ├── init.pp
│ │ ├── key.pp
│ │ ├── params.pp
│ │ ├── pin.pp
│ │ ├── ppa.pp
│ │ ├── release.pp
│ │ ├── source.pp
│ │ └── update.pp
│ ├── spec
│ │ ├── classes
│ │ │ ├── apt_spec.rb
│ │ │ ├── backports_spec.rb
│ │ │ ├── debian_testing_spec.rb
│ │ │ ├── debian_unstable_spec.rb
│ │ │ ├── params_spec.rb
│ │ │ └── release_spec.rb
│ │ ├── defines
│ │ │ ├── builddep_spec.rb
│ │ │ ├── conf_spec.rb
│ │ │ ├── force_spec.rb
│ │ │ ├── key_spec.rb
│ │ │ ├── pin_spec.rb
│ │ │ ├── ppa_spec.rb
│ │ │ └── source_spec.rb
│ │ ├── fixtures
│ │ │ └── manifests
│ │ │ │ └── site.pp
│ │ └── spec_helper.rb
│ ├── templates
│ │ ├── pin.pref.erb
│ │ └── source.list.erb
│ └── tests
│ │ ├── builddep.pp
│ │ ├── debian
│ │ ├── testing.pp
│ │ └── unstable.pp
│ │ ├── force.pp
│ │ ├── init.pp
│ │ ├── key.pp
│ │ ├── params.pp
│ │ ├── pin.pp
│ │ ├── ppa.pp
│ │ ├── release.pp
│ │ └── source.pp
├── build
│ └── manifests
│ │ ├── init.pp
│ │ ├── install.pp
│ │ └── requires.pp
├── concat
│ ├── .fixtures.yml
│ ├── .gemfile
│ ├── .travis.yml
│ ├── CHANGELOG
│ ├── LICENSE
│ ├── Modulefile
│ ├── README.markdown
│ ├── Rakefile
│ ├── files
│ │ └── concatfragments.sh
│ ├── lib
│ │ └── facter
│ │ │ └── concat_basedir.rb
│ ├── manifests
│ │ ├── fragment.pp
│ │ ├── init.pp
│ │ └── setup.pp
│ └── spec
│ │ ├── defines
│ │ └── init_spec.rb
│ │ ├── fixtures
│ │ └── manifests
│ │ │ └── site.pp
│ │ └── spec_helper.rb
├── git
│ ├── CONTRIBUTING.markdown
│ ├── Modulefile
│ ├── README.markdown
│ ├── gpl.txt
│ ├── manifests
│ │ ├── init.pp
│ │ ├── install.pp
│ │ ├── params.pp
│ │ ├── repo.pp
│ │ └── user.pp
│ ├── metadata.json
│ ├── spec
│ │ ├── spec.opts
│ │ └── spec_helper.rb
│ └── tests
│ │ └── init.pp
├── mysql
│ ├── .fixtures.yml
│ ├── .gemfile
│ ├── .travis.yml
│ ├── Modulefile
│ ├── README.md
│ ├── Rakefile
│ ├── manifests
│ │ ├── augeas.pp
│ │ ├── client.pp
│ │ ├── grant.pp
│ │ ├── init.pp
│ │ ├── params.pp
│ │ ├── password.pp
│ │ ├── query.pp
│ │ ├── queryfile.pp
│ │ ├── spec.pp
│ │ └── user.pp
│ ├── spec
│ │ ├── classes
│ │ │ └── mysql_spec.rb
│ │ ├── spec.opts
│ │ └── spec_helper.rb
│ └── templates
│ │ ├── grant.erb
│ │ ├── query.erb
│ │ ├── root.my.cnf.backup.erb
│ │ ├── root.my.cnf.erb
│ │ ├── spec.erb
│ │ └── user.erb
├── php
│ ├── .fixtures.yml
│ ├── .gemfile
│ ├── .travis.yml
│ ├── Modulefile
│ ├── README.md
│ ├── Rakefile
│ ├── lib
│ │ └── facter
│ │ │ ├── php_fact_extension_dir.rb
│ │ │ └── php_fact_version.rb
│ ├── manifests
│ │ ├── augeas.pp
│ │ ├── composer.pp
│ │ ├── composer
│ │ │ └── run.pp
│ │ ├── custom
│ │ │ └── xhprof.pp
│ │ ├── devel.pp
│ │ ├── ini.pp
│ │ ├── ini
│ │ │ └── removeblock.pp
│ │ ├── init.pp
│ │ ├── module.pp
│ │ ├── params.pp
│ │ ├── pear.pp
│ │ ├── pear
│ │ │ ├── config.pp
│ │ │ └── module.pp
│ │ ├── pecl
│ │ │ └── module.pp
│ │ └── spec.pp
│ ├── spec
│ │ ├── classes
│ │ │ └── php_spec.rb
│ │ └── spec_helper.rb
│ └── templates
│ │ ├── extra-ini.erb
│ │ └── spec.erb
├── puphpet
│ └── files
│ │ └── dot
│ │ └── .bash_aliases
├── puppi
│ ├── .fixtures.yml
│ ├── .gemfile
│ ├── .travis.yml
│ ├── Modulefile
│ ├── README.md
│ ├── README_check.md
│ ├── README_deploy.md
│ ├── README_info.md
│ ├── README_log.md
│ ├── Rakefile
│ ├── composer.json
│ ├── files
│ │ ├── info
│ │ │ └── readme
│ │ │ │ ├── readme
│ │ │ │ └── readme-default
│ │ ├── mailpuppicheck
│ │ ├── mcollective
│ │ │ ├── mc-puppi
│ │ │ ├── puppi.ddl
│ │ │ ├── puppi.rb
│ │ │ ├── puppicheck
│ │ │ └── puppideploy
│ │ └── scripts
│ │ │ ├── archive.sh
│ │ │ ├── check_project.sh
│ │ │ ├── checkwardir.sh
│ │ │ ├── clean_filelist.sh
│ │ │ ├── database.sh
│ │ │ ├── delete.sh
│ │ │ ├── deploy.sh
│ │ │ ├── deploy_files.sh
│ │ │ ├── execute.sh
│ │ │ ├── firewall.sh
│ │ │ ├── functions
│ │ │ ├── get_file.sh
│ │ │ ├── get_filesfromlist.sh
│ │ │ ├── get_maven_files.sh
│ │ │ ├── get_metadata.sh
│ │ │ ├── git.sh
│ │ │ ├── header
│ │ │ ├── predeploy.sh
│ │ │ ├── predeploy_tar.sh
│ │ │ ├── report_mail.sh
│ │ │ ├── report_mongo.sh
│ │ │ ├── service.sh
│ │ │ ├── svn.sh
│ │ │ ├── wait.sh
│ │ │ ├── yant.sh
│ │ │ └── yum.sh
│ ├── lib
│ │ ├── facter
│ │ │ ├── last_run.rb
│ │ │ └── puppi_projects.rb
│ │ └── puppet
│ │ │ └── parser
│ │ │ └── functions
│ │ │ ├── any2bool.rb
│ │ │ ├── bool2ensure.rb
│ │ │ ├── get_class_args.rb
│ │ │ ├── get_magicvar.rb
│ │ │ ├── is_array.rb
│ │ │ ├── options_lookup.rb
│ │ │ ├── params_lookup.rb
│ │ │ └── url_parse.rb
│ ├── manifests
│ │ ├── check.pp
│ │ ├── dependencies.pp
│ │ ├── deploy.pp
│ │ ├── extras.pp
│ │ ├── helper.pp
│ │ ├── helpers.pp
│ │ ├── info.pp
│ │ ├── info
│ │ │ ├── instance.pp
│ │ │ ├── module.pp
│ │ │ └── readme.pp
│ │ ├── init.pp
│ │ ├── initialize.pp
│ │ ├── log.pp
│ │ ├── mcollective
│ │ │ ├── client.pp
│ │ │ └── server.pp
│ │ ├── netinstall.pp
│ │ ├── one.pp
│ │ ├── params.pp
│ │ ├── project.pp
│ │ ├── project
│ │ │ ├── README
│ │ │ ├── archive.pp
│ │ │ ├── builder.pp
│ │ │ ├── dir.pp
│ │ │ ├── files.pp
│ │ │ ├── git.pp
│ │ │ ├── maven.pp
│ │ │ ├── mysql.pp
│ │ │ ├── service.pp
│ │ │ ├── svn.pp
│ │ │ ├── tar.pp
│ │ │ ├── war.pp
│ │ │ ├── y4maven.pp
│ │ │ └── yum.pp
│ │ ├── report.pp
│ │ ├── rollback.pp
│ │ ├── run.pp
│ │ ├── skel.pp
│ │ ├── todo.pp
│ │ ├── two.pp
│ │ └── ze.pp
│ ├── spec
│ │ ├── classes
│ │ │ └── puppi_spec.rb
│ │ ├── defines
│ │ │ ├── puppi_check_spec.rb
│ │ │ ├── puppi_deploy_spec.rb
│ │ │ ├── puppi_helper_spec.rb
│ │ │ ├── puppi_info_spec.rb
│ │ │ ├── puppi_initialize_spec.rb
│ │ │ ├── puppi_log_spec.rb
│ │ │ ├── puppi_project_spec.rb
│ │ │ ├── puppi_report_spec.rb
│ │ │ ├── puppi_rollback_spec.rb
│ │ │ ├── puppi_run_spec.rb
│ │ │ ├── puppi_todo_spec.rb
│ │ │ └── puppi_ze_spec.rb
│ │ ├── functions
│ │ │ ├── any2bool_spec.rb
│ │ │ ├── bool2ensure_spec.rb
│ │ │ └── url_parse_spec.rb
│ │ └── spec_helper.rb
│ └── templates
│ │ ├── helpers
│ │ └── standard.yml.erb
│ │ ├── info.erb
│ │ ├── info
│ │ ├── instance.erb
│ │ ├── module.erb
│ │ ├── puppet.erb
│ │ └── readme.erb
│ │ ├── log.erb
│ │ ├── project
│ │ └── config.erb
│ │ ├── puppi.conf.erb
│ │ ├── puppi.erb
│ │ └── todo.erb
├── stdlib
│ ├── .gemspec
│ ├── .rspec
│ ├── .travis.yml
│ ├── CHANGELOG
│ ├── CONTRIBUTING.md
│ ├── Gemfile
│ ├── LICENSE
│ ├── Modulefile
│ ├── README.markdown
│ ├── README_DEVELOPER.markdown
│ ├── README_SPECS.markdown
│ ├── RELEASE_PROCESS.markdown
│ ├── Rakefile
│ ├── lib
│ │ ├── facter
│ │ │ ├── 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
│ │ │ │ ├── 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
│ ├── spec
│ │ ├── classes
│ │ │ └── anchor_spec.rb
│ │ ├── 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_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
│ │ │ │ │ ├── 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
└── xdebug
│ ├── README.md
│ ├── files
│ └── cli_alias.erb
│ ├── manifests
│ ├── config.pp
│ └── init.pp
│ └── templates
│ └── ini_file.erb
└── shell
└── phalcon.sh
/.htaccess:
--------------------------------------------------------------------------------
1 | ### CORS HEADERS ###
2 | ### Deprecated in favor of explicit Options Routes in RESTController.php ###
3 |
4 | # This has to be allowed per-referer if credentials are used.
5 | # Useful here for dev, but should be set programatically for production.
6 | # Header add Access-Control-Allow-Origin "*"
7 |
8 | # Again, these are useful for dev, but bad for production
9 | # Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
10 | # Header add Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD"
11 |
12 | # Allows for Basic auth
13 | # Header add Access-Control-Allow-Credentials: true
14 |
15 | # Preflight only has to be made every 24 hours per resource
16 | # Header add Access-Control-Max-Age: 86400
17 |
18 | ### URL REWRITE TO index.php ###
19 |
20 | # Only ever allow requests to the index page,
21 | # No other files should ever be served by this directory.
22 | # Assets must live on another subdomain, in another location.
23 | RewriteEngine On
24 | RewriteCond %{REQUEST_URI} !=/v1/index.php
25 | RewriteRule (.*)$ index.php?_url=/$1 [QSA,L]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) {{year}} {{fullname}}
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/config/config.ini:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmoore4/phalcon-rest/ceb4cee9e4b278e8fae8a0b2658009580320a22b/config/config.ini
--------------------------------------------------------------------------------
/controllers/BaseController.php:
--------------------------------------------------------------------------------
1 | setDI($di);
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/controllers/Controller.php:
--------------------------------------------------------------------------------
1 | setDI($di);
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/data/database.sqlite:
--------------------------------------------------------------------------------
1 | CREATE TABLE princesses
2 | (id INTEGER NOT NULL,
3 | name VARCHAR(64) NOT NULL,
4 | married INTEGER,
5 | birth_year TEXT(25) DEFAULT '1900-01-01 00:00:00',
6 | PRIMARY KEY (id),
7 | UNIQUE (name));
8 |
9 |
10 |
--------------------------------------------------------------------------------
/data/princesses.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE princesses (
2 | id INTEGER NOT NULL,
3 | name VARCHAR(64) NOT NULL,
4 | married INTEGER, -- This is a boolean
5 | birth_date TEXT(25) DEFAULT '1900-01-01 00:00:00', --SQLite3 users text fields to store dates
6 | deleted INTEGER DEFAULT 0,
7 | last_change TEXT(25) DEFAULT now()
8 | PRIMARY KEY (id),
9 | UNIQUE (name)
10 | );
11 |
12 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('1', 'Jasmine', '0', '0200-05-05 13:14:15');
13 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('2', 'Ariel', '0', '1825-06-05 13:00:10');
14 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('3', 'Nala', '0', '1532-05-12 09:10:10');
15 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('4', 'Belle', '1', '1804-12-23 00:53:30');
16 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('5', 'Mulan', '0', '0386-01-20 22:32:12');
17 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('6', 'Rapunzel', '0', '1299-10-13 20:31:19');
18 | INSERT INTO princesses(id, name, married, birth_year) VALUES ('7', 'Tiana', '1', '1893-09-12 15:25:25');
--------------------------------------------------------------------------------
/routes/routeLoader.php:
--------------------------------------------------------------------------------
1 | "shell/phalcon.sh"
22 | end
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jtreminio/vagrant-puppet-lamp",
3 | "type": "project",
4 | "description": "Non-PHP! Everything you need to get a LAMP-based Puppet/Vagrant VM up and running in seconds!",
5 | "keywords": ["puppet", "vagrant", "vm", "virtual machine", "lamp"],
6 | "homepage": "https://github.com/jtreminio/vagrant-puppet-lamp",
7 | "license": "MIT",
8 | "authors": [
9 | {
10 | "name": "Juan Treminio",
11 | "email": "jtreminio@gmail.com",
12 | "homepage": "https://jtreminio.com"
13 | }
14 | ],
15 | "extra": {
16 | "branch-alias": {
17 | "dev-master": "1.x-dev"
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | repositories:
3 | "puppi": "git://github.com/example42/puppi.git"
4 | "monitor": "git://github.com/example42/puppet-monitor.git"
5 | "firewall": "git://github.com/example42/puppet-firewall.git"
6 | "iptables": "git://github.com/example42/puppet-iptables.git"
7 | "concat": "git://github.com/example42/puppet-concat.git"
8 | symlinks:
9 | "apache": "#{source_dir}"
10 |
11 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/.gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | puppetversion = ENV['PUPPET_VERSION']
4 | gem 'puppet', puppetversion, :require => false
5 | gem 'puppet-lint'
6 | gem 'puppetlabs_spec_helper', '>= 0.1.0'
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /metadata.json
3 | /.rvmrc
4 | build
5 | pkg/
6 | Session.vim
7 | spec/fixtures
8 | .*.sw[a-z]
9 | *.un~
10 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | apache
4 |
5 |
6 |
7 |
8 |
9 | org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.xtext.ui.shared.xtextBuilder
15 |
16 |
17 |
18 |
19 |
20 | org.cloudsmith.geppetto.pp.dsl.ui.puppetNature
21 | org.eclipse.xtext.ui.shared.xtextNature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.8.7
4 | - 1.9.3
5 | script:
6 | - "rake spec SPEC_OPTS='--format documentation'"
7 | env:
8 | - PUPPET_VERSION="~> 2.6.0"
9 | - PUPPET_VERSION="~> 2.7.0"
10 | - PUPPET_VERSION="~> 3.0.0"
11 | - PUPPET_VERSION="~> 3.1.0"
12 | matrix:
13 | exclude:
14 | - rvm: 1.9.3
15 | env: PUPPET_VERSION="~> 2.6.0"
16 | gemfile: .gemfile
17 |
18 | gemfile: .gemfile
19 | notifications:
20 | email:
21 | - al@lab42.it
22 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/Modulefile:
--------------------------------------------------------------------------------
1 | name 'example42-apache'
2 | version '2.0.8'
3 |
4 | author 'Alessandro Franceschi'
5 | license 'Apache2'
6 | project_page 'http://www.example42.com'
7 | source 'https://github.com/example42/puppet-apache'
8 | summary 'Puppet module for apache'
9 | description 'This module installs and manages apache. Check README.rdoc for details. Puppi is required for some common functions: you can install them without using the whole module. Monitor and firewall dependencies are needed only if the relevant features are enabled'
10 | dependency 'example42/puppi', '>=2.0.0'
11 | dependency 'example42/yum', '>=2.0.0'
12 | dependency 'example42/firewall', '>=2.0.0'
13 | dependency 'example42/monitor', '>=2.0.0'
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'puppetlabs_spec_helper/rake_tasks'
3 | require 'puppet-lint'
4 | PuppetLint.configuration.send("disable_80chars")
5 | PuppetLint.configuration.send('disable_class_parameter_defaults')
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/manifests/passenger.pp:
--------------------------------------------------------------------------------
1 | # Class apache::passenger
2 | #
3 | # Apache resources specific for passenger
4 | #
5 | class apache::passenger {
6 |
7 | include apache
8 |
9 | case $::operatingsystem {
10 | ubuntu,debian,mint: {
11 | package { 'libapache2-mod-passenger':
12 | ensure => present;
13 | }
14 |
15 | exec { 'enable-passenger':
16 | command => '/usr/sbin/a2enmod passenger',
17 | creates => '/etc/apache2/mods-enabled/passenger.load',
18 | notify => Service['apache'],
19 | require => [
20 | Package['apache'],
21 | Package['libapache2-mod-passenger']
22 | ],
23 | }
24 | }
25 |
26 | centos,redhat,scientific,fedora: {
27 | $osver = split($::operatingsystemrelease, '[.]')
28 |
29 | case $osver[0] {
30 | 5: { require yum::repo::passenger }
31 | default: { }
32 | }
33 | package { 'mod_passenger':
34 | ensure => present;
35 | }
36 | }
37 |
38 | default: { }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/manifests/redhat.pp:
--------------------------------------------------------------------------------
1 | # Class apache::redhat
2 | #
3 | # Apache resources specific for RedHat
4 | #
5 | class apache::redhat {
6 | apache::dotconf { '00-NameVirtualHost':
7 | content => template('apache/00-NameVirtualHost.conf.erb'),
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/manifests/spec.pp:
--------------------------------------------------------------------------------
1 | # Class: apache::spec
2 | #
3 | # This class is used only for rpsec-puppet tests
4 | # Can be taken as an example on how to do custom classes but should not
5 | # be modified.
6 | #
7 | # == Usage
8 | #
9 | # This class is not intended to be used directly.
10 | # Use it as reference
11 | #
12 | class apache::spec inherits apache {
13 |
14 | # This just a test to override the arguments of an existing resource
15 | # Note that you can achieve this same result with just:
16 | # class { "apache": template => "apache/spec.erb" }
17 |
18 | File['apache.conf'] {
19 | content => template('apache/spec.erb'),
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/module_spec_helper'
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/templates/00-NameVirtualHost.conf.erb:
--------------------------------------------------------------------------------
1 | # File managed by Puppet
2 |
3 | NameVirtualHost *:80
4 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/templates/module/proxy.conf.erb:
--------------------------------------------------------------------------------
1 | # File Managed by Puppet
2 |
3 |
4 |
5 | # This is not a forwared proxy
6 | ProxyRequests Off
7 |
8 |
9 | AddDefaultCharset off
10 | Order deny,allow
11 | Deny from all
12 | Allow from all
13 |
14 |
15 | ProxyVia On
16 |
17 |
18 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/templates/spec.erb:
--------------------------------------------------------------------------------
1 | # This is a template used only for rspec tests
2 |
3 | # Yaml of the whole scope
4 | <%= scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }.to_yaml %>
5 |
6 | # Custom Options
7 | <%= @options['opt_a'] %>
8 | <%= @options['opt_b'] %>
9 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/templates/virtualhost/virtualhost.conf.erb:
--------------------------------------------------------------------------------
1 | # File Managed by Puppet
2 |
3 |
4 | ServerAdmin webmaster@<%= @name %>
5 | DocumentRoot <%= @real_documentroot %>
6 | ServerName <%= @name %>
7 | <% if @aliases != "" -%>
8 | <% if @aliases.is_a? Array -%>
9 | ServerAlias <%= @aliases.flatten.join(" ") %>
10 | <% else -%>
11 | ServerAlias <%= @aliases %>
12 | <% end -%>
13 | <% end -%>
14 | ErrorLog <%= scope.lookupvar('apache::log_dir')%>/<%= @name %>-error_log
15 | CustomLog <%= scope.lookupvar('apache::log_dir')%>/<%= @name %>-access_log common
16 |
17 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apache/tests/vhost.pp:
--------------------------------------------------------------------------------
1 | include apache
2 |
3 | apache::vhost { 'testsite':
4 | docroot => '/var/www/test',
5 | env_variables => ['APP_ENV dev'],
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | repositories:
3 | "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
4 | symlinks:
5 | "apt": "#{source_dir}"
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | bundler_args: --without development
3 | script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
4 | rvm:
5 | - 1.8.7
6 | - 1.9.3
7 | - ruby-head
8 | env:
9 | - PUPPET_GEM_VERSION="~> 2.6.0"
10 | - PUPPET_GEM_VERSION="~> 2.7.0"
11 | - PUPPET_GEM_VERSION="~> 3.0.0"
12 | - PUPPET_GEM_VERSION="~> 3.1.0"
13 | matrix:
14 | allow_failures:
15 | - rvm: ruby-head
16 | exclude:
17 | - rvm: 1.9.3
18 | env: PUPPET_GEM_VERSION="~> 2.7.0"
19 | - rvm: ruby-head
20 | env: PUPPET_GEM_VERSION="~> 2.7.0"
21 | - rvm: 1.9.3
22 | env: PUPPET_GEM_VERSION="~> 2.6.0"
23 | - rvm: ruby-head
24 | env: PUPPET_GEM_VERSION="~> 2.6.0"
25 | notifications:
26 | email: false
27 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/Gemfile:
--------------------------------------------------------------------------------
1 | source :rubygems
2 |
3 | group :development, :test do
4 | gem 'puppetlabs_spec_helper', :require => false
5 | end
6 |
7 | if puppetversion = ENV['PUPPET_GEM_VERSION']
8 | gem 'puppet', puppetversion, :require => false
9 | else
10 | gem 'puppet', :require => false
11 | end
12 |
13 | # vim:ft=ruby
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Evolving Web Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/Modulefile:
--------------------------------------------------------------------------------
1 | name 'puppetlabs-apt'
2 | version '1.1.0'
3 | source 'https://github.com/puppetlabs/puppetlabs-apt'
4 | author 'Evolving Web / Puppet Labs'
5 | license 'Apache License 2.0'
6 | summary 'Puppet Labs Apt Module'
7 | description 'APT Module for Puppet'
8 | project_page 'https://github.com/puppetlabs/puppetlabs-apt'
9 |
10 | ## Add dependencies, if any:
11 | #dependency 'puppetlabs/stdlib', '2.x'
12 | # The dependency should be written as above but librarian-puppet
13 | # does not support the expression as the PMT does.
14 | dependency 'puppetlabs/stdlib', '>= 2.2.1'
15 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/Rakefile:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/rake_tasks'
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/builddep.pp:
--------------------------------------------------------------------------------
1 | # builddep.pp
2 |
3 | define apt::builddep() {
4 | include apt::update
5 |
6 | exec { "apt-builddep-${name}":
7 | command => "/usr/bin/apt-get -y --force-yes build-dep ${name}",
8 | logoutput => 'on_failure',
9 | notify => Exec['apt_update'],
10 | }
11 |
12 | # Need anchor to provide containment for dependencies.
13 | anchor { "apt::builddep::${name}":
14 | require => Class['apt::update'],
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/conf.pp:
--------------------------------------------------------------------------------
1 | define apt::conf (
2 | $content,
3 | $ensure = present,
4 | $priority = '50'
5 | ) {
6 |
7 | include apt::params
8 |
9 | $apt_conf_d = $apt::params::apt_conf_d
10 |
11 | file { "${apt_conf_d}/${priority}${name}":
12 | ensure => $ensure,
13 | content => $content,
14 | owner => root,
15 | group => root,
16 | mode => '0644',
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/debian/testing.pp:
--------------------------------------------------------------------------------
1 | # testing.pp
2 |
3 | class apt::debian::testing {
4 | include apt
5 |
6 | # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
7 | # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
8 | # Key: 55BE302B Server: subkeys.pgp.net
9 | # debian-keyring
10 | # debian-archive-keyring
11 |
12 | apt::source { 'debian_testing':
13 | location => 'http://debian.mirror.iweb.ca/debian/',
14 | release => 'testing',
15 | repos => 'main contrib non-free',
16 | required_packages => 'debian-keyring debian-archive-keyring',
17 | key => '55BE302B',
18 | key_server => 'subkeys.pgp.net',
19 | pin => '-10',
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/debian/unstable.pp:
--------------------------------------------------------------------------------
1 | # unstable.pp
2 |
3 | class apt::debian::unstable {
4 | include apt
5 |
6 | # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free
7 | # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free
8 | # Key: 55BE302B Server: subkeys.pgp.net
9 | # debian-keyring
10 | # debian-archive-keyring
11 |
12 | apt::source { 'debian_unstable':
13 | location => 'http://debian.mirror.iweb.ca/debian/',
14 | release => 'unstable',
15 | repos => 'main contrib non-free',
16 | required_packages => 'debian-keyring debian-archive-keyring',
17 | key => '55BE302B',
18 | key_server => 'subkeys.pgp.net',
19 | pin => '-10',
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/force.pp:
--------------------------------------------------------------------------------
1 | # force.pp
2 | # force a package from a specific release
3 |
4 | define apt::force(
5 | $release = 'testing',
6 | $version = false,
7 | $timeout = 300
8 | ) {
9 |
10 | $version_string = $version ? {
11 | false => undef,
12 | default => "=${version}",
13 | }
14 |
15 | $install_check = $version ? {
16 | false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'",
17 | default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'",
18 | }
19 | exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}":
20 | unless => $install_check,
21 | logoutput => 'on_failure',
22 | timeout => $timeout,
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/params.pp:
--------------------------------------------------------------------------------
1 | class apt::params {
2 | $root = '/etc/apt'
3 | $provider = '/usr/bin/apt-get'
4 | $sources_list_d = "${root}/sources.list.d"
5 | $apt_conf_d = "${root}/apt.conf.d"
6 | $preferences_d = "${root}/preferences.d"
7 |
8 | case $::lsbdistid {
9 | 'debian': {
10 | $backports_location = 'http://backports.debian.org/debian-backports'
11 | }
12 | 'ubuntu': {
13 | case $::lsbdistcodename {
14 | 'hardy','lucid','maverick','natty','oneiric','precise': {
15 | $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
16 | }
17 | default: {
18 | $backports_location = 'http://old-releases.ubuntu.com/ubuntu'
19 | }
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/release.pp:
--------------------------------------------------------------------------------
1 | # release.pp
2 |
3 | class apt::release (
4 | $release_id
5 | ) {
6 |
7 | include apt::params
8 |
9 | $root = $apt::params::root
10 |
11 | file { "${root}/apt.conf.d/01release":
12 | owner => root,
13 | group => root,
14 | mode => '0644',
15 | content => "APT::Default-Release \"${release_id}\";"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/manifests/update.pp:
--------------------------------------------------------------------------------
1 | class apt::update {
2 | include apt::params
3 |
4 | exec { 'apt_update':
5 | command => "${apt::params::provider} update",
6 | logoutput => 'on_failure',
7 | refreshonly => true,
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/classes/debian_testing_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | describe 'apt::debian::testing', :type => :class do
3 | it {
4 | should contain_apt__source("debian_testing").with({
5 | "location" => "http://debian.mirror.iweb.ca/debian/",
6 | "release" => "testing",
7 | "repos" => "main contrib non-free",
8 | "required_packages" => "debian-keyring debian-archive-keyring",
9 | "key" => "55BE302B",
10 | "key_server" => "subkeys.pgp.net",
11 | "pin" => "-10"
12 | })
13 | }
14 | end
15 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/classes/debian_unstable_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | describe 'apt::debian::unstable', :type => :class do
3 | it {
4 | should contain_apt__source("debian_unstable").with({
5 | "location" => "http://debian.mirror.iweb.ca/debian/",
6 | "release" => "unstable",
7 | "repos" => "main contrib non-free",
8 | "required_packages" => "debian-keyring debian-archive-keyring",
9 | "key" => "55BE302B",
10 | "key_server" => "subkeys.pgp.net",
11 | "pin" => "-10"
12 | })
13 | }
14 | end
15 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/classes/params_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | describe 'apt::params', :type => :class do
3 | let (:title) { 'my_package' }
4 |
5 | it { should contain_apt__params }
6 |
7 | # There are 4 resources in this class currently
8 | # there should not be any more resources because it is a params class
9 | # The resources are class[apt::params], class[main], class[settings], stage[main]
10 | it "Should not contain any resources" do
11 | subject.resources.size.should == 4
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/classes/release_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | describe 'apt::release', :type => :class do
3 | let (:title) { 'my_package' }
4 |
5 | let :param_set do
6 | { :release_id => 'precise' }
7 | end
8 |
9 | let (:params) { param_set }
10 |
11 | it { should include_class("apt::params") }
12 |
13 | it {
14 | should contain_file("/etc/apt/apt.conf.d/01release").with({
15 | "mode" => "0644",
16 | "owner" => "root",
17 | "group" => "root",
18 | "content" => "APT::Default-Release \"#{param_set[:release_id]}\";"
19 | })
20 | }
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/defines/builddep_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | describe 'apt::builddep', :type => :define do
3 |
4 | let(:title) { 'my_package' }
5 |
6 | describe "should require apt-get update" do
7 | it { should contain_exec("apt_update").with({
8 | 'command' => "/usr/bin/apt-get update",
9 | 'refreshonly' => true
10 | })
11 | }
12 | it { should contain_anchor("apt::builddep::my_package").with({
13 | 'require' => 'Class[Apt::Update]',
14 | })
15 | }
16 | end
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/fixtures/manifests/site.pp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmoore4/phalcon-rest/ceb4cee9e4b278e8fae8a0b2658009580320a22b/vagrant-phalcon-rest/modules/apt/spec/fixtures/manifests/site.pp
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/module_spec_helper'
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/templates/pin.pref.erb:
--------------------------------------------------------------------------------
1 | # <%= name %>
2 | Explanation: <%= explanation %>
3 | Package: <%= packages %>
4 | Pin: <%= pin %>
5 | Pin-Priority: <%= priority %>
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/templates/source.list.erb:
--------------------------------------------------------------------------------
1 | # <%= name %>
2 | deb <%= location %> <%= release_real %> <%= repos %>
3 | <%- if include_src then -%>
4 | deb-src <%= location %> <%= release_real %> <%= repos %>
5 | <%- end -%>
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/builddep.pp:
--------------------------------------------------------------------------------
1 | class { 'apt': }
2 | apt::builddep{ 'glusterfs-server': }
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/debian/testing.pp:
--------------------------------------------------------------------------------
1 | class { 'apt': }
2 | class { 'apt::debian::testing': }
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/debian/unstable.pp:
--------------------------------------------------------------------------------
1 | class { 'apt': }
2 | class { 'apt::debian::unstable': }
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/force.pp:
--------------------------------------------------------------------------------
1 | # force.pp
2 | # force a package from a specific release
3 |
4 | apt::force { 'package':
5 | release => 'testing',
6 | version => false
7 | }
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/init.pp:
--------------------------------------------------------------------------------
1 | class { 'apt': }
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/key.pp:
--------------------------------------------------------------------------------
1 | # Declare Apt key for apt.puppetlabs.com source
2 | apt::key { 'puppetlabs':
3 | key => '4BD6EC30',
4 | key_server => 'pgp.mit.edu',
5 | }
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/params.pp:
--------------------------------------------------------------------------------
1 | include apt::params
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/pin.pp:
--------------------------------------------------------------------------------
1 | # pin a release in apt, useful for unstable repositories
2 | apt::pin { 'foo':
3 | packages => '*',
4 | priority => 0,
5 | }
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/ppa.pp:
--------------------------------------------------------------------------------
1 | class { 'apt': }
2 |
3 | # Example declaration of an Apt PPA
4 | apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': }
5 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/release.pp:
--------------------------------------------------------------------------------
1 | class { 'apt': }
2 | class { 'apt::release':
3 | release_id => 'karmic'
4 | }
5 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/apt/tests/source.pp:
--------------------------------------------------------------------------------
1 | # Declare the apt class to manage /etc/apt/sources.list and /etc/sources.list.d
2 | class { 'apt': }
3 |
4 | # Install the puppetlabs apt source
5 | # Release is automatically obtained from lsbdistcodename fact if available.
6 | apt::source { 'puppetlabs':
7 | location => 'http://apt.puppetlabs.com',
8 | repos => 'main',
9 | key => '4BD6EC30',
10 | key_server => 'pgp.mit.edu',
11 | }
12 |
13 | # test two sources with the same key
14 | apt::source { 'debian_testing':
15 | location => 'http://debian.mirror.iweb.ca/debian/',
16 | release => 'testing',
17 | repos => 'main contrib non-free',
18 | key => '55BE302B',
19 | key_server => 'subkeys.pgp.net',
20 | pin => '-10',
21 | }
22 | apt::source { 'debian_unstable':
23 | location => 'http://debian.mirror.iweb.ca/debian/',
24 | release => 'unstable',
25 | repos => 'main contrib non-free',
26 | key => '55BE302B',
27 | key_server => 'subkeys.pgp.net',
28 | pin => '-10',
29 | }
30 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/build/manifests/init.pp:
--------------------------------------------------------------------------------
1 | class build {}
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/build/manifests/install.pp:
--------------------------------------------------------------------------------
1 | define build::install (
2 | $folder,
3 | $buildoptions = '',
4 | $make_cmd = '',
5 | $rm_build_folder = true
6 | ) {
7 |
8 | build::requires { "${name}-requires-build-essential" :
9 | package => 'build-essential'
10 | }
11 |
12 | $cwd = '/usr/local/src'
13 | $test = '/usr/bin/test'
14 |
15 | $make = $make_cmd ? {
16 | '' => 'make && make install',
17 | default => $make_cmd,
18 | }
19 |
20 | exec { "config-${name}" :
21 | cwd => $folder,
22 | command => $buildoptions,
23 | timeout => 120,
24 | onlyif => "/usr/bin/test ! -e /usr/lib/php5/20100525/xhprof.so",
25 | }
26 |
27 | exec { "make-install-${name}" :
28 | cwd => $folder,
29 | command => $make,
30 | path => '/bin:/sbin:/usr/bin:/usr/sbin',
31 | timeout => 600,
32 | require => Exec["config-${name}"],
33 | onlyif => "/usr/bin/test ! -e /usr/lib/php5/20100525/xhprof.so",
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/build/manifests/requires.pp:
--------------------------------------------------------------------------------
1 | define build::requires (
2 | $ensure = 'installed',
3 | $package
4 | ) {
5 |
6 | if defined( Package[$package] ) {
7 | debug("${package} already installed")
8 | } else {
9 | package { $package:
10 | ensure => $ensure
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/concat/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | symlinks:
3 | 'concat': '#{source_dir}'
4 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/concat/.gemfile:
--------------------------------------------------------------------------------
1 | source :rubygems
2 |
3 | puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
4 | gem 'puppet', puppetversion
5 | gem 'puppet-lint'
6 | gem 'rspec-puppet'
7 | gem 'puppetlabs_spec_helper', '>= 0.1.0'
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/concat/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.8.7
4 | script:
5 | - "rake lint"
6 | - "rake spec"
7 | branches:
8 | only:
9 | - master
10 | env:
11 | - PUPPET_VERSION=2.7.11
12 | gemfile: .gemfile
13 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/concat/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'puppetlabs_spec_helper/rake_tasks'
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/concat/spec/fixtures/manifests/site.pp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cmoore4/phalcon-rest/ceb4cee9e4b278e8fae8a0b2658009580320a22b/vagrant-phalcon-rest/modules/concat/spec/fixtures/manifests/site.pp
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/concat/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/module_spec_helper'
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/CONTRIBUTING.markdown:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Welcome to my stuff, really, take it, it's GPL. Just remember to attribute it back to me. If your changes are visible to on GitHub, I'll pull features back from your forks when the look good.
4 |
5 | I'll also consider Pull Requests via GitHub, but please target them on to the `pull_here` branch rather than to `master`, this gives me a chance to check them out and deal with silly issues, like how my IDE used to put hard tabs in everything when I really wanted spaces.
6 |
7 | I like tests, but I've still got to pick up how that works with Puppet.
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/Modulefile:
--------------------------------------------------------------------------------
1 | name 'nesi-git'
2 | version '0.0.1'
3 | source 'https://github.com/nesi/puppet-git'
4 | author 'Aaron Hicks'
5 | license 'GPL3'
6 | summary 'A git module'
7 | description 'A module for managing git repositories and users with Puppet'
8 | project_page 'https://github.com/nesi/puppet-git'
9 |
10 | ## Add dependencies, if any:
11 | # dependency 'username/name', '>= 1.2.0'
12 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/manifests/install.pp:
--------------------------------------------------------------------------------
1 | # Git installer manifest
2 | # DO NOT USE DIRECTLY
3 | #
4 | # Use this instead:
5 | # include git
6 | #
7 | # or:
8 | # class {'git':
9 | # svn => true,
10 | # gui => true,
11 | #}
12 |
13 | class git::install(
14 | $gui,
15 | $svn
16 | ){
17 | require git::params
18 |
19 | if ! defined(Package[$git::params::package]) {
20 | package{$git::params::package: ensure => installed}
21 | }
22 |
23 | if $svn {
24 | package{$git::params::svn_package: ensure => installed}
25 | } else {
26 | package{$git::params::svn_package: ensure => absent}
27 | }
28 |
29 | if $gui {
30 | package{$git::params::gui_package: ensure => installed}
31 | } else {
32 | package{$git::params::gui_package: ensure => absent}
33 | }
34 |
35 | $root_name = "root on ${::fqdn}"
36 | $root_email = "root@${::fqdn}"
37 |
38 | git::user{'root':}
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/manifests/params.pp:
--------------------------------------------------------------------------------
1 | # = Class: git::params
2 | #
3 | # Configure how the puppet git module behaves
4 |
5 | class git::params {
6 |
7 | case $::operatingsystem {
8 | 'CentOS','Ubuntu', 'Debian', 'Amazon' :{
9 | $package = 'git'
10 | $svn_package = 'git-svn'
11 | $gui_package = 'git-gui'
12 | $bin = '/usr/bin/git'
13 | }
14 | default:{
15 | warning("git not configured for ${::operatingsystem} on ${::fqdn}")
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/metadata.json:
--------------------------------------------------------------------------------
1 | /*
2 | +-----------------------------------------------------------------------+
3 | | |
4 | | ==> DO NOT EDIT THIS FILE! <== |
5 | | |
6 | | You should edit the `Modulefile` and run `puppet-module build` |
7 | | to generate the `metadata.json` file for your releases. |
8 | | |
9 | +-----------------------------------------------------------------------+
10 | */
11 |
12 | {}
13 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/spec/spec.opts:
--------------------------------------------------------------------------------
1 | --format
2 | s
3 | --colour
4 | --loadby
5 | mtime
6 | --backtrace
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'pathname'
2 | dir = Pathname.new(__FILE__).parent
3 | $LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
4 |
5 | require 'mocha'
6 | require 'puppet'
7 | gem 'rspec', '=1.2.9'
8 | require 'spec/autorun'
9 |
10 | Spec::Runner.configure do |config|
11 | config.mock_with :mocha
12 | end
13 |
14 | # We need this because the RAL uses 'should' as a method. This
15 | # allows us the same behaviour but with a different method name.
16 | class Object
17 | alias :must :should
18 | end
19 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/git/tests/init.pp:
--------------------------------------------------------------------------------
1 | # This file is part of the git Puppet module.
2 | #
3 | # The git Puppet module is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # The git Puppet module is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with the git Puppet module. If not, see .
15 | include git
16 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | repositories:
3 | "puppi": "git://github.com/example42/puppi.git"
4 | "monitor": "git://github.com/example42/puppet-monitor.git"
5 | "firewall": "git://github.com/example42/puppet-firewall.git"
6 | "iptables": "git://github.com/example42/puppet-iptables.git"
7 | "concat": "git://github.com/example42/puppet-concat.git"
8 | symlinks:
9 | "mysql": "#{source_dir}"
10 |
11 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/.gemfile:
--------------------------------------------------------------------------------
1 | source :rubygems
2 |
3 | puppetversion = ENV['PUPPET_VERSION']
4 | gem 'puppet', puppetversion, :require => false
5 | gem 'puppet-lint'
6 | gem 'puppetlabs_spec_helper', '>= 0.1.0'
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.8.7
4 | - 1.9.3
5 | script:
6 | - "rake spec SPEC_OPTS='--format documentation'"
7 | env:
8 | - PUPPET_VERSION="~> 2.6.0"
9 | - PUPPET_VERSION="~> 2.7.0"
10 | - PUPPET_VERSION="~> 3.0.0"
11 | - PUPPET_VERSION="~> 3.1.0"
12 | matrix:
13 | exclude:
14 | - rvm: 1.9.3
15 | env: PUPPET_VERSION="~> 2.6.0"
16 | gemfile: .gemfile
17 | - rvm: 1.9.3
18 | env: PUPPET_VERSION="~> 2.7.0"
19 | gemfile: .gemfile
20 |
21 | gemfile: .gemfile
22 | notifications:
23 | email:
24 | - al@lab42.it
25 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/Modulefile:
--------------------------------------------------------------------------------
1 | name 'example42-mysql'
2 | version '2.0.7'
3 |
4 | author 'Alessandro Franceschi'
5 | license 'Apache2'
6 | project_page 'http://www.example42.com'
7 | source 'https://github.com/example42/puppet-mysql'
8 | summary 'Puppet module for mysql'
9 | description 'This module installs and manages mysql. Check README.rdoc for details. Puppi is required for some common functions: you can install them without using the whole module. Monitor and firewall dependencies are needed only if the relevant features are enabled'
10 | dependency 'example42/puppi', '>=2.0.0'
11 | dependency 'example42/firewall', '>=2.0.0'
12 | dependency 'example42/monitor', '>=2.0.0'
13 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'puppetlabs_spec_helper/rake_tasks'
3 | require 'puppet-lint'
4 | PuppetLint.configuration.send("disable_80chars")
5 | PuppetLint.configuration.send('disable_class_parameter_defaults')
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/manifests/client.pp:
--------------------------------------------------------------------------------
1 | # Class: mysql::client
2 | #
3 | # Manages mysql client installation
4 | #
5 | # Usage:
6 | # include mysql::client
7 | #
8 | class mysql::client {
9 |
10 | include mysql::params
11 |
12 | package { 'mysql-client':
13 | ensure => present,
14 | name => $mysql::params::package_client,
15 | }
16 |
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/manifests/spec.pp:
--------------------------------------------------------------------------------
1 | # Class: mysql::spec
2 | #
3 | # This class is used only for rpsec-puppet tests
4 | # Can be taken as an example on how to do custom classes but should not
5 | # be modified.
6 | #
7 | # == Usage
8 | #
9 | # This class is not intended to be used directly.
10 | # Use it as reference
11 | #
12 | class mysql::spec inherits mysql {
13 |
14 | # This just a test to override the arguments of an existing resource
15 | # Note that you can achieve this same result with just:
16 | # class { "mysql": template => "mysql/spec.erb" }
17 |
18 | File['mysql.conf'] {
19 | content => template('mysql/spec.erb'),
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/spec/spec.opts:
--------------------------------------------------------------------------------
1 | --format
2 | s
3 | --colour
4 | --loadby
5 | mtime
6 | --backtrace
7 |
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/module_spec_helper'
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/templates/grant.erb:
--------------------------------------------------------------------------------
1 | # File managed by Puppet
2 |
3 | <% if mysql_db != "*" then %>
4 | CREATE DATABASE IF NOT EXISTS `<%= mysql_db %>` ;
5 | <% end %>
6 | GRANT <%= mysql_privileges %> ON `<%= mysql_db %>`.* TO '<%= mysql_user %>'@'<%= mysql_host %>' IDENTIFIED BY '<%= mysql_password %>';
7 | FLUSH PRIVILEGES ;
8 |
9 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/templates/query.erb:
--------------------------------------------------------------------------------
1 | # File managed by Puppet
2 |
3 | <% if @mysql_db -%>
4 | USE <%= mysql_db -%> ;
5 | <% end -%>
6 | <%= mysql_query %> ;
7 |
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/templates/root.my.cnf.backup.erb:
--------------------------------------------------------------------------------
1 | # File Managed by Puppet
2 |
3 | [client]
4 | password=
5 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/templates/root.my.cnf.erb:
--------------------------------------------------------------------------------
1 | # File Managed by Puppet
2 |
3 | [mysql]
4 | local-infile=1
5 |
6 | [client]
7 | password=<%= scope.lookupvar('mysql::real_root_password') %>
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/templates/spec.erb:
--------------------------------------------------------------------------------
1 | # This is a template used only for rspec tests
2 |
3 | # Yaml of the whole scope
4 | <%= scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }.to_yaml %>
5 |
6 | # Custom Options
7 | <%= options['opt_a'] %>
8 | <%= options['opt_b'] %>
9 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/mysql/templates/user.erb:
--------------------------------------------------------------------------------
1 | # File managed by Puppet
2 |
3 | GRANT USAGE ON *.*
4 | TO '<%= mysql_user %>'@'<%= mysql_host %>'
5 | IDENTIFIED BY
6 | <% if has_variable?('mysql_password_hash') && mysql_password_hash then %>
7 | PASSWORD '<%= mysql_password_hash %>'
8 | <% else %>
9 | '<%= mysql_password %>';
10 | <% end %>
11 | ;
12 | FLUSH PRIVILEGES;
13 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | repositories:
3 | "puppi": "git://github.com/example42/puppi.git"
4 | "monitor": "git://github.com/example42/puppet-monitor.git"
5 | "firewall": "git://github.com/example42/puppet-firewall.git"
6 | "iptables": "git://github.com/example42/puppet-iptables.git"
7 | "concat": "git://github.com/example42/puppet-concat.git"
8 | symlinks:
9 | "php": "#{source_dir}"
10 |
11 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/.gemfile:
--------------------------------------------------------------------------------
1 | source :rubygems
2 |
3 | puppetversion = ENV['PUPPET_VERSION']
4 | gem 'puppet', puppetversion, :require => false
5 | gem 'puppet-lint'
6 | gem 'puppetlabs_spec_helper', '>= 0.1.0'
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.8.7
4 | - 1.9.3
5 | script:
6 | - "rake spec SPEC_OPTS='--format documentation'"
7 | env:
8 | - PUPPET_VERSION="~> 2.6.0"
9 | - PUPPET_VERSION="~> 2.7.0"
10 | - PUPPET_VERSION="~> 3.0.0"
11 | - PUPPET_VERSION="~> 3.1.0"
12 | matrix:
13 | exclude:
14 | - rvm: 1.9.3
15 | env: PUPPET_VERSION="~> 2.6.0"
16 | gemfile: .gemfile
17 |
18 | gemfile: .gemfile
19 | notifications:
20 | email:
21 | - al@lab42.it
22 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/Modulefile:
--------------------------------------------------------------------------------
1 | name 'example42-php'
2 | version '2.0.8'
3 | author 'Alessandro Franceschi'
4 | license 'Apache2'
5 | project_page 'http://www.example42.com'
6 | source 'https://github.com/example42/puppet-php'
7 | summary 'Puppet module for php'
8 | description 'This module installs and manages php. Check README.rdoc for details. Puppi is required for some common functions: you can install them without using the whole module. Monitor and firewall dependencies are needed only if the relevant features are enabled'
9 | dependency 'example42/puppi', '>= 2.0.0'
10 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'puppetlabs_spec_helper/rake_tasks'
3 | require 'puppet-lint'
4 | PuppetLint.configuration.send("disable_80chars")
5 | PuppetLint.configuration.send('disable_class_parameter_defaults')
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/lib/facter/php_fact_extension_dir.rb:
--------------------------------------------------------------------------------
1 | Facter.add("php_fact_extension_dir") do
2 | setcode do
3 | Facter::Util::Resolution.exec('php-config --extension-dir') || nil
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/lib/facter/php_fact_version.rb:
--------------------------------------------------------------------------------
1 | Facter.add("php_fact_version") do
2 | setcode do
3 | Facter::Util::Resolution.exec('php-config --version') || nil
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/composer.pp:
--------------------------------------------------------------------------------
1 | # Class: php::composer
2 | #
3 | # Installs Composer
4 | class php::composer (
5 | $install_location = '/usr/bin',
6 | $filename = 'composer'
7 | ) {
8 | $composer_location = $install_location
9 | $composer_filename = $filename
10 |
11 | exec { "composer-${install_location}":
12 | command => "curl -sS https://getcomposer.org/installer | php -- --install-dir=/home/vagrant && mv /home/vagrant/composer.phar ${install_location}/${filename}",
13 | path => ['/usr/bin' , '/bin'],
14 | require => Package['php5', 'curl'],
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/composer/run.pp:
--------------------------------------------------------------------------------
1 | define php::composer::run (
2 | $command = 'install',
3 | $path
4 | ) {
5 | exec { "composer-${path}-${command}-${php::composer::composer_location}":
6 | command => "${php::composer::composer_filename} ${command} --working-dir ${path}",
7 | path => "/usr/bin:/usr/sbin:/bin:/sbin:${php::composer::composer_location}",
8 | require => Class['php::composer']
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/custom/xhprof.pp:
--------------------------------------------------------------------------------
1 | define php::custom::xhprof ($output_dir = '/var/tmp/xhprof')
2 | {
3 | if !defined(File[$output_dir]) {
4 | file { $output_dir :
5 | ensure => 'directory',
6 | }
7 | }
8 |
9 | git::repo{ 'xhprof' :
10 | path => "${settings::confdir}/files/git/xhprof",
11 | source => 'git://github.com/facebook/xhprof.git'
12 | }
13 |
14 | build::install { 'xhprof' :
15 | folder => "${settings::confdir}/files/git/xhprof/extension",
16 | buildoptions => "/usr/bin/phpize && ./configure",
17 | require => [
18 | Git::Repo['xhprof'],
19 | Apt::Builddep['php5']
20 | ],
21 | }
22 |
23 | php::ini { 'xhprof' :
24 | value => [
25 | '[xhprof]',
26 | 'extension=xhprof.so',
27 | "xhprof.output_dir=\"${output_dir}\""
28 | ],
29 | template => 'extra-ini.erb',
30 | target => 'xhprof.ini',
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/devel.pp:
--------------------------------------------------------------------------------
1 | # Class php::devel
2 | #
3 | # Installs php devel package
4 | #
5 | class php::devel {
6 |
7 | if $php::package_devel != '' {
8 | package { 'php-devel':
9 | ensure => $php::manage_package,
10 | name => $php::package_devel,
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/ini.pp:
--------------------------------------------------------------------------------
1 | define php::ini (
2 | $value = '',
3 | $template = 'extra-ini.erb',
4 | $target = 'extra.ini',
5 | $service = $php::service
6 | ) {
7 | file { "/etc/php5/conf.d/${target}" :
8 | ensure => 'present',
9 | content => template("php/${template}"),
10 | require => Package['php'],
11 | notify => Service[$service],
12 | }
13 |
14 | file { "/etc/php5/cli/conf.d/${target}" :
15 | ensure => 'present',
16 | content => template("php/${template}"),
17 | require => Package['php'],
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/ini/removeblock.pp:
--------------------------------------------------------------------------------
1 | define php::ini::removeblock (
2 | $block_name,
3 | $ini_file
4 | ) {
5 | $left_side_regex = 'perl -pi -w -e "s/^(\[?)'
6 | $right_side_regex = '(\]?)(.+\n)//"'
7 | $cmd = "${left_side_regex}${block_name}${right_side_regex}"
8 |
9 | exec { "${cmd} ${ini_file}" :
10 | path => '/usr/bin/',
11 | require => Package['php']
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/pear.pp:
--------------------------------------------------------------------------------
1 | # Class: php::pear
2 | #
3 | # Installs Pear for PHP module
4 | #
5 | # Usage:
6 | # include php::pear
7 | #
8 | # == Parameters
9 | #
10 | # Standard class parameters
11 | # Define the general class behaviour and customizations
12 | #
13 | # [*package*]
14 | # Name of the package to install. Defaults to 'php-pear'
15 | #
16 | # [*install_package*]
17 | # Boolean. Determines if any package should be installed to support the PEAR functionality.
18 | # Can be false if PEAR was already provided by another package or module.
19 | # Default: true
20 | #
21 | class php::pear (
22 | $package = $php::package_pear,
23 | $install_package = true,
24 | $path = '/usr/bin:/usr/sbin:/bin:/sbin',
25 | ) inherits php {
26 |
27 | if ( $install_package ) {
28 | package { 'php-pear':
29 | name => $package,
30 | ensure => present,
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/pear/config.pp:
--------------------------------------------------------------------------------
1 | # Define: php::pear::config
2 | #
3 | # Configures pear
4 | #
5 | # Usage:
6 | # php::pear::config { http_proxy: value => "myproxy:8080" }
7 | #
8 | define php::pear::config ($value) {
9 |
10 | include php::pear
11 |
12 | exec { "pear-config-set-${name}":
13 | command => "pear config-set ${name} ${value}",
14 | path => $php::pear::path,
15 | unless => "pear config-get ${name} | grep ${value}",
16 | require => Package['php-pear'],
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/manifests/spec.pp:
--------------------------------------------------------------------------------
1 | # Class: php::spec
2 | #
3 | # This class is used only for rpsec-puppet tests
4 | # Can be taken as an example on how to do custom classes but should not
5 | # be modified.
6 | #
7 | # == Usage
8 | #
9 | # This class is not intended to be used directly.
10 | # Use it as reference
11 | #
12 | class php::spec inherits php {
13 |
14 | # This just a test to override the arguments of an existing resource
15 | # Note that you can achieve this same result with just:
16 | # class { "php": template => "php/spec.erb" }
17 |
18 | File['php.conf'] {
19 | content => template('php/spec.erb'),
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'puppetlabs_spec_helper/module_spec_helper'
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/templates/extra-ini.erb:
--------------------------------------------------------------------------------
1 | ; File Managed by Puppet
2 |
3 | <% if value != "" -%>
4 | <% if value.is_a? Array -%>
5 | <% value.each do |name| -%>
6 | <%= name %>
7 | <% end %>
8 | <% else -%>
9 | <%= value %>
10 | <% end -%>
11 | <% end -%>
12 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/php/templates/spec.erb:
--------------------------------------------------------------------------------
1 | # This is a template used only for rspec tests
2 |
3 | # Yaml of the whole scope
4 | <%= scope.to_hash.reject { |k,v| !( k.is_a?(String) && v.is_a?(String) ) }.to_yaml %>
5 |
6 | # Custom Options
7 | <%= options['opt_a'] %>
8 | <%= options['opt_b'] %>
9 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/.fixtures.yml:
--------------------------------------------------------------------------------
1 | fixtures:
2 | repositories:
3 | "concat": "git://github.com/example42/puppet-concat.git"
4 | symlinks:
5 | "puppi": "#{source_dir}"
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/.gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | puppetversion = ENV['PUPPET_VERSION']
4 | gem 'puppet', puppetversion, :require => false
5 | gem 'puppet-lint'
6 | gem 'puppetlabs_spec_helper', '>= 0.1.0'
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 1.8.7
4 | - 1.9.3
5 | script:
6 | - "rake spec SPEC_OPTS='--format documentation'"
7 | env:
8 | - PUPPET_VERSION="~> 2.6.0"
9 | - PUPPET_VERSION="~> 2.7.0"
10 | - PUPPET_VERSION="~> 3.0.0"
11 | - PUPPET_VERSION="~> 3.1.0"
12 | matrix:
13 | exclude:
14 | - rvm: 1.9.3
15 | env: PUPPET_VERSION="~> 2.6.0"
16 | gemfile: .gemfile
17 |
18 | gemfile: .gemfile
19 | notifications:
20 | email:
21 | - al@lab42.it
22 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/Modulefile:
--------------------------------------------------------------------------------
1 | name 'example42-puppi'
2 | version '2.0.8'
3 |
4 | author 'lab42'
5 | license 'Apache'
6 | project_page 'http://www.example42.com'
7 | source 'git://github.com/example42/puppi'
8 | summary 'Installs and configures Puppi'
9 | description 'This module provides the Puppi libraries required by Example42 modules and, if explicitely included, the puppi command, its working environment, the defines and procedures to deploy applications'
10 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'puppetlabs_spec_helper/rake_tasks'
3 | require 'puppet-lint'
4 | PuppetLint.configuration.send("disable_80chars")
5 | PuppetLint.configuration.send('disable_class_parameter_defaults')
6 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example42/puppi",
3 | "description": "Puppet driven applications deployment tool",
4 | "homepage": "https://github.com/example42/puppi",
5 | "type": "library",
6 | "license": "Apache License, Version 2.0",
7 | "authors": [
8 | {
9 | "name": "Example42",
10 | "homepage": "http://www.example42.com/"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/info/readme/readme:
--------------------------------------------------------------------------------
1 | Default ReadMe File.
2 | Edit puppi/files/info/readme/readme to change this message
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/info/readme/readme-default:
--------------------------------------------------------------------------------
1 | No extra node or role related info available.
2 | To have node or role specific extar info, create
3 | modules/puppi/files/info/readme/readme--$hostname or
4 | modules/puppi/files/info/readme/readme-$role
5 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/mcollective/puppicheck:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # File Managed by Puppet
3 | PATH=$PATH:/usr/local/bin
4 |
5 | if [ ! $1 ] ; then
6 | echo "Provide at least a match pattern. For example:"
7 | echo "role=fep-pgol"
8 | exit 1
9 | fi
10 |
11 | filtered=$(echo $* | sed "s/[^a-Z0-9= _.\-]//Ig")
12 |
13 | randfile="$(mktemp)"
14 |
15 | trap "rm -f $randfile" SIGINT SIGTERM EXIT
16 |
17 | myarg=$(echo $filtered | sed -e "s/ / -F /g")
18 |
19 | mc-puppi check -F $myarg | tee $randfile
20 | grep FAILED $randfile && exit 1
21 | exit 0
22 |
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/mcollective/puppideploy:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # File Managed by Puppet
3 | PATH=$PATH:/usr/local/bin
4 |
5 | if [ ! $2 ] ; then
6 | echo "Provide the hostname and the project you want to deploy:"
7 | echo "superdeploy web01.example42.com myapp"
8 | exit 1
9 | fi
10 |
11 | filtered=$(echo $* | sed "s/[^a-Z0-9= _.\-]//Ig")
12 |
13 | randfile="$(mktemp)"
14 |
15 | trap "rm -f $randfile" SIGINT SIGTERM EXIT
16 |
17 | myarg=$(echo $filtered | sed -e "s/ / -F /g")
18 |
19 | mc-puppi deploy -I $1 $2 | tee $randfile
20 | grep FAILED $randfile && exit 1
21 | exit 0
22 |
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/clean_filelist.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # clean_filelist.sh - Made for Puppi
3 |
4 | # Sources common header for Puppi scripts
5 | . $(dirname $0)/header || exit 10
6 |
7 | # Show help
8 | showhelp () {
9 | echo "This script is used to cleanup a list of files to download from unwanted data"
10 | echo "It has 1 optional argument:"
11 | echo "The prefix, present in the list, to cut out when defining files to deploy"
12 | echo "The list file is defined as $downloadedfile , these variables are gathered from the Puppi runtime"
13 | echo " config file."
14 | echo
15 | echo "Example:"
16 | echo "clean_filelist.sh http://svn.example42.com/myproject"
17 | }
18 |
19 |
20 | if [ $1 ] ; then
21 | prefix=$1
22 | else
23 | prefix=""
24 | fi
25 |
26 | deployfilelist=$downloadedfile
27 |
28 | # Clean list
29 | cleanlist () {
30 |
31 | sed -i "s/^$prefix//g" $deployfilelist
32 |
33 | }
34 |
35 | cleanlist
36 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # delete.sh - Made for Puppi
3 |
4 | # Sources common header for Puppi scripts
5 | . $(dirname $0)/header || exit 10
6 |
7 | # Manage script variables
8 | if [ $1 ] ; then
9 | tobedeleted=$1
10 | else
11 | echo "You must provide a file or directory to delete!"
12 | exit 2
13 | fi
14 |
15 | if [ "$tobedeleted" = "/" ] ; then
16 | echo "Be Serious!"
17 | exit 2
18 | fi
19 |
20 | # Move file
21 | move () {
22 | mkdir $workdir/$project/deleted
23 | mv $tobedeleted $workdir/$project/deleted
24 | }
25 |
26 | move
27 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/execute.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # execute.sh - Made for Puppi
3 | # This script just executes what is passed as argument
4 |
5 | # Sources common header for Puppi scripts
6 | . $(dirname $0)/header || exit 10
7 |
8 | #parse variables
9 | command=$(eval "echo "$*"")
10 |
11 | #execute command
12 | eval "${command}"
13 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/header:
--------------------------------------------------------------------------------
1 | configfile="/etc/puppi/puppi.conf"
2 |
3 | # Load general configurations
4 | if [ ! -f $configfile ] ; then
5 | echo "Config file: $configfile not found"
6 | exit 2
7 | else
8 | . $configfile
9 | . $scriptsdir/functions
10 | fi
11 |
12 | # Load project runtime configuration
13 | projectconfigfile="$workdir/$project/config"
14 | if [ ! -f $projectconfigfile ] ; then
15 | echo "Project runtime config file: $projectconfigfile not found"
16 | exit 2
17 | else
18 | . $projectconfigfile
19 | fi
20 |
21 | # Activate debug
22 | case "$debug" in
23 | yes) set -x ;;
24 | full) set -xv ;;
25 | esac
26 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/predeploy_tar.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # predeploy_tar.sh - Made for Puppi
3 |
4 | # Sources common header for Puppi scripts
5 | . $(dirname $0)/header || exit 10
6 |
7 | # Show help
8 | showhelp () {
9 | echo "This script unpacks (tar) file from the download dir (storedir) to the predeploydir"
10 | echo "It has the following options:"
11 | echo "\$1 (Required) - Name of the variable that identifies the tar to predeploy"
12 | echo
13 | echo "Examples:"
14 | echo "predeploy_tar.sh tarfile"
15 | }
16 |
17 | # Check Arguments
18 | if [ $1 ] ; then
19 | deployfilevar=$1
20 | deployfile="$(eval "echo \${$(echo ${deployfilevar})}")"
21 | else
22 | showhelp
23 | exit 2
24 | fi
25 |
26 | # Untar file
27 | untar () {
28 | cd $predeploydir
29 | # file $deployfile | grep gzip 2>&1>/dev/null
30 | # if [ $? == "0"] ; then
31 | tar -zxf $deployfile
32 | # else
33 | # tar -xvf $deployfile
34 | # fi
35 | }
36 |
37 | untar
38 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/report_mail.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # report_mail.sh - Made for Puppi
3 | # This script sends a summary mail to the recipients defined in $1
4 | # Use a comma separated list for multiple emails
5 |
6 | # Sources common header for Puppi scripts
7 | . $(dirname $0)/header || exit 10
8 |
9 | # Check arguments & eventually apply runtimeconfig overwrite
10 | recipients=$1
11 | [ $report_email ] && recipients=$report_email
12 |
13 | # Main functions
14 | mail_send () {
15 | result=$(grep result $logdir/$project/$tag/summary | awk '{ print $NF }')
16 | cat $logdir/$project/$tag/summary | mail -s "[puppi] $result $action of $project on $(hostname)" $recipients
17 | }
18 |
19 | mail_send
20 |
21 | if [ "$EXITCRIT" = "1" ] ; then
22 | exit 2
23 | fi
24 |
25 | if [ "$EXITWARN" = "1" ] ; then
26 | exit 1
27 | fi
28 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/service.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # service.sh - Made for Puppi
3 |
4 | # Sources common header for Puppi scripts
5 | . $(dirname $0)/header || exit 10
6 |
7 | # Show help
8 | showhelp () {
9 | echo "This script is used to manage one or more services"
10 | echo "It requires AT LEAST 2 arguments:"
11 | echo "First argument (\$1 - required) is the script command (stop|start|restart|reload)"
12 | echo "Second argument and following (\$2 - required) is the space separated list of sevices to manage"
13 | echo
14 | echo "Examples:"
15 | echo "service.sh stop monit puppet"
16 | }
17 |
18 | # Check arguments
19 | if [ $1 ] ; then
20 | servicecommand=$1
21 | else
22 | showhelp
23 | exit 2
24 | fi
25 |
26 |
27 | if [ $# -ge 2 ] ; then
28 | shift
29 | services=$@
30 | else
31 | showhelp
32 | exit 2
33 | fi
34 |
35 | # Manage service
36 | service () {
37 | for serv in $services ; do
38 | /etc/init.d/$serv $servicecommand
39 | done
40 | }
41 |
42 | service
43 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/files/scripts/yant.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # yant.sh - Made for Puppi
3 | # Sources common header for Puppi scripts
4 | . $(dirname $0)/header || exit 10
5 |
6 | # Show help
7 | showhelp () {
8 | echo "This script is used to call ant in a hybris-system"
9 | echo "It requires AT LEAST 2 arguments:"
10 | echo "First the \${hybris_parent_dir} where it can find a hybris-directory"
11 | echo "Second argument: Everything you want to pass through to ant"
12 | echo "The script assumes that hybris is located in \${hybris_parent_dir}/hybris"
13 | echo
14 | echo "Examples:"
15 | echo "yant.sh /home/hybris clean all"
16 | }
17 |
18 | # Unfortunately, showhelp will never be called
19 |
20 | cd $1/hybris/bin/platform
21 | . ./setantenv.sh
22 |
23 | # somehow dirty ...
24 | shift
25 |
26 | if [ -d /opt/hybris/config ]; then
27 | template=""
28 | else
29 | template=-Dinput.template=develop
30 | fi
31 |
32 | if [ $debug ] ; then
33 | ant -Dinput.template=develop $*
34 | else
35 | ant $* > /dev/null
36 | fi
37 |
38 | handle_result
39 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/lib/facter/last_run.rb:
--------------------------------------------------------------------------------
1 | require 'facter'
2 | Facter.add("last_run") do
3 | confine :kernel => [ 'Linux' , 'SunOS' , 'FreeBSD' , 'Darwin' ]
4 | setcode do
5 | Facter::Util::Resolution.exec('date')
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/lib/facter/puppi_projects.rb:
--------------------------------------------------------------------------------
1 | require 'facter'
2 | Facter.add("puppi_projects") do
3 | confine :kernel => [ 'Linux' , 'SunOS' , 'FreeBSD' , 'Darwin' ]
4 | setcode do
5 | Facter::Util::Resolution.exec('ls `grep projectsdir /etc/puppi/puppi.conf | sed \'s/projectsdir="\([^"]*\)"/\1/\'` | tr \'\n\' \',\' | sed \'s/,$//\'') if File.exists?("/etc/puppi/puppi.conf")
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/lib/puppet/parser/functions/bool2ensure.rb:
--------------------------------------------------------------------------------
1 | #
2 | # bool2ensure.rb
3 | #
4 | # This define return present/absent accroding to the boolean value passed
5 | #
6 | module Puppet::Parser::Functions
7 | newfunction(:bool2ensure, :type => :rvalue, :doc => <<-EOS
8 | This converts any input similar to a boolean to the stringpresent or absent
9 | EOS
10 | ) do |arguments|
11 |
12 | raise(Puppet::ParseError, "bool2ensure(): Wrong number of arguments " +
13 | "given (#{arguments.size} for 1)") if arguments.size < 1
14 |
15 | string = arguments[0]
16 |
17 | result = case string
18 | when false then "absent"
19 | when true then "present"
20 | when /^$/, '' then "present"
21 | when /^(1|t|y|true|yes)$/ then "present"
22 | when /^(0|f|n|false|no)$/ then "absent"
23 | when /^(undef|undefined)$/ then "present"
24 | else
25 | raise(Puppet::ParseError, 'bool2ensure(): Unknown type of boolean given')
26 | end
27 |
28 | return result
29 | end
30 | end
31 |
32 | # vim: set ts=2 sw=2 et :
33 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/lib/puppet/parser/functions/get_class_args.rb:
--------------------------------------------------------------------------------
1 | # This function is based on Ken Barber's get_scope_args
2 | # It has been slightly changed and renamed to avoid naming clash
3 |
4 | module Puppet::Parser::Functions
5 | newfunction(:get_class_args, :type => :rvalue, :doc => <<-EOS
6 | This function will return all arguments passed to the current scope. This could
7 | be a class or defined resource.
8 | EOS
9 | ) do |arguments|
10 |
11 | if (arguments.size != 0) then
12 | raise(Puppet::ParseError, "validate_resource(): Wrong number of arguments "+
13 | "given #{arguments.size} for 0")
14 | end
15 |
16 | # Grab the current scope, turn it to a hash but do not be recursive
17 | # about it.
18 | classhash = to_hash(recursive=false)
19 |
20 | # Strip bits that do not matter for validation
21 | # classhash.delete("name")
22 | # classhash.delete("title")
23 | # classhash.delete("caller_module_name")
24 | # classhash.delete("module_name")
25 |
26 | # Return munged classhash
27 | classhash
28 | end
29 | end
30 |
31 | # vim: set ts=2 sw=2 et :
32 |
33 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/lib/puppet/parser/functions/get_magicvar.rb:
--------------------------------------------------------------------------------
1 | #
2 | # get_magicvar.rb
3 | #
4 | # This define return the value of the the provided var name
5 | #
6 | module Puppet::Parser::Functions
7 | newfunction(:get_magicvar, :type => :rvalue, :doc => <<-EOS
8 | This returns the value of the input variable. For example if you input role
9 | it returns the value of $role'.
10 | EOS
11 | ) do |arguments|
12 |
13 | raise(Puppet::ParseError, "get_magicvar(): Wrong number of arguments " +
14 | "given (#{arguments.size} for 1)") if arguments.size < 1
15 |
16 | my_var = arguments[0]
17 | result = lookupvar("#{my_var}")
18 | result = 'all' if ( result == :undefined || result == '' )
19 | return result
20 | end
21 | end
22 |
23 | # vim: set ts=2 sw=2 et :
24 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/lib/puppet/parser/functions/is_array.rb:
--------------------------------------------------------------------------------
1 | #
2 | # is_array.rb
3 | #
4 | # Imported from puppetlabs-stdlib
5 |
6 | module Puppet::Parser::Functions
7 | newfunction(:is_array, :type => :rvalue, :doc => <<-EOS
8 | Returns true if the variable passed to this function is an array.
9 | EOS
10 | ) do |arguments|
11 |
12 | raise(Puppet::ParseError, "is_array(): Wrong number of arguments " +
13 | "given (#{arguments.size} for 1)") if arguments.size < 1
14 |
15 | type = arguments[0]
16 |
17 | result = type.is_a?(Array)
18 |
19 | return result
20 | end
21 | end
22 |
23 | # vim: set ts=2 sw=2 et :
24 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/helper.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::helper
2 | #
3 | # The Puppi 2.0 define that creates an helper file that contains
4 | # the commands to execute, for the different puppi actions, using
5 | # the variables present in the datafile
6 | #
7 | # == Usage
8 | # Basic Usage:
9 | # puppi::helper { "myhelper":
10 | # template => 'myproject/puppi/helpers/myhelper.erb',
11 | # }
12 | #
13 | define puppi::helper (
14 | $template,
15 | $ensure = 'present' ) {
16 |
17 | require puppi
18 | require puppi::params
19 |
20 | file { "puppi_helper_${name}":
21 | ensure => $ensure,
22 | path => "${puppi::params::helpersdir}/${name}.yml",
23 | mode => '0644',
24 | owner => $puppi::params::configfile_owner,
25 | group => $puppi::params::configfile_group,
26 | content => template($template),
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/helpers.pp:
--------------------------------------------------------------------------------
1 | # Class puppi::helpers
2 | #
3 | # A class that defines all the default helpers used by Example42
4 | # modules
5 | #
6 | # == Usage
7 | # Automatically included by Puppi
8 | #
9 | class puppi::helpers {
10 |
11 | # Standard helper for Example42 modules
12 | puppi::helper { 'standard':
13 | template => 'puppi/helpers/standard.yml.erb',
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/info/instance.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::info::instance
2 | #
3 | # This is a puppi info plugin specific for the tomcat::instance define
4 | #
5 | define puppi::info::instance (
6 | $servicename = '',
7 | $processname = '',
8 | $configdir = '',
9 | $bindir = '',
10 | $pidfile = '',
11 | $datadir = '',
12 | $logdir = '',
13 | $httpport = '',
14 | $controlport = '',
15 | $ajpport = '',
16 | $description = '',
17 | $run = '',
18 | $verbose = 'no',
19 | $templatefile = 'puppi/info/instance.erb' ) {
20 |
21 | require puppi
22 | require puppi::params
23 |
24 | file { "${puppi::params::infodir}/${name}":
25 | ensure => present,
26 | mode => '0750',
27 | owner => $puppi::params::configfile_owner,
28 | group => $puppi::params::configfile_group,
29 | content => template($templatefile),
30 | tag => 'puppi_info',
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/initialize.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::initialize
2 | #
3 | # This define creates a file with a initialize command that can be used locally.
4 | #
5 | # Usage:
6 | # puppi::initialize { "Retrieve files":
7 | # command => "get_file.sh",
8 | # argument => "/remote/dir/file",
9 | # priority => "10",
10 | # user => "root",
11 | # project => "spysite",
12 | # }
13 | #
14 | define puppi::initialize (
15 | $command,
16 | $project,
17 | $arguments = '',
18 | $priority = '50',
19 | $user = 'root',
20 | $enable = true ) {
21 |
22 | require puppi
23 | require puppi::params
24 |
25 | $ensure = bool2ensure($enable)
26 |
27 | file { "${puppi::params::projectsdir}/${project}/initialize/${priority}-${name}":
28 | ensure => $ensure,
29 | mode => '0750',
30 | owner => $puppi::params::configfile_owner,
31 | group => $puppi::params::configfile_group,
32 | require => Class['puppi'],
33 | content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n",
34 | tag => 'puppi_initialize',
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/log.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::log
2 | #
3 | # This define creates a basic log file that simply contains
4 | # the list of logs to show when issuing the puppi log command.
5 | #
6 | # == Usage:
7 | # puppi::log { "system":
8 | # description => "General System Logs" ,
9 | # log => [ "/var/log/syslog" , "/var/log/messages" ],
10 | # }
11 | #
12 | # :include:../README.log
13 | #
14 | define puppi::log (
15 | $log,
16 | $description = '' ) {
17 |
18 | require puppi
19 | require puppi::params
20 |
21 | $array_log = is_array($log) ? {
22 | false => split($log, ','),
23 | default => $log,
24 | }
25 |
26 | file { "${puppi::params::logsdir}/${name}":
27 | ensure => 'present',
28 | mode => '0644',
29 | owner => $puppi::params::configfile_owner,
30 | group => $puppi::params::configfile_group,
31 | require => Class['puppi'],
32 | content => template('puppi/log.erb'),
33 | tag => 'puppi_log',
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/mcollective/server.pp:
--------------------------------------------------------------------------------
1 | # = Class puppi::mcollective::server
2 | #
3 | # This class installs the puppi agent on mcollective servers
4 | # (Note that in mcollective terminology a server is an host
5 | # managed by a mcollective client)
6 | #
7 | # == Usage:
8 | # include puppi::mcollective::server
9 | #
10 | # :include:../README.mcollective
11 | #
12 | class puppi::mcollective::server {
13 |
14 | require puppi::params
15 |
16 | file { "${puppi::params::mcollective}/agent/puppi.ddl":
17 | ensure => 'present',
18 | mode => '0644',
19 | owner => 'root',
20 | group => 'root',
21 | source => 'puppet:///modules/puppi/mcollective/puppi.ddl',
22 | }
23 |
24 | file { "${puppi::params::mcollective}/agent/puppi.rb":
25 | ensure => 'present',
26 | mode => '0644',
27 | owner => 'root',
28 | group => 'root',
29 | source => 'puppet:///modules/puppi/mcollective/puppi.rb',
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/one.pp:
--------------------------------------------------------------------------------
1 | # Class: puppi::one
2 | #
3 | # Installs Puppi 1.0
4 | #
5 | class puppi::one {
6 |
7 | require puppi::params
8 |
9 | # Main configuration file
10 | file { 'puppi.conf':
11 | ensure => present,
12 | path => "${puppi::params::basedir}/puppi.conf",
13 | mode => '0644',
14 | owner => $puppi::params::configfile_owner,
15 | group => $puppi::params::configfile_group,
16 | content => template($puppi::template),
17 | require => File['puppi_basedir'],
18 | }
19 |
20 | # The Puppi 1.0 command
21 | file { 'puppi':
22 | ensure => present,
23 | path => '/usr/sbin/puppi.one',
24 | mode => '0750',
25 | owner => $puppi::params::configfile_owner,
26 | group => $puppi::params::configfile_group,
27 | content => template('puppi/puppi.erb'),
28 | require => File['puppi_basedir'],
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/report.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::report
2 | #
3 | # This define creates a file with a report command that can be used locally.
4 | #
5 | # Usage:
6 | # puppi::report { "Retrieve files":
7 | # command => "report_mail.sh",
8 | # argument => "roots@example42.com",
9 | # priority => "10",
10 | # user => "root",
11 | # project => "spysite",
12 | # }
13 | #
14 | define puppi::report (
15 | $project,
16 | $command,
17 | $arguments = '',
18 | $priority = '50',
19 | $user = 'root',
20 | $enable = true ) {
21 |
22 | require puppi::params
23 |
24 | # Autoinclude the puppi class
25 | include puppi
26 |
27 | $ensure = bool2ensure($enable)
28 |
29 | file { "${puppi::params::projectsdir}/${project}/report/${priority}-${name}":
30 | ensure => $ensure,
31 | mode => '0755',
32 | owner => $puppi::params::configfile_owner,
33 | group => $puppi::params::configfile_group,
34 | content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n",
35 | tag => 'puppi_report',
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/rollback.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::rollback
2 | #
3 | # This define creates a file with a rollback command that can be used locally.
4 | #
5 | # Usage:
6 | # puppi::rollback { "Retrieve files":
7 | # command => "get_file.sh",
8 | # argument => "/remote/dir/file",
9 | # priority => "10",
10 | # user => "root",
11 | # project => "spysite",
12 | # }
13 | #
14 | define puppi::rollback (
15 | $project,
16 | $command,
17 | $arguments = '',
18 | $priority = '50',
19 | $user = 'root',
20 | $enable = true ) {
21 |
22 | require puppi
23 | require puppi::params
24 |
25 | $ensure = bool2ensure($enable)
26 |
27 | file { "${puppi::params::projectsdir}/${project}/rollback/${priority}-${name}":
28 | ensure => $ensure,
29 | mode => '0750',
30 | owner => $puppi::params::configfile_owner,
31 | group => $puppi::params::configfile_group,
32 | content => "su - ${user} -c \"export project=${project} && ${puppi::params::scriptsdir}/${command} ${arguments}\"\n",
33 | tag => 'puppi_rollback',
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/run.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::run
2 | #
3 | # This define triggers a puppi deploy run directly during Puppet
4 | # execution. It can be used to automate FIRST TIME applications
5 | # deployments directly during the first Puppet execution
6 | #
7 | # == Variables
8 | #
9 | # [*name*]
10 | # The title/name you use has to be the name of an existing puppi::project
11 | # procedure define
12 | #
13 | # == Usage
14 | # Basic Usage:
15 | # puppi::run { "myapp": }
16 | #
17 | define puppi::run (
18 | $project = '',
19 | $timeout = 300) {
20 |
21 | require puppi
22 |
23 | exec { "Run_Puppi_${name}":
24 | command => "puppi deploy ${name}; [ $? -le \"1\" ] && touch ${puppi::params::archivedir}/puppirun_${name}",
25 | path => '/bin:/sbin:/usr/sbin:/usr/bin',
26 | creates => "${puppi::params::archivedir}/puppirun_${name}",
27 | timeout => $timeout,
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/two.pp:
--------------------------------------------------------------------------------
1 | # Class: puppi::two
2 | #
3 | # Installs Puppi NextGen
4 | #
5 | class puppi::two {
6 |
7 | # The Puppi command
8 | package { 'puppi':
9 | ensure => present,
10 | provider => 'gem',
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/manifests/ze.pp:
--------------------------------------------------------------------------------
1 | # Define puppi::ze
2 | #
3 | # The Puppi 2.0 define that transforms any class variable in data
4 | # you can use with Puppi
5 | #
6 | # == Usage
7 | # Basic Usage:
8 | # puppi::ze { "openssh":
9 | # variables => get_class_args(),
10 | # }
11 | #
12 | # puppi::ze { "openssh":
13 | # variables => get_class_args(),
14 | # filter => '.*content.*|.*key.*',
15 | # }
16 | #
17 | define puppi::ze (
18 | $variables,
19 | $helper = 'standard',
20 | $filter = '.*content.*|.*password.*',
21 | $ensure = 'present' ) {
22 |
23 | require puppi
24 | require puppi::params
25 |
26 | file { "puppize_${name}":
27 | ensure => $ensure,
28 | path => "${puppi::params::datadir}/${helper}_${name}.yml",
29 | mode => '0644',
30 | owner => $puppi::params::configfile_owner,
31 | group => $puppi::params::configfile_group,
32 | content => inline_template("<%= Hash[variables.sort].reject{ |k,v| k.to_s =~ /(${filter})/ }.to_yaml %>\n"),
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/classes/puppi_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi' do
4 |
5 | let(:node) { 'rspec.example42.com' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:facts) { { :ipaddress => '10.42.42.42' } }
8 |
9 | describe 'Test standard installation' do
10 | it { should contain_file('puppi').with_ensure('present') }
11 | it { should contain_file('puppi.conf').with_ensure('present') }
12 | it { should contain_file('puppi.scripts').with_ensure('present') }
13 | it { should contain_file('puppi_basedir').with_ensure('directory') }
14 | it { should contain_file('puppi_datadir').with_ensure('directory') }
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_check_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::check' do
4 |
5 | let(:title) { 'puppi::check' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:facts) { { :arch => 'i386' } }
8 | let(:params) {
9 | { 'enable' => 'true',
10 | 'name' => 'get',
11 | 'command' => 'echo',
12 | 'priority' => '50',
13 | 'project' => 'myapp',
14 | }
15 | }
16 |
17 | describe 'Test puppi check step file creation' do
18 | it 'should create a puppi::check step file' do
19 | should contain_file('Puppi_check_myapp_50_get').with_ensure('present')
20 | end
21 | it 'should populate correctly the puppi::check step file' do
22 | content = catalogue.resource('file', 'Puppi_check_myapp_50_get').send(:parameters)[:content]
23 | content.should match "/usr/lib/nagios/plugins/echo\n"
24 | end
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_deploy_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::deploy' do
4 |
5 | let(:title) { 'puppi::deploy' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'enable' => 'true',
9 | 'name' => 'get',
10 | 'command' => 'echo',
11 | 'priority' => '50',
12 | 'project' => 'myapp',
13 | }
14 | }
15 |
16 | describe 'Test puppi deploy step file creation' do
17 | it 'should create a puppi::deploy step file' do
18 | should contain_file('/etc/puppi/projects/myapp/deploy/50-get').with_ensure('present')
19 | end
20 | it 'should populate correctly the puppi::deploy step file' do
21 | content = catalogue.resource('file', '/etc/puppi/projects/myapp/deploy/50-get').send(:parameters)[:content]
22 | content.should match "su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n"
23 | end
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::helper' do
4 |
5 | let(:title) { 'spec' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'template' => 'puppi/helpers/standard.yml.erb' }
9 | }
10 |
11 | describe 'Test puppi helper file creation' do
12 | it 'should create a puppi helper file' do
13 | should contain_file('puppi_helper_spec').with_ensure('present')
14 | end
15 | it 'should populate correctly the helper file' do
16 | content = catalogue.resource('file', 'puppi_helper_spec').send(:parameters)[:content]
17 | content.should match('info:')
18 | end
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_info_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::info' do
4 |
5 | let(:title) { 'puppi::info' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'name' => 'sample',
9 | 'description' => 'Sample Info',
10 | 'templatefile' => 'puppi/info.erb',
11 | 'run' => 'myownscript',
12 | }
13 | }
14 |
15 | describe 'Test puppi info step file creation' do
16 | it 'should create a puppi::info step file' do
17 | should contain_file('/etc/puppi/info/sample').with_ensure('present')
18 | end
19 | it 'should populate correctly the puppi::info step file' do
20 | content = catalogue.resource('file', '/etc/puppi/info/sample').send(:parameters)[:content]
21 | content.should match(/myownscript/)
22 | end
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_initialize_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::initialize' do
4 |
5 | let(:title) { 'puppi::initialize' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'enable' => 'true',
9 | 'name' => 'get',
10 | 'command' => 'echo',
11 | 'priority' => '50',
12 | 'project' => 'myapp',
13 | }
14 | }
15 |
16 | describe 'Test puppi initialize step file creation' do
17 | it 'should create a puppi::initialize step file' do
18 | should contain_file('/etc/puppi/projects/myapp/initialize/50-get').with_ensure('present')
19 | end
20 | it 'should populate correctly the puppi::initialize step file' do
21 | content = catalogue.resource('file', '/etc/puppi/projects/myapp/initialize/50-get').send(:parameters)[:content]
22 | content.should match "su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n"
23 | # content.should match(/myapp,get/)
24 | end
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_log_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::log' do
4 |
5 | let(:title) { 'mylog' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'log' => '/var/log/mylog.log',
9 | 'description' => 'My Log',
10 | }
11 | }
12 |
13 | describe 'Test puppi log file creation' do
14 | it 'should create a puppi::log file' do
15 | should contain_file('/etc/puppi/logs/mylog').with_ensure('present')
16 | end
17 | it 'should populate correctly the puppi::log step file' do
18 | content = catalogue.resource('file', '/etc/puppi/logs/mylog').send(:parameters)[:content]
19 | content.should match(/mylog.log/)
20 | end
21 | end
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_project_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::report' do
4 |
5 | let(:title) { 'puppi::report' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'enable' => 'true',
9 | 'name' => 'get',
10 | 'command' => 'echo',
11 | 'priority' => '50',
12 | 'project' => 'myapp',
13 | }
14 | }
15 |
16 | describe 'Test puppi report step file creation' do
17 | it 'should create a puppi::report step file' do
18 | should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present')
19 | end
20 | it 'should populate correctly the puppi::report step file' do
21 | content = catalogue.resource('file', '/etc/puppi/projects/myapp/report/50-get').send(:parameters)[:content]
22 | content.should match "su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n"
23 | # content.should match(/myapp,get/)
24 | end
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_report_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::report' do
4 |
5 | let(:title) { 'puppi::report' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'enable' => 'true',
9 | 'name' => 'get',
10 | 'command' => 'echo',
11 | 'priority' => '50',
12 | 'project' => 'myapp',
13 | }
14 | }
15 |
16 | describe 'Test puppi report step file creation' do
17 | it 'should create a puppi::report step file' do
18 | should contain_file('/etc/puppi/projects/myapp/report/50-get').with_ensure('present')
19 | end
20 | it 'should populate correctly the puppi::report step file' do
21 | content = catalogue.resource('file', '/etc/puppi/projects/myapp/report/50-get').send(:parameters)[:content]
22 | content.should match "su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n"
23 | # content.should match(/myapp,get/)
24 | end
25 | end
26 |
27 | end
28 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_rollback_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::rollback' do
4 |
5 | let(:title) { 'puppi::rollback' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'enable' => 'true',
9 | 'name' => 'get',
10 | 'command' => 'echo',
11 | 'priority' => '50',
12 | 'project' => 'myapp',
13 | }
14 | }
15 |
16 | describe 'Test puppi rollback step file creation' do
17 | it 'should create a puppi::rollback step file' do
18 | should contain_file('/etc/puppi/projects/myapp/rollback/50-get').with_ensure('present')
19 | end
20 | it 'should populate correctly the puppi::rollback step file' do
21 | content = catalogue.resource('file', '/etc/puppi/projects/myapp/rollback/50-get').send(:parameters)[:content]
22 | content.should match "su - root -c \"export project=myapp && /etc/puppi/scripts/echo \"\n"
23 | end
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_run_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::run' do
4 |
5 | let(:title) { 'myapp' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | {
9 | 'project' => 'myapp',
10 | }
11 | }
12 |
13 | describe 'Test puppi run exe creation' do
14 | it 'should create a puppi::run exec' do
15 | content = catalogue.resource('exec', 'Run_Puppi_myapp').send(:parameters)[:command]
16 | content.should match /puppi deploy myapp/
17 | end
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_todo_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::todo' do
4 |
5 | let(:title) { 'mytodo' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'notes' => 'Test Notes',
9 | 'description' => 'Test Description',
10 | 'check_command' => 'check_test',
11 | 'run' => 'test',
12 | }
13 | }
14 |
15 | describe 'Test puppi todo file creation' do
16 | it 'should create a puppi::todo file' do
17 | should contain_file('/etc/puppi/todo/mytodo').with_ensure('present')
18 | end
19 | it 'should populate correctly the puppi::todo step file' do
20 | content = catalogue.resource('file', '/etc/puppi/todo/mytodo').send(:parameters)[:content]
21 | content.should match(/check_test/)
22 | end
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/defines/puppi_ze_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'puppi::ze' do
4 |
5 | let(:title) { 'sample' }
6 | let(:node) { 'rspec.example42.com' }
7 | let(:params) {
8 | { 'helper' => 'mytest',
9 | 'variables' => { 'var1' => 'get', 'var2' => 'got' },
10 | 'name' => 'sample',
11 | }
12 | }
13 |
14 | describe 'Test puppi ze data file creation' do
15 | it 'should create a puppi::ze step file' do
16 | should contain_file('puppize_sample').with_ensure('present')
17 | end
18 | it 'should populate correctly the puppi::ze data file' do
19 | content = catalogue.resource('file', 'puppize_sample').send(:parameters)[:content]
20 | content.should match(/var1: get/)
21 | end
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/functions/any2bool_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'any2bool' do
4 |
5 | describe 'Test Any2True' do
6 | it { should run.with_params(true).and_return(true) }
7 | it { should run.with_params('true').and_return(true) }
8 | it { should run.with_params('yes').and_return(true) }
9 | it { should run.with_params('y').and_return(true) }
10 | end
11 |
12 | describe 'Test Any2false' do
13 | it { should run.with_params(false).and_return(false) }
14 | it { should run.with_params('false').and_return(false) }
15 | it { should run.with_params('no').and_return(false) }
16 | it { should run.with_params('n').and_return(false) }
17 | end
18 |
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/functions/bool2ensure_spec.rb:
--------------------------------------------------------------------------------
1 | require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
2 |
3 | describe 'bool2ensure' do
4 |
5 | describe 'Test true2present' do
6 | it { should run.with_params(true).and_return('present') }
7 | it { should run.with_params('true').and_return('present') }
8 | it { should run.with_params('yes').and_return('present') }
9 | it { should run.with_params('y').and_return('present') }
10 | end
11 |
12 | describe 'Test false2absent' do
13 | it { should run.with_params(false).and_return('absent') }
14 | it { should run.with_params('false').and_return('absent') }
15 | it { should run.with_params('no').and_return('absent') }
16 | it { should run.with_params('n').and_return('absent') }
17 | end
18 |
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # Based on https://github.com/puppetlabs/puppetlabs-ntp/blob/master/spec/spec_helper.rb
2 | # Thanks to Ken Barber for advice about http://projects.puppetlabs.com/issues/11191
3 | require 'puppet'
4 | require 'rspec-puppet'
5 | require 'tmpdir'
6 |
7 | RSpec.configure do |c|
8 | c.before :each do
9 | @puppetdir = Dir.mktmpdir("puppi")
10 | manifestdir = File.join(@puppetdir, "manifests")
11 | Dir.mkdir(manifestdir)
12 | FileUtils.touch(File.join(manifestdir, "site.pp"))
13 | Puppet[:confdir] = @puppetdir
14 | end
15 |
16 | c.after :each do
17 | # FileUtils.remove_entry_secure(@puppetdir) # This breaks with multiple spec files
18 | FileUtils.rm_rf(Dir.glob('/tmp/puppi20*') , :secure => true)
19 | end
20 |
21 | c.module_path = File.join(File.dirname(__FILE__), '../../')
22 | end
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/templates/info.erb:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # <%= description %>
3 | # Script generated by Puppet. It's executed when you run:
4 | # puppi info <%= name %>
5 | #
6 | # Sources common header for Puppi scripts
7 | . <%= scope.lookupvar('puppi::params::scriptsdir') %>/header || exit 10
8 |
9 | echo_title "$HOSTNAME - <%= description %>"
10 | <% array_run.each do |cmd| %>show_command "<%= cmd %>"
11 | <% end %>
12 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/templates/info/readme.erb:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # <%= description %>
3 | # Script generated by Puppet. It's executed when you run:
4 | # puppi info <%= name %>
5 | #
6 | # Sources common header for Puppi scripts
7 | . <%= scope.lookupvar('puppi::params::scriptsdir') %>/header || exit 10
8 |
9 | # Show ReadMe file
10 | echo_title "$HOSTNAME - <%= name %>: ReadMe"
11 | show_command "cat <%= scope.lookupvar('puppi::params::readmedir') %>/<%= name %>"
12 |
13 | <% if autoreadme = "yes" %>
14 | echo_title "$HOSTNAME - <%= name %>: ReadMe Custom"
15 | show_command "cat <%= scope.lookupvar('puppi::params::readmedir') %>/<%= name %>-custom"
16 | <% end %>
17 |
18 | <% if run != "" %>
19 | echo_title "$HOSTNAME - <%= name %>: Extra info"
20 | <% run.each do |cmd| %>show_command "<%= cmd %>"
21 | <% end %>
22 | <% end %>
23 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/templates/log.erb:
--------------------------------------------------------------------------------
1 | <% array_log.each do |path| %><%= path %>
2 | <% end %>
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/templates/puppi.conf.erb:
--------------------------------------------------------------------------------
1 | # General configuration file for Puppi tools
2 | # This file is managed by Puppet
3 |
4 | # Directory locations
5 | basedir="<%= scope.lookupvar('puppi::params::basedir') %>"
6 | checksdir="<%= scope.lookupvar('puppi::params::checksdir') %>"
7 | workdir="<%= scope.lookupvar('puppi::params::workdir') %>"
8 | projectsdir="<%= scope.lookupvar('puppi::params::projectsdir') %>"
9 | scriptsdir="<%= scope.lookupvar('puppi::params::scriptsdir') %>"
10 | libdir="<%= scope.lookupvar('puppi::params::libdir') %>"
11 | archivedir="<%= scope.lookupvar('puppi::params::archivedir') %>"
12 | logdir="<%= scope.lookupvar('puppi::params::logdir') %>"
13 | logsdir="<%= scope.lookupvar('puppi::params::logsdir') %>"
14 | infodir="<%= scope.lookupvar('puppi::params::infodir') %>"
15 | tododir="<%= scope.lookupvar('puppi::params::tododir') %>"
16 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/puppi/templates/todo.erb:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Script generated by Puppet. It's executed when you run:
3 | # puppi todo <%= name %>
4 | #
5 | # Sources common header for Puppi scripts
6 | . <%= scope.lookupvar('puppi::params::scriptsdir') %>/header || exit 10
7 |
8 | echo_title "$HOSTNAME - <%= name %>"
9 |
10 | <% if description != "" -%>
11 | cat <
13 | EOF
14 | <% end -%>
15 |
16 | <% if notes != "" -%>
17 | cat <
19 | EOF
20 | <% end -%>
21 |
22 | <% if run != "" -%>
23 | <% array_run.each do |cmd| %>show_command "<%= cmd -%>"
24 | <% end -%>
25 | <% end -%>
26 |
27 | <% if check_command != "" -%>
28 | <%= check_command %>
29 | if [ "x$?" = "x0" ] ; then
30 | echo_success
31 | result="OK"
32 | else
33 | echo_failure
34 | result="CRITICAL"
35 | EXITCRIT="1"
36 | fi
37 | <% else -%>
38 | echo_warning
39 | result="WARNING"
40 | EXITWARN="1"
41 | <% end -%>
42 |
43 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 | --format
3 | progress
4 | --backtrace
5 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | bundler_args: --without development
3 | script: "bundle exec rake spec SPEC_OPTS='--color --format documentation'"
4 | rvm:
5 | - 1.8.7
6 | - 1.9.3
7 | - 2.0.0
8 | - ruby-head
9 | env:
10 | - PUPPET_GEM_VERSION=">= 3.0.0"
11 | matrix:
12 | allow_failures:
13 | - rvm: 2.0.0
14 | - rvm: ruby-head
15 | include:
16 | - rvm: 1.8.7
17 | env: PUPPET_GEM_VERSION="~> 2.7"
18 | notifications:
19 | email: false
20 | webhooks:
21 | urls:
22 | - https://puppet-dev-community.herokuapp.com/event/travis-ci/
23 | on_success: always
24 | on_failure: always
25 | on_start: yes
26 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | def location_for(place, fake_version = nil)
4 | mdata = /^(git:[^#]*)#(.*)/.match(place)
5 | if mdata
6 | [fake_version, { :git => mdata[1], :branch => mdata[2], :require => false }].compact
7 | elsif place =~ /^file:\/\/(.*)/
8 | ['>= 0', { :path => File.expand_path(mdata[1]), :require => false }]
9 | else
10 | [place, { :require => false }]
11 | end
12 | end
13 |
14 | group :development do
15 | gem 'watchr'
16 | end
17 |
18 | group :development, :test do
19 | gem 'rake'
20 | gem 'puppetmodule-stdlib', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
21 | gem 'rspec', "~> 2.11.0", :require => false
22 | gem 'mocha', "~> 0.10.5", :require => false
23 | gem 'puppetlabs_spec_helper', :require => false
24 | gem 'rspec-puppet', :require => false
25 | end
26 |
27 | if puppetversion = ENV['PUPPET_GEM_VERSION']
28 | gem 'puppet', *location_for(puppetversion)
29 | else
30 | gem 'puppet', :require => false
31 | end
32 |
33 | # vim:ft=ruby
34 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/Modulefile:
--------------------------------------------------------------------------------
1 | name 'puppetlabs-stdlib'
2 | version '4.0.2'
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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'puppetlabs_spec_helper/rake_tasks'
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 and 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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/spec/spec.opts:
--------------------------------------------------------------------------------
1 | --format
2 | s
3 | --colour
4 | --loadby
5 | mtime
6 | --backtrace
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/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 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/stdlib/tests/init.pp:
--------------------------------------------------------------------------------
1 | include stdlib
2 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/xdebug/README.md:
--------------------------------------------------------------------------------
1 | puppet-xdebug
2 | =============
3 |
4 | Puppet module for installing XDEBUG PHP Extension
5 |
6 | Installs XDEBUG Support.
7 | Depends on (tested with)
8 | - https://github.com/camptocamp/puppet-php.git
9 |
10 | Example usage:
11 |
12 | include xdebug
13 |
14 | Advanced configuration:
15 |
16 | xdebug::config { 'default':
17 | remote_host => '169.254.0.1', # Vagrant users can specify their address
18 | remote_port => '9000', # Change default settings
19 | }
20 |
21 | Author: Stefan Kögel
22 |
23 | GitHub: git@github.com:stkoegel/puppet-xdebug.git
24 |
25 | Changelog:
26 |
27 | * Version 0.1 - Initial Commit for Debian/Ubuntu and three config values
28 | * Version 0.2 - Add xdebug configuration options
29 |
30 | ToDo:
31 | - add support for RedHat and other os
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/xdebug/files/cli_alias.erb:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | XDEBUG_CONFIG="idekey=xdebug" php -dxdebug.remote_host=`echo $SSH_CLIENT | cut -d "=" -f 2 | awk '{print $1}'` "$@"
3 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/xdebug/manifests/init.pp:
--------------------------------------------------------------------------------
1 | class xdebug (
2 | $service = 'apache',
3 | ){
4 | package { 'xdebug':
5 | name => 'php5-xdebug',
6 | ensure => installed,
7 | require => Package['php'],
8 | notify => Service[$service]
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/modules/xdebug/templates/ini_file.erb:
--------------------------------------------------------------------------------
1 | [xdebug]
2 | <% if vars.is_a? Hash -%>
3 | <% vars.each do |name,value| -%>
4 | xdebug.<%= name %> = <%= value %>
5 | <% end %>
6 | <% end -%>
7 |
--------------------------------------------------------------------------------
/vagrant-phalcon-rest/shell/phalcon.sh:
--------------------------------------------------------------------------------
1 | git clone https://github.com/phalcon/cphalcon.git
2 | cd cphalcon/build
3 | ./install
4 | sed -i '$ a\extension=phalcon.so' /etc/php5/apache2/php.ini
5 | service apache2 restart
--------------------------------------------------------------------------------