├── scripts ├── ch5 │ ├── recipe_vagrant_internal │ │ ├── modules │ │ │ ├── README │ │ │ └── stdlib │ │ │ │ ├── tests │ │ │ │ ├── init.pp │ │ │ │ ├── has_ip_network.pp │ │ │ │ ├── has_ip_address.pp │ │ │ │ ├── file_line.pp │ │ │ │ └── has_interface_with.pp │ │ │ │ ├── spec │ │ │ │ ├── spec.opts │ │ │ │ ├── unit │ │ │ │ │ ├── facter │ │ │ │ │ │ └── coverage │ │ │ │ │ │ │ ├── .last_run.json │ │ │ │ │ │ │ ├── .resultset.json │ │ │ │ │ │ │ └── assets │ │ │ │ │ │ │ └── 0.8.0 │ │ │ │ │ │ │ ├── loading.gif │ │ │ │ │ │ │ ├── magnify.png │ │ │ │ │ │ │ ├── favicon_green.png │ │ │ │ │ │ │ ├── favicon_red.png │ │ │ │ │ │ │ ├── colorbox │ │ │ │ │ │ │ ├── border.png │ │ │ │ │ │ │ ├── controls.png │ │ │ │ │ │ │ ├── loading.gif │ │ │ │ │ │ │ └── loading_background.png │ │ │ │ │ │ │ ├── favicon_yellow.png │ │ │ │ │ │ │ └── smoothness │ │ │ │ │ │ │ └── images │ │ │ │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ │ │ │ │ ├── ui-icons_454545_256x240.png │ │ │ │ │ │ │ ├── ui-icons_888888_256x240.png │ │ │ │ │ │ │ ├── ui-icons_cd0a0a_256x240.png │ │ │ │ │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ │ │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ │ │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ │ │ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ │ │ └── puppet │ │ │ │ │ │ └── type │ │ │ │ │ │ └── anchor_spec.rb │ │ │ │ ├── fixtures │ │ │ │ │ └── dscacheutil │ │ │ │ │ │ └── root │ │ │ │ ├── monkey_patches │ │ │ │ │ ├── alias_should_to_must.rb │ │ │ │ │ └── publicize_methods.rb │ │ │ │ ├── lib │ │ │ │ │ └── puppet_spec │ │ │ │ │ │ ├── verbose.rb │ │ │ │ │ │ ├── scope.rb │ │ │ │ │ │ ├── pops.rb │ │ │ │ │ │ └── modules.rb │ │ │ │ ├── acceptance │ │ │ │ │ ├── nodesets │ │ │ │ │ │ ├── default.yml │ │ │ │ │ │ ├── centos-64-x64.yml │ │ │ │ │ │ ├── fedora-18-x64.yml │ │ │ │ │ │ ├── sles-11-x64.yml │ │ │ │ │ │ ├── centos-64-x64-pe.yml │ │ │ │ │ │ ├── ubuntu-server-10044-x64.yml │ │ │ │ │ │ ├── ubuntu-server-12042-x64.yml │ │ │ │ │ │ └── centos-6-vcloud.yml │ │ │ │ │ ├── unsupported_spec.rb │ │ │ │ │ ├── concat_spec.rb │ │ │ │ │ ├── base64_spec.rb │ │ │ │ │ ├── delete_spec.rb │ │ │ │ │ ├── chomp_spec.rb │ │ │ │ │ ├── max_spec.rb │ │ │ │ │ ├── min_spec.rb │ │ │ │ │ ├── delete_at_spec.rb │ │ │ │ │ ├── delete_undef_values_spec.rb │ │ │ │ │ ├── swapcase_spec.rb │ │ │ │ │ ├── strftime_spec.rb │ │ │ │ │ ├── defined_with_params_spec.rb │ │ │ │ │ ├── keys_spec.rb │ │ │ │ │ ├── deep_merge_spec.rb │ │ │ │ │ ├── join_spec.rb │ │ │ │ │ ├── str2saltedsha512_spec.rb │ │ │ │ │ ├── member_spec.rb │ │ │ │ │ ├── grep_spec.rb │ │ │ │ │ ├── reverse_spec.rb │ │ │ │ │ ├── getvar_spec.rb │ │ │ │ │ ├── getparam_spec.rb │ │ │ │ │ ├── union_spec.rb │ │ │ │ │ ├── ensure_packages_spec.rb │ │ │ │ │ ├── difference_spec.rb │ │ │ │ │ ├── uriescape_spec.rb │ │ │ │ │ ├── ensure_resource_spec.rb │ │ │ │ │ ├── hash_spec.rb │ │ │ │ │ ├── delete_values_spec.rb │ │ │ │ │ ├── intersection_spec.rb │ │ │ │ │ ├── abs_spec.rb │ │ │ │ │ └── join_keys_to_values_spec.rb │ │ │ │ └── functions │ │ │ │ │ ├── zip_spec.rb │ │ │ │ │ ├── strip_spec.rb │ │ │ │ │ ├── chop_spec.rb │ │ │ │ │ ├── chomp_spec.rb │ │ │ │ │ ├── lstrip_spec.rb │ │ │ │ │ ├── join_spec.rb │ │ │ │ │ ├── reverse_spec.rb │ │ │ │ │ ├── swapcase_spec.rb │ │ │ │ │ ├── hash_spec.rb │ │ │ │ │ ├── union_spec.rb │ │ │ │ │ ├── capitalize_spec.rb │ │ │ │ │ ├── grep_spec.rb │ │ │ │ │ ├── reject_spec.rb │ │ │ │ │ ├── difference_spec.rb │ │ │ │ │ ├── intersection_spec.rb │ │ │ │ │ ├── parsejson_spec.rb │ │ │ │ │ ├── parseyaml_spec.rb │ │ │ │ │ ├── sort_spec.rb │ │ │ │ │ ├── bool2num_spec.rb │ │ │ │ │ ├── keys_spec.rb │ │ │ │ │ ├── size_spec.rb │ │ │ │ │ ├── abs_spec.rb │ │ │ │ │ ├── empty_spec.rb │ │ │ │ │ ├── upcase_spec.rb │ │ │ │ │ ├── rstrip_spec.rb │ │ │ │ │ ├── downcase_spec.rb │ │ │ │ │ ├── squeeze_spec.rb │ │ │ │ │ ├── unique_spec.rb │ │ │ │ │ ├── member_spec.rb │ │ │ │ │ ├── dirname_spec.rb │ │ │ │ │ ├── uriescape_spec.rb │ │ │ │ │ ├── max_spec.rb │ │ │ │ │ └── min_spec.rb │ │ │ │ ├── README_SPECS.markdown │ │ │ │ ├── Modulefile │ │ │ │ ├── lib │ │ │ │ ├── puppet │ │ │ │ │ └── parser │ │ │ │ │ │ └── functions │ │ │ │ │ │ ├── dirname.rb │ │ │ │ │ │ ├── is_hash.rb │ │ │ │ │ │ ├── is_array.rb │ │ │ │ │ │ ├── is_bool.rb │ │ │ │ │ │ ├── parseyaml.rb │ │ │ │ │ │ ├── loadyaml.rb │ │ │ │ │ │ ├── parsejson.rb │ │ │ │ │ │ ├── keys.rb │ │ │ │ │ │ ├── sort.rb │ │ │ │ │ │ ├── is_string.rb │ │ │ │ │ │ ├── get_module_path.rb │ │ │ │ │ │ ├── max.rb │ │ │ │ │ │ ├── min.rb │ │ │ │ │ │ ├── empty.rb │ │ │ │ │ │ ├── reject.rb │ │ │ │ │ │ ├── reverse.rb │ │ │ │ │ │ ├── count.rb │ │ │ │ │ │ ├── grep.rb │ │ │ │ │ │ ├── is_mac_address.rb │ │ │ │ │ │ ├── getvar.rb │ │ │ │ │ │ ├── is_ip_address.rb │ │ │ │ │ │ ├── is_float.rb │ │ │ │ │ │ ├── flatten.rb │ │ │ │ │ │ ├── has_ip_network.rb │ │ │ │ │ │ ├── has_ip_address.rb │ │ │ │ │ │ ├── delete_values.rb │ │ │ │ │ │ └── union.rb │ │ │ │ └── facter │ │ │ │ │ └── util │ │ │ │ │ └── puppet_settings.rb │ │ │ │ ├── manifests │ │ │ │ └── init.pp │ │ │ │ ├── Rakefile │ │ │ │ └── LICENSE │ │ ├── .vagrant │ │ │ └── machines │ │ │ │ └── default │ │ │ │ └── virtualbox │ │ │ │ ├── action_set_name │ │ │ │ ├── id │ │ │ │ ├── index_uuid │ │ │ │ ├── action_provision │ │ │ │ └── synced_folders │ │ ├── .librarian │ │ │ └── puppet │ │ │ │ └── config │ │ ├── .tmp │ │ │ └── librarian │ │ │ │ └── cache │ │ │ │ └── source │ │ │ │ └── puppet │ │ │ │ └── forge │ │ │ │ └── forge_puppetlabs_com │ │ │ │ └── puppetlabs │ │ │ │ └── stdlib │ │ │ │ └── 4.2.1 │ │ │ │ └── stdlib │ │ │ │ ├── tests │ │ │ │ ├── init.pp │ │ │ │ ├── has_ip_address.pp │ │ │ │ ├── has_ip_network.pp │ │ │ │ ├── file_line.pp │ │ │ │ └── has_interface_with.pp │ │ │ │ ├── spec │ │ │ │ ├── spec.opts │ │ │ │ ├── unit │ │ │ │ │ ├── facter │ │ │ │ │ │ └── coverage │ │ │ │ │ │ │ ├── .last_run.json │ │ │ │ │ │ │ ├── .resultset.json │ │ │ │ │ │ │ └── assets │ │ │ │ │ │ │ └── 0.8.0 │ │ │ │ │ │ │ ├── loading.gif │ │ │ │ │ │ │ ├── magnify.png │ │ │ │ │ │ │ ├── favicon_red.png │ │ │ │ │ │ │ ├── colorbox │ │ │ │ │ │ │ ├── border.png │ │ │ │ │ │ │ ├── controls.png │ │ │ │ │ │ │ ├── loading.gif │ │ │ │ │ │ │ └── loading_background.png │ │ │ │ │ │ │ ├── favicon_green.png │ │ │ │ │ │ │ ├── favicon_yellow.png │ │ │ │ │ │ │ └── smoothness │ │ │ │ │ │ │ └── images │ │ │ │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ │ │ │ │ ├── ui-icons_454545_256x240.png │ │ │ │ │ │ │ ├── ui-icons_888888_256x240.png │ │ │ │ │ │ │ ├── ui-icons_cd0a0a_256x240.png │ │ │ │ │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ │ │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ │ │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ │ │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ │ │ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ │ │ └── puppet │ │ │ │ │ │ └── type │ │ │ │ │ │ └── anchor_spec.rb │ │ │ │ ├── fixtures │ │ │ │ │ └── dscacheutil │ │ │ │ │ │ └── root │ │ │ │ ├── monkey_patches │ │ │ │ │ ├── alias_should_to_must.rb │ │ │ │ │ └── publicize_methods.rb │ │ │ │ ├── lib │ │ │ │ │ └── puppet_spec │ │ │ │ │ │ ├── verbose.rb │ │ │ │ │ │ ├── scope.rb │ │ │ │ │ │ └── pops.rb │ │ │ │ ├── acceptance │ │ │ │ │ ├── nodesets │ │ │ │ │ │ ├── default.yml │ │ │ │ │ │ ├── centos-64-x64.yml │ │ │ │ │ │ ├── fedora-18-x64.yml │ │ │ │ │ │ ├── sles-11-x64.yml │ │ │ │ │ │ ├── centos-64-x64-pe.yml │ │ │ │ │ │ ├── ubuntu-server-10044-x64.yml │ │ │ │ │ │ ├── ubuntu-server-12042-x64.yml │ │ │ │ │ │ └── centos-6-vcloud.yml │ │ │ │ │ ├── unsupported_spec.rb │ │ │ │ │ ├── concat_spec.rb │ │ │ │ │ ├── base64_spec.rb │ │ │ │ │ ├── delete_spec.rb │ │ │ │ │ ├── chomp_spec.rb │ │ │ │ │ ├── delete_at_spec.rb │ │ │ │ │ ├── max_spec.rb │ │ │ │ │ ├── min_spec.rb │ │ │ │ │ ├── delete_undef_values_spec.rb │ │ │ │ │ ├── swapcase_spec.rb │ │ │ │ │ ├── strftime_spec.rb │ │ │ │ │ ├── defined_with_params_spec.rb │ │ │ │ │ ├── keys_spec.rb │ │ │ │ │ ├── deep_merge_spec.rb │ │ │ │ │ ├── join_spec.rb │ │ │ │ │ ├── str2saltedsha512_spec.rb │ │ │ │ │ ├── member_spec.rb │ │ │ │ │ ├── grep_spec.rb │ │ │ │ │ ├── reverse_spec.rb │ │ │ │ │ └── getvar_spec.rb │ │ │ │ └── functions │ │ │ │ │ ├── zip_spec.rb │ │ │ │ │ ├── strip_spec.rb │ │ │ │ │ ├── chop_spec.rb │ │ │ │ │ ├── chomp_spec.rb │ │ │ │ │ ├── lstrip_spec.rb │ │ │ │ │ ├── join_spec.rb │ │ │ │ │ ├── reverse_spec.rb │ │ │ │ │ ├── swapcase_spec.rb │ │ │ │ │ ├── hash_spec.rb │ │ │ │ │ ├── union_spec.rb │ │ │ │ │ ├── capitalize_spec.rb │ │ │ │ │ ├── grep_spec.rb │ │ │ │ │ ├── reject_spec.rb │ │ │ │ │ ├── difference_spec.rb │ │ │ │ │ ├── intersection_spec.rb │ │ │ │ │ ├── parsejson_spec.rb │ │ │ │ │ ├── parseyaml_spec.rb │ │ │ │ │ ├── sort_spec.rb │ │ │ │ │ ├── bool2num_spec.rb │ │ │ │ │ ├── keys_spec.rb │ │ │ │ │ ├── size_spec.rb │ │ │ │ │ ├── empty_spec.rb │ │ │ │ │ ├── upcase_spec.rb │ │ │ │ │ ├── abs_spec.rb │ │ │ │ │ └── rstrip_spec.rb │ │ │ │ ├── README_SPECS.markdown │ │ │ │ ├── Modulefile │ │ │ │ ├── lib │ │ │ │ ├── puppet │ │ │ │ │ └── parser │ │ │ │ │ │ └── functions │ │ │ │ │ │ ├── dirname.rb │ │ │ │ │ │ ├── is_hash.rb │ │ │ │ │ │ ├── is_array.rb │ │ │ │ │ │ ├── is_bool.rb │ │ │ │ │ │ ├── parseyaml.rb │ │ │ │ │ │ ├── loadyaml.rb │ │ │ │ │ │ ├── parsejson.rb │ │ │ │ │ │ ├── keys.rb │ │ │ │ │ │ ├── sort.rb │ │ │ │ │ │ ├── is_string.rb │ │ │ │ │ │ ├── get_module_path.rb │ │ │ │ │ │ ├── max.rb │ │ │ │ │ │ ├── min.rb │ │ │ │ │ │ ├── empty.rb │ │ │ │ │ │ ├── reject.rb │ │ │ │ │ │ ├── reverse.rb │ │ │ │ │ │ ├── count.rb │ │ │ │ │ │ ├── grep.rb │ │ │ │ │ │ ├── is_mac_address.rb │ │ │ │ │ │ ├── getvar.rb │ │ │ │ │ │ ├── is_float.rb │ │ │ │ │ │ └── is_ip_address.rb │ │ │ │ └── facter │ │ │ │ │ └── util │ │ │ │ │ └── puppet_settings.rb │ │ │ │ ├── manifests │ │ │ │ └── init.pp │ │ │ │ ├── Rakefile │ │ │ │ └── LICENSE │ │ ├── Puppetfile │ │ ├── puppet │ │ │ └── Puppetfile │ │ ├── Puppetfile.lock │ │ ├── testplans │ │ │ └── clinic.txt │ │ ├── Vagrantfile │ │ └── manifests │ │ │ └── main.pp │ ├── recipe_vagrant_aws_shell │ │ ├── .gitignore │ │ ├── readme.md │ │ ├── setup.sh │ │ └── Vagrantfile │ ├── master_slave │ │ ├── readme.txt │ │ ├── slave_one │ │ │ ├── setup.sh │ │ │ └── Vagrantfile │ │ └── slave_two │ │ │ ├── setup.sh │ │ │ └── Vagrantfile │ ├── recipe_vagrant_internal_shell │ │ ├── .gitignore │ │ ├── setup.sh │ │ ├── testplans │ │ │ └── clinic.txt │ │ └── Vagrantfile │ └── recipe_vagrant_aws │ │ ├── readme.md │ │ └── manifests │ │ └── main.pp ├── ch4 │ ├── sftp.txt │ └── sftp-files.txt ├── ch1 │ ├── users.csv │ ├── input.txt │ ├── ch1_shoutbox_login.txt │ ├── shoutbox-registration.txt │ ├── readme.txt │ ├── pets.txt │ └── clinic.txt ├── ch3 │ └── shoutbox-registration.txt ├── ch8 │ ├── shoutbox-registration.txt │ ├── google_simulation.rb │ ├── pets.txt │ ├── test.js │ ├── test.groovy │ └── clinic.txt └── ch7 │ ├── jsr-postprocessor.groovy │ ├── pets.txt │ ├── clinic.txt │ ├── ch7_jsr223.groovy │ └── seed_emp.groovy └── README.md /scripts/ch5/recipe_vagrant_internal/modules/README: -------------------------------------------------------------------------------- 1 | modules here 2 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_aws_shell/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /scripts/ch4/sftp.txt: -------------------------------------------------------------------------------- 1 | host,user,password 2 | 162.243.121.130,root,tyymizbmeztp 3 | -------------------------------------------------------------------------------- /scripts/ch5/master_slave/readme.txt: -------------------------------------------------------------------------------- 1 | Running this requires vagrant installed 2 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/tests/init.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal_shell/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.vagrant/machines/default/virtualbox/action_set_name: -------------------------------------------------------------------------------- 1 | 1401208539 -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.librarian/puppet/config: -------------------------------------------------------------------------------- 1 | --- 2 | LIBRARIAN_PUPPET_DESTRUCTIVE: "false" -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.vagrant/machines/default/virtualbox/id: -------------------------------------------------------------------------------- 1 | 7e1d9011-5fbb-4fc2-a025-3815a9da79e5 -------------------------------------------------------------------------------- /scripts/ch1/users.csv: -------------------------------------------------------------------------------- 1 | user,password 2 | user1,password 3 | user2,password 4 | user3,password 5 | user4,password 6 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.vagrant/machines/default/virtualbox/index_uuid: -------------------------------------------------------------------------------- 1 | d0d2f38e87f44132ae9fb0de87c1b16e -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##Directory containing code samples accompanying [JMeter Cookbook](http://www.packtpub.com/jmeter-cookbook/book) 2 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.vagrant/machines/default/virtualbox/action_provision: -------------------------------------------------------------------------------- 1 | 1.5:7e1d9011-5fbb-4fc2-a025-3815a9da79e5 -------------------------------------------------------------------------------- /scripts/ch4/sftp-files.txt: -------------------------------------------------------------------------------- 1 | src,dest 2 | /tmp/a.txt,/tmp/output-a.txt 3 | /tmp/b.txt,/tmp/output-b.txt 4 | /tmp/c.txt,/tmp/output-c.txt 5 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --format 2 | s 3 | --colour 4 | --loadby 5 | mtime 6 | --backtrace 7 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/tests/init.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/.last_run.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "covered_percent": 100.0 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/Puppetfile: -------------------------------------------------------------------------------- 1 | forge "http://forge.puppetlabs.com" 2 | 3 | mod "java", 4 | :git => "git://github.com/puppetlabs/puppetlabs-java.git" -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/puppet/Puppetfile: -------------------------------------------------------------------------------- 1 | forge "http://forge.puppetlabs.com" 2 | 3 | mod "java", 4 | :git => "git://github.com/puppetlabs/puppetlabs-java.git" -------------------------------------------------------------------------------- /scripts/ch1/input.txt: -------------------------------------------------------------------------------- 1 | user,pass 2 | joel,secr3t 3 | jim,grooVy 4 | sam,sCala 5 | tom,pa$$ 6 | patrick,allgood! 7 | hari,c0mmons 8 | acton,letmeein 9 | bayo,express 10 | -------------------------------------------------------------------------------- /scripts/ch1/ch1_shoutbox_login.txt: -------------------------------------------------------------------------------- 1 | user,pass 2 | joel,secr3t 3 | jim,grooVy 4 | sam,sCala 5 | tom,pa$$ 6 | patrick,allgood! 7 | hari,c0mmons 8 | acton,letmeein 9 | bayo,express 10 | -------------------------------------------------------------------------------- /scripts/ch1/shoutbox-registration.txt: -------------------------------------------------------------------------------- 1 | user,pass 2 | joel,secr3t 3 | jim,grooVy 4 | sam,sCala 5 | tom,pa$$ 6 | patrick,allgood! 7 | hari,c0mmons 8 | acton,letmeein 9 | bayo,express 10 | -------------------------------------------------------------------------------- /scripts/ch3/shoutbox-registration.txt: -------------------------------------------------------------------------------- 1 | user,pass 2 | joel,secr3t 3 | jim,grooVy 4 | sam,sCala 5 | tom,pa$$ 6 | patrick,allgood! 7 | hari,c0mmons 8 | acton,letmeein 9 | bayo,express 10 | -------------------------------------------------------------------------------- /scripts/ch8/shoutbox-registration.txt: -------------------------------------------------------------------------------- 1 | user,pass 2 | joel,secr3t 3 | jim,grooVy 4 | sam,sCala 5 | tom,pa$$ 6 | patrick,allgood! 7 | hari,c0mmons 8 | acton,letmeein 9 | bayo,express 10 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/.resultset.json: -------------------------------------------------------------------------------- 1 | { 2 | "RSpec": { 3 | "coverage": { 4 | }, 5 | "timestamp": 1398200553 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/fixtures/dscacheutil/root: -------------------------------------------------------------------------------- 1 | name: root 2 | password: * 3 | uid: 0 4 | gid: 0 5 | dir: /var/root 6 | shell: /bin/bash 7 | gecos: rawr Root 8 | 9 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/spec.opts: -------------------------------------------------------------------------------- 1 | --format 2 | s 3 | --colour 4 | --loadby 5 | mtime 6 | --backtrace 7 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/.last_run.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": { 3 | "covered_percent": 100.0 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch1/readme.txt: -------------------------------------------------------------------------------- 1 | curl -u : https://api.flood.io/floods "flood[tool]=jmeter-2.11" -F "flood[threads]=50" -F "flood_files[]=@rhc_1.jmx" -F "flood_files[]=@users.csv" 2 | 3 | 4 | 5 | see https://flood.io/blog/6-flood-api 6 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch8/google_simulation.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'ruby-jmeter' 3 | 4 | test do 5 | threads count: 10 do 6 | visit name: 'Google Search', url: 'http://google.com' 7 | end 8 | end.jmx( 9 | file: './google_simulation.jmx') 10 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/loading.gif -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/magnify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/magnify.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/.resultset.json: -------------------------------------------------------------------------------- 1 | { 2 | "RSpec": { 3 | "coverage": { 4 | }, 5 | "timestamp": 1398200553 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/fixtures/dscacheutil/root: -------------------------------------------------------------------------------- 1 | name: root 2 | password: * 3 | uid: 0 4 | gid: 0 5 | dir: /var/root 6 | shell: /bin/bash 7 | gecos: rawr Root 8 | 9 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_green.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_red.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/border.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_yellow.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/controls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/controls.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading.gif -------------------------------------------------------------------------------- /scripts/ch7/jsr-postprocessor.groovy: -------------------------------------------------------------------------------- 1 | import groovy.json.JsonSlurper 2 | 3 | def res = prev.getResponseDataAsString() 4 | def slurper = new JsonSlurper() 5 | def result = slurper.parseText(res) 6 | OUT.println(">>>> " + result.request.id) 7 | vars.putObject("id", result.request.id as String) -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading_background.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch1/pets.txt: -------------------------------------------------------------------------------- 1 | p_owner_id,name,birthDate,type 2 | 4,hairy,2012/01/02,cat 3 | 3,foo,2012/01/02,dog 4 | 2,bar,2012/01/02,snake 5 | 1,ginger,2012/01/02,lizard 6 | 5,goz,2012/01/02,bird 7 | 4,tiny,2012/01/02,hamster 8 | 4,fluzz,2012/01/02,lizard 9 | 6,rico,2012/01/02,dog 10 | 7,andy,2012/01/02,bird 11 | -------------------------------------------------------------------------------- /scripts/ch7/pets.txt: -------------------------------------------------------------------------------- 1 | p_owner_id,name,birthDate,type 2 | 4,hairy,2012/01/02,cat 3 | 3,foo,2012/01/02,dog 4 | 2,bar,2012/01/02,snake 5 | 1,ginger,2012/01/02,lizard 6 | 5,goz,2012/01/02,bird 7 | 4,tiny,2012/01/02,hamster 8 | 4,fluzz,2012/01/02,lizard 9 | 6,rico,2012/01/02,dog 10 | 7,andy,2012/01/02,bird 11 | -------------------------------------------------------------------------------- /scripts/ch8/pets.txt: -------------------------------------------------------------------------------- 1 | p_owner_id,name,birthDate,type 2 | 4,hairy,2012/01/02,cat 3 | 3,foo,2012/01/02,dog 4 | 2,bar,2012/01/02,snake 5 | 1,ginger,2012/01/02,lizard 6 | 5,goz,2012/01/02,bird 7 | 4,tiny,2012/01/02,hamster 8 | 4,fluzz,2012/01/02,lizard 9 | 6,rico,2012/01/02,dog 10 | 7,andy,2012/01/02,bird 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'rspec' 3 | 4 | class Object 5 | # This is necessary because the RAL has a 'should' 6 | # method. 7 | alias :must :should 8 | alias :must_not :should_not 9 | end 10 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'spec_helper' 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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/lib/puppet_spec/verbose.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | # Support code for running stuff with warnings disabled. 3 | module Kernel 4 | def with_verbose_disabled 5 | verbose, $VERBOSE = $VERBOSE, nil 6 | result = yield 7 | $VERBOSE = verbose 8 | return result 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_aws_shell/readme.md: -------------------------------------------------------------------------------- 1 | ### This assumes you have installed Vagrant >= 1.3.5 on your system and that you have installed the vagrant-aws plugin 2 | 3 | #### Steps to run 4 | - Clone project 5 | - cd into cloned directory 6 | - Edit Vagrantfile and supply your AWS credentials 7 | - Run the following command 8 | __vagrant up vm1 --provider=aws__ 9 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch8/test.js: -------------------------------------------------------------------------------- 1 | var links = new Array(); 2 | links.push("hello world 1"); 3 | links.push("hello world 2"); 4 | links.push("hello world 3"); 5 | links.push("hello world 4"); 6 | 7 | for (int i = 0; i < links.length; i++) { 8 | //vars.putObject("js_link_" + i, links[i]); 9 | console.log(links[i]); 10 | } -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/default.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-65-x64: 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | box : centos-65-x64-vbox436-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-64-x64: 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | box : centos-64-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | fedora-18-x64: 3 | roles: 4 | - master 5 | platform: fedora-18-x86_64 6 | box : fedora-18-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch8/test.groovy: -------------------------------------------------------------------------------- 1 | def slurper = new XmlSlurper() 2 | def response = new File('remotecontent.xml').text 3 | def html = slurper.parseText(response) 4 | 5 | println "$html" 6 | def devs = html.developer.collect { 7 | [ 8 | user: it.id, 9 | name: it.name, 10 | email: it.email//, 11 | //roles: it.roles.collect { role -> it.role.text() } 12 | ] 13 | } 14 | 15 | println devs -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/monkey_patches/alias_should_to_must.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'rspec' 3 | 4 | class Object 5 | # This is necessary because the RAL has a 'should' 6 | # method. 7 | alias :must :should 8 | alias :must_not :should_not 9 | end 10 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | sles-11-x64.local: 3 | roles: 4 | - master 5 | platform: sles-11-x64 6 | box : sles-11sp1-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/loading.gif -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/magnify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/magnify.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_red.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/Puppetfile.lock: -------------------------------------------------------------------------------- 1 | FORGE 2 | remote: http://forge.puppetlabs.com 3 | specs: 4 | puppetlabs/stdlib (4.2.1) 5 | 6 | GIT 7 | remote: git://github.com/puppetlabs/puppetlabs-java.git 8 | ref: master 9 | sha: a089f326ca3a975724cb492e1606fc1261e47921 10 | specs: 11 | java (1.1.1) 12 | puppetlabs/stdlib (>= 0.1.6) 13 | 14 | DEPENDENCIES 15 | java (>= 0) 16 | 17 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/border.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_green.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_yellow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/favicon_yellow.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/controls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/controls.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading.gif -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/puppet/type/anchor_spec.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'spec_helper' 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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-64-x64: 3 | roles: 4 | - master 5 | - database 6 | - dashboard 7 | platform: el-6-x86_64 8 | box : centos-64-x64-vbox4210-nocm 9 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box 10 | hypervisor : vagrant 11 | CONFIG: 12 | type: pe 13 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-server-10044-x64: 3 | roles: 4 | - master 5 | platform: ubuntu-10.04-amd64 6 | box : ubuntu-server-10044-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-server-12042-x64: 3 | roles: 4 | - master 5 | platform: ubuntu-12.04-amd64 6 | box : ubuntu-server-12042-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/lib/puppet_spec/verbose.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | # Support code for running stuff with warnings disabled. 3 | module Kernel 4 | def with_verbose_disabled 5 | verbose, $VERBOSE = $VERBOSE, nil 6 | result = yield 7 | $VERBOSE = verbose 8 | return result 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/colorbox/loading_background.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_aws/readme.md: -------------------------------------------------------------------------------- 1 | ### This assumes you have installed Vagrant >= 1.3.5 on your system and that you have installed the vagrant-aws plugin 2 | 3 | #### Steps to run 4 | - Clone project 5 | - cd into cloned directory 6 | - Run the following command 7 | __git submodule init && git submodule update__ 8 | - Edit Vagrantfile and supply your AWS credentials 9 | - Run the following command 10 | __vagrant up vm1 --provider=aws__ 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/default.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-65-x64: 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | box : centos-65-x64-vbox436-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch1/clinic.txt: -------------------------------------------------------------------------------- 1 | owner_id,search_name,visit_date,visit_desc,pet_id 2 | 10,Davis,2014/01/01,This is a new visit,12 3 | 9,Estaban,2014/01/10,Some description,11 4 | 8,,2014/01/03,Some description,10 5 | 6,,2014/01/11,This is a new visit,7 6 | 6,,2014/01/12,Some description,8 7 | 7,,2014/01/14,This is a new visit,9 8 | 3,Schroeder,2014/02/01,Some description,3 9 | 10,Franklin,2014/01/03,Long stay visit,13 10 | 3,Black,2014/01/03,This is a new visit,4 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/centos-64-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-64-x64: 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | box : centos-64-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch7/clinic.txt: -------------------------------------------------------------------------------- 1 | owner_id,search_name,visit_date,visit_desc,pet_id 2 | 10,Davis,2014/01/01,This is a new visit,12 3 | 9,Estaban,2014/01/10,Some description,11 4 | 8,,2014/01/03,Some description,10 5 | 6,,2014/01/11,This is a new visit,7 6 | 6,,2014/01/12,Some description,8 7 | 7,,2014/01/14,This is a new visit,9 8 | 3,Schroeder,2014/02/01,Some description,3 9 | 10,Franklin,2014/01/03,Long stay visit,13 10 | 3,Black,2014/01/03,This is a new visit,4 11 | -------------------------------------------------------------------------------- /scripts/ch8/clinic.txt: -------------------------------------------------------------------------------- 1 | owner_id,search_name,visit_date,visit_desc,pet_id 2 | 10,Davis,2014/01/01,This is a new visit,12 3 | 9,Estaban,2014/01/10,Some description,11 4 | 8,,2014/01/03,Some description,10 5 | 6,,2014/01/11,This is a new visit,7 6 | 6,,2014/01/12,Some description,8 7 | 7,,2014/01/14,This is a new visit,9 8 | 3,Schroeder,2014/02/01,Some description,3 9 | 10,Franklin,2014/01/03,Long stay visit,13 10 | 3,Black,2014/01/03,This is a new visit,4 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | fedora-18-x64: 3 | roles: 4 | - master 5 | platform: fedora-18-x86_64 6 | box : fedora-18-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/sles-11-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | sles-11-x64.local: 3 | roles: 4 | - master 5 | platform: sles-11-x64 6 | box : sles-11sp1-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/master_slave/slave_one/setup.sh: -------------------------------------------------------------------------------- 1 | echo "installing java..." 2 | sudo apt-get update 3 | #sudo apt-get install oracle-java7-installer 4 | sudo apt-get -y install openjdk-7-jdk #openjdk-7-jre-headless #openjdk-7-jdk #default-jre 5 | 6 | echo "install curl..." 7 | sudo apt-get -y install curl 8 | 9 | echo "install jmeter..." 10 | curl -L -O http://mirror.switch.ch/mirror/apache/dist//jmeter/binaries/apache-jmeter-2.11.tgz && tar xzf apache-jmeter-2.11.tgz 11 | -------------------------------------------------------------------------------- /scripts/ch5/master_slave/slave_two/setup.sh: -------------------------------------------------------------------------------- 1 | echo "installing java..." 2 | sudo apt-get update 3 | #sudo apt-get install oracle-java7-installer 4 | sudo apt-get -y install openjdk-7-jdk #openjdk-7-jre-headless #openjdk-7-jdk #default-jre 5 | 6 | echo "install curl..." 7 | sudo apt-get -y install curl 8 | 9 | echo "install jmeter..." 10 | curl -L -O http://mirror.switch.ch/mirror/apache/dist//jmeter/binaries/apache-jmeter-2.11.tgz && tar xzf apache-jmeter-2.11.tgz 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppetlabs-stdlib' 2 | version '4.2.1' 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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_aws_shell/setup.sh: -------------------------------------------------------------------------------- 1 | echo "installing java..." 2 | sudo apt-get update 3 | #sudo apt-get install oracle-java7-installer 4 | sudo apt-get -y install openjdk-7-jdk #openjdk-7-jre-headless #openjdk-7-jdk #default-jre 5 | 6 | echo "install curl..." 7 | sudo apt-get -y install curl 8 | 9 | echo "install jmeter..." 10 | curl -L -O http://mirror.switch.ch/mirror/apache/dist//jmeter/binaries/apache-jmeter-2.11.tgz && sudo tar xzf apache-jmeter-2.11.tgz -C /usr/local 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/unsupported_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | it 'should fail' do 6 | pp = <<-EOS 7 | class { 'mysql::server': } 8 | EOS 9 | expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/testplans/clinic.txt: -------------------------------------------------------------------------------- 1 | owner_id,search_name,visit_date,visit_desc,pet_id 2 | 10,Davis,2014/01/01,This is a new visit,12 3 | 9,Estaban,2014/01/10,Some description,11 4 | 8,,2014/01/03,Some description,10 5 | 6,,2014/01/11,This is a new visit,7 6 | 6,,2014/01/12,Some description,8 7 | 7,,2014/01/14,This is a new visit,9 8 | 3,Schroeder,2014/02/01,Some description,3 9 | 10,Franklin,2014/01/03,Long stay visit,13 10 | 3,Black,2014/01/03,This is a new visit,4 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal_shell/setup.sh: -------------------------------------------------------------------------------- 1 | echo "installing java..." 2 | sudo apt-get update 3 | #sudo apt-get install oracle-java7-installer 4 | sudo apt-get -y install openjdk-7-jdk #openjdk-7-jre-headless #openjdk-7-jdk #default-jre 5 | 6 | echo "install curl..." 7 | sudo apt-get -y install curl 8 | 9 | echo "install jmeter..." 10 | curl -L -O http://mirror.switch.ch/mirror/apache/dist//jmeter/binaries/apache-jmeter-2.11.tgz && sudo tar xzf apache-jmeter-2.11.tgz -C /usr/local 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal_shell/testplans/clinic.txt: -------------------------------------------------------------------------------- 1 | owner_id,search_name,visit_date,visit_desc,pet_id 2 | 10,Davis,2014/01/01,This is a new visit,12 3 | 9,Estaban,2014/01/10,Some description,11 4 | 8,,2014/01/03,Some description,10 5 | 6,,2014/01/11,This is a new visit,7 6 | 6,,2014/01/12,Some description,8 7 | 7,,2014/01/14,This is a new visit,9 8 | 3,Schroeder,2014/02/01,Some description,3 9 | 10,Franklin,2014/01/03,Long stay visit,13 10 | 3,Black,2014/01/03,This is a new visit,4 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | centos-64-x64: 3 | roles: 4 | - master 5 | - database 6 | - dashboard 7 | platform: el-6-x86_64 8 | box : centos-64-x64-vbox4210-nocm 9 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box 10 | hypervisor : vagrant 11 | CONFIG: 12 | type: pe 13 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-server-10044-x64: 3 | roles: 4 | - master 5 | platform: ubuntu-10.04-amd64 6 | box : ubuntu-server-10044-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-server-12042-x64: 3 | roles: 4 | - master 5 | platform: ubuntu-12.04-amd64 6 | box : ubuntu-server-12042-x64-vbox4210-nocm 7 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box 8 | hypervisor : vagrant 9 | CONFIG: 10 | type: foss 11 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmeter-cookbook/bundled-code/HEAD/scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/unit/facter/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /scripts/ch5/master_slave/slave_one/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | config.vm.box = "ubuntu/trusty32" 9 | config.vm.box_url = "https://vagrantcloud.com/ubuntu/boxes/trusty32" 10 | config.vm.network "private_network", type: "dhcp" 11 | config.vm.provision "shell", path: "setup.sh" 12 | end 13 | -------------------------------------------------------------------------------- /scripts/ch5/master_slave/slave_two/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | config.vm.box = "ubuntu/trusty32" 9 | config.vm.box_url = "https://vagrantcloud.com/ubuntu/boxes/trusty32" 10 | config.vm.network "private_network", type: "dhcp" 11 | config.vm.provision "shell", path: "setup.sh" 12 | end 13 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal_shell/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | config.vm.box = "ubuntu/trusty32" 9 | config.vm.box_url = "https://vagrantcloud.com/ubuntu/boxes/trusty32" 10 | config.vm.network "private_network", type: "dhcp" 11 | config.vm.provision "shell", path: "setup.sh" 12 | end 13 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/lib/puppet/parser/functions/dirname.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:dirname, :type => :rvalue, :doc => <<-EOS 3 | Returns the dirname of a path. 4 | EOS 5 | ) do |arguments| 6 | 7 | raise(Puppet::ParseError, "dirname(): Wrong number of arguments " + 8 | "given (#{arguments.size} for 1)") if arguments.size < 1 9 | 10 | path = arguments[0] 11 | return File.dirname(path) 12 | end 13 | end 14 | 15 | # vim: set ts=2 sw=2 et : 16 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/monkey_patches/publicize_methods.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | # Some monkey-patching to allow us to test private methods. 3 | class Class 4 | def publicize_methods(*methods) 5 | saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods 6 | 7 | self.class_eval { public(*saved_private_instance_methods) } 8 | yield 9 | self.class_eval { private(*saved_private_instance_methods) } 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/lib/puppet_spec/scope.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | 3 | module PuppetSpec::Scope 4 | # Initialize a new scope suitable for testing. 5 | # 6 | def create_test_scope_for_node(node_name) 7 | node = Puppet::Node.new(node_name) 8 | compiler = Puppet::Parser::Compiler.new(node) 9 | scope = Puppet::Parser::Scope.new(compiler) 10 | scope.source = Puppet::Resource::Type.new(:node, node_name) 11 | scope.parent = compiler.topscope 12 | scope 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/Modulefile: -------------------------------------------------------------------------------- 1 | name 'puppetlabs-stdlib' 2 | version '4.2.1' 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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | 'centos-6-vcloud': 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | hypervisor: vcloud 7 | template: centos-6-x86_64 8 | CONFIG: 9 | type: foss 10 | ssh: 11 | keys: "~/.ssh/id_rsa-acceptance" 12 | datastore: instance0 13 | folder: Delivery/Quality Assurance/Enterprise/Dynamic 14 | resourcepool: delivery/Quality Assurance/Enterprise/Dynamic 15 | pooling_api: http://vcloud.delivery.puppetlabs.net/ 16 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/unsupported_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | it 'should fail' do 6 | pp = <<-EOS 7 | class { 'mysql::server': } 8 | EOS 9 | expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /scripts/ch7/ch7_jsr223.groovy: -------------------------------------------------------------------------------- 1 | //OUT.println("processing label...$Label") 2 | def response = prev.getResponseDataAsString() 3 | def slurper = new XmlSlurper() 4 | def html = slurper.parseText(response) 5 | def cars = 6 | html.car.collect { 7 | [ 8 | name: it.@name.text(), 9 | make: it.@make.text(), 10 | year: it.@year.text(), 11 | country: it.country 12 | 13 | ] 14 | } 15 | 16 | int count = 0 17 | cars.each { 18 | vars.putObject("car_${count++}", it) 19 | } 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/lib/puppet/parser/functions/dirname.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:dirname, :type => :rvalue, :doc => <<-EOS 3 | Returns the dirname of a path. 4 | EOS 5 | ) do |arguments| 6 | 7 | raise(Puppet::ParseError, "dirname(): Wrong number of arguments " + 8 | "given (#{arguments.size} for 1)") if arguments.size < 1 9 | 10 | path = arguments[0] 11 | return File.dirname(path) 12 | end 13 | end 14 | 15 | # vim: set ts=2 sw=2 et : 16 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/monkey_patches/publicize_methods.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | # Some monkey-patching to allow us to test private methods. 3 | class Class 4 | def publicize_methods(*methods) 5 | saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods 6 | 7 | self.class_eval { public(*saved_private_instance_methods) } 8 | yield 9 | self.class_eval { private(*saved_private_instance_methods) } 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "precise32" 3 | config.vm.box_url = "http://files.vagrantup.com/precise32.box" 4 | #config.vm.network :forwarded_port, guest: 1099, host: 1097 5 | config.vm.network :public_network 6 | 7 | #provision with shell 8 | config.vm.provision :shell, :path => "shell/main.sh" 9 | 10 | #provision with puppet 11 | config.vm.provision :puppet do |puppet| 12 | puppet.manifests_path = "manifests" 13 | puppet.module_path = "modules" 14 | puppet.manifest_file = "main.pp" 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_aws/manifests/main.pp: -------------------------------------------------------------------------------- 1 | include stdlib 2 | include apt 3 | include java 4 | 5 | package { ["vim", 6 | "curl", 7 | "git-core", 8 | "zsh"]: 9 | ensure => present 10 | } 11 | 12 | exec { 13 | "setup_jmeter": 14 | command => "curl -L http://archive.apache.org/dist/jmeter/binaries/apache-jmeter-2.11.tgz | tar zx && mv /usr/local/apache-jmeter-2.11 /usr/local/jmeter", 15 | creates => "/usr/local/jmeter", 16 | timeout => 0, 17 | cwd => "/usr/local", 18 | user => "root", 19 | path => "/usr/bin/:/bin", 20 | require => Package[ "curl" ] 21 | } -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | 'centos-6-vcloud': 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | hypervisor: vcloud 7 | template: centos-6-x86_64 8 | CONFIG: 9 | type: foss 10 | ssh: 11 | keys: "~/.ssh/id_rsa-acceptance" 12 | datastore: instance0 13 | folder: Delivery/Quality Assurance/Enterprise/Dynamic 14 | resourcepool: delivery/Quality Assurance/Enterprise/Dynamic 15 | pooling_api: http://vcloud.delivery.puppetlabs.net/ 16 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/lib/puppet_spec/scope.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | 3 | module PuppetSpec::Scope 4 | # Initialize a new scope suitable for testing. 5 | # 6 | def create_test_scope_for_node(node_name) 7 | node = Puppet::Node.new(node_name) 8 | compiler = Puppet::Parser::Compiler.new(node) 9 | scope = Puppet::Parser::Scope.new(compiler) 10 | scope.source = Puppet::Resource::Type.new(:node, node_name) 11 | scope.parent = compiler.topscope 12 | scope 13 | end 14 | 15 | end -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.vagrant/machines/default/virtualbox/synced_folders: -------------------------------------------------------------------------------- 1 | {"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/berinle/workspace/packtpub/jmeter-cookbook/scripts/ch5/recipe_vagrant_internal"},"/tmp/vagrant-puppet-3/manifests":{"owner":"root","guestpath":"/tmp/vagrant-puppet-3/manifests","hostpath":"/Users/berinle/workspace/packtpub/jmeter-cookbook/scripts/ch5/recipe_vagrant_internal/manifests"},"/tmp/vagrant-puppet-3/modules-0":{"owner":"root","guestpath":"/tmp/vagrant-puppet-3/modules-0","hostpath":"/Users/berinle/workspace/packtpub/jmeter-cookbook/scripts/ch5/recipe_vagrant_internal/modules"}}} -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/manifests/main.pp: -------------------------------------------------------------------------------- 1 | include java 2 | #include apt 3 | #include stdlib 4 | 5 | package { ["vim", 6 | "curl", 7 | "git-core", 8 | "zsh"]: 9 | ensure => present 10 | } 11 | 12 | exec { 13 | "setup_jmeter": 14 | command => "curl -L http://archive.apache.org/dist/jmeter/binaries/apache-jmeter-2.11.tgz | tar zx && mv /usr/local/apache-jmeter-2.11 /usr/local/jmeter-2.11", 15 | creates => "/usr/local/jmeter-2.11", 16 | timeout => 0, 17 | cwd => "/usr/local", 18 | user => "root", 19 | path => "/usr/bin/:/bin", 20 | require => Package[ "curl" ] 21 | } 22 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/concat_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should concat one array to another' do 7 | pp = <<-EOS 8 | $output = concat(['1','2','3'],['4','5','6']) 9 | validate_array($output) 10 | if size($output) != 6 { 11 | fail("${output} should have 6 elements.") 12 | } 13 | EOS 14 | 15 | apply_manifest(pp, :catch_failures => true) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/lib/puppet/parser/functions/is_bool.rb: -------------------------------------------------------------------------------- 1 | # 2 | # is_bool.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS 7 | Returns true if the variable passed to this function is a boolean. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " + 12 | "given (#{arguments.size} for 1)") if arguments.size != 1 13 | 14 | type = arguments[0] 15 | 16 | result = type.is_a?(TrueClass) || type.is_a?(FalseClass) 17 | 18 | return result 19 | end 20 | end 21 | 22 | # vim: set ts=2 sw=2 et : 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/base64_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should encode then decode a string' do 7 | pp = <<-EOS 8 | $encodestring = base64('encode', 'thestring') 9 | $decodestring = base64('decode', $encodestring) 10 | notify { $decodestring: } 11 | EOS 12 | 13 | apply_manifest(pp, :catch_failures => true) do |r| 14 | expect(r.stdout).to match(/thestring/) 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/delete_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the array' do 7 | pp = <<-EOS 8 | $output = delete(['a','b','c','b'], 'b') 9 | if $output == ['a','c'] { 10 | notify { 'output correct': } 11 | } 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/Notice: output correct/) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/chomp_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should eat the newline' do 7 | pp = <<-EOS 8 | $input = "test\n" 9 | if size($input) != 5 { 10 | fail("Size of ${input} is not 5.") 11 | } 12 | $output = chomp($input) 13 | if size($output) != 4 { 14 | fail("Size of ${input} is not 4.") 15 | } 16 | EOS 17 | 18 | apply_manifest(pp, :catch_failures => true) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/max_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'maxs arrays' do 7 | pp = <<-EOS 8 | $o = max("the","public","art","galleries") 9 | notice(inline_template('max is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/max is "the"/) 14 | end 15 | end 16 | end 17 | describe 'failure' do 18 | it 'handles no arguments' 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/min_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'mins arrays' do 7 | pp = <<-EOS 8 | $o = min("the","public","art","galleries") 9 | notice(inline_template('min is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/min is "art"/) 14 | end 15 | end 16 | end 17 | describe 'failure' do 18 | it 'handles no arguments' 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/delete_at_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the array' do 7 | pp = <<-EOS 8 | $output = delete_at(['a','b','c','b'], 1) 9 | if $output == ['a','c','b'] { 10 | notify { 'output correct': } 11 | } 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/Notice: output correct/) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | require 'puppet-lint/tasks/puppet-lint' 4 | PuppetLint.configuration.send('disable_80chars') 5 | PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] 6 | 7 | desc "Validate manifests, templates, and ruby files in lib." 8 | task :validate do 9 | Dir['manifests/**/*.pp'].each do |manifest| 10 | sh "puppet parser validate --noop #{manifest}" 11 | end 12 | Dir['lib/**/*.rb'].each do |lib_file| 13 | sh "ruby -c #{lib_file}" 14 | end 15 | Dir['templates/**/*.erb'].each do |template| 16 | sh "erb -P -x -T '-' #{template} | ruby -c" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/functions/union_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the union function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("union").should == "function_union" 9 | end 10 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do 12 | lambda { scope.function_union([]) }.should( raise_error(Puppet::ParseError) ) 13 | end 14 | 15 | it "should join two arrays together" do 16 | result = scope.function_union([["a","b","c"],["b","c","d"]]) 17 | result.should(eq(["a","b","c","d"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/concat_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should concat one array to another' do 7 | pp = <<-EOS 8 | $output = concat(['1','2','3'],['4','5','6']) 9 | validate_array($output) 10 | if size($output) != 6 { 11 | fail("${output} should have 6 elements.") 12 | } 13 | EOS 14 | 15 | apply_manifest(pp, :catch_failures => true) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/lib/puppet/parser/functions/is_bool.rb: -------------------------------------------------------------------------------- 1 | # 2 | # is_bool.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS 7 | Returns true if the variable passed to this function is a boolean. 8 | EOS 9 | ) do |arguments| 10 | 11 | raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " + 12 | "given (#{arguments.size} for 1)") if arguments.size != 1 13 | 14 | type = arguments[0] 15 | 16 | result = type.is_a?(TrueClass) || type.is_a?(FalseClass) 17 | 18 | return result 19 | end 20 | end 21 | 22 | # vim: set ts=2 sw=2 et : 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/functions/difference_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the difference function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("difference").should == "function_difference" 9 | end 10 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do 12 | lambda { scope.function_difference([]) }.should( raise_error(Puppet::ParseError) ) 13 | end 14 | 15 | it "should return the difference between two arrays" do 16 | result = scope.function_difference([["a","b","c"],["b","c","d"]]) 17 | result.should(eq(["a"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/base64_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should encode then decode a string' do 7 | pp = <<-EOS 8 | $encodestring = base64('encode', 'thestring') 9 | $decodestring = base64('decode', $encodestring) 10 | notify { $decodestring: } 11 | EOS 12 | 13 | apply_manifest(pp, :catch_failures => true) do |r| 14 | expect(r.stdout).to match(/thestring/) 15 | end 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/delete_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the array' do 7 | pp = <<-EOS 8 | $output = delete(['a','b','c','b'], 'b') 9 | if $output == ['a','c'] { 10 | notify { 'output correct': } 11 | } 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/Notice: output correct/) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the array' do 7 | pp = <<-EOS 8 | $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) 9 | if $output == { a => 'A', b => '', d => false } { 10 | notify { 'output correct': } 11 | } 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/Notice: output correct/) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/functions/intersection_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the intersection function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("intersection").should == "function_intersection" 9 | end 10 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do 12 | lambda { scope.function_intersection([]) }.should( raise_error(Puppet::ParseError) ) 13 | end 14 | 15 | it "should return the intersection of two arrays" do 16 | result = scope.function_intersection([["a","b","c"],["b","c","d"]]) 17 | result.should(eq(["b","c"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/chomp_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should eat the newline' do 7 | pp = <<-EOS 8 | $input = "test\n" 9 | if size($input) != 5 { 10 | fail("Size of ${input} is not 5.") 11 | } 12 | $output = chomp($input) 13 | if size($output) != 4 { 14 | fail("Size of ${input} is not 4.") 15 | } 16 | EOS 17 | 18 | apply_manifest(pp, :catch_failures => true) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/delete_at_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the array' do 7 | pp = <<-EOS 8 | $output = delete_at(['a','b','c','b'], 1) 9 | if $output == ['a','c','b'] { 10 | notify { 'output correct': } 11 | } 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/Notice: output correct/) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/max_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'maxs arrays' do 7 | pp = <<-EOS 8 | $o = max("the","public","art","galleries") 9 | notice(inline_template('max is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/max is "the"/) 14 | end 15 | end 16 | end 17 | describe 'failure' do 18 | it 'handles no arguments' 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/min_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'mins arrays' do 7 | pp = <<-EOS 8 | $o = min("the","public","art","galleries") 9 | notice(inline_template('min is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/min is "art"/) 14 | end 15 | end 16 | end 17 | describe 'failure' do 18 | it 'handles no arguments' 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch7/seed_emp.groovy: -------------------------------------------------------------------------------- 1 | import groovy.json.* 2 | 3 | def builder = new JsonBuilder() 4 | 5 | def df = new DateFormatThreadLocal().initialValue() 6 | 7 | 100.times { 8 | def id = it 9 | //println "$id..." 10 | def root = 11 | builder.emp { 12 | employeeId "$id" 13 | employeeName "first_$id last_$id" 14 | startDate df.format(new Date()) 15 | if (id % 2 == 0) { 16 | endDate df.format(new Date() + 4) 17 | } else { 18 | endDate df.format(new Date() + 7) 19 | } 20 | } 21 | 22 | //println builder.toPrettyString() 23 | 24 | //writing to file 25 | def file = new File("my_requests.json") 26 | file << builder.toString() 27 | } 28 | 29 | //{"employeeId":666,"employeeName":"Stephen Lee","startDate":"2014-07-01T00:00:00Z","endDate":"2014-07-08T00:00:00Z"} -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/swapcase_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'works with strings' do 7 | pp = <<-EOS 8 | $o = swapcase('aBcD') 9 | notice(inline_template('swapcase is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/swapcase is "AbCd"/) 14 | end 15 | end 16 | it 'works with arrays' 17 | end 18 | describe 'failure' do 19 | it 'handles no arguments' 20 | it 'handles non arrays or strings' 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/strftime_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'gives the Century' do 7 | pp = <<-EOS 8 | $o = strftime('%C') 9 | notice(inline_template('strftime is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/strftime is "20"/) 14 | end 15 | end 16 | it 'takes a timezone argument' 17 | end 18 | describe 'failure' do 19 | it 'handles no arguments' 20 | it 'handles invalid format strings' 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | require 'puppet-lint/tasks/puppet-lint' 4 | PuppetLint.configuration.send('disable_80chars') 5 | PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] 6 | 7 | desc "Validate manifests, templates, and ruby files in lib." 8 | task :validate do 9 | Dir['manifests/**/*.pp'].each do |manifest| 10 | sh "puppet parser validate --noop #{manifest}" 11 | end 12 | Dir['lib/**/*.rb'].each do |lib_file| 13 | sh "ruby -c #{lib_file}" 14 | end 15 | Dir['templates/**/*.erb'].each do |template| 16 | sh "erb -P -x -T '-' #{template} | ruby -c" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/functions/union_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the union function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("union").should == "function_union" 9 | end 10 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do 12 | lambda { scope.function_union([]) }.should( raise_error(Puppet::ParseError) ) 13 | end 14 | 15 | it "should join two arrays together" do 16 | result = scope.function_union([["a","b","c"],["b","c","d"]]) 17 | result.should(eq(["a","b","c","d"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/defined_with_params_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should successfully notify' do 7 | pp = <<-EOS 8 | user { 'dan': 9 | ensure => present, 10 | } 11 | 12 | if defined_with_params(User[dan], {'ensure' => 'present' }) { 13 | notify { 'User defined with ensure=>present': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: User defined with ensure=>present/) 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/keys_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'keyss hashes' do 7 | pp = <<-EOS 8 | $a = {'aaa'=>'bbb','ccc'=>'ddd'} 9 | $o = keys($a) 10 | notice(inline_template('keys is <%= @o.sort.inspect %>')) 11 | EOS 12 | 13 | apply_manifest(pp, :catch_failures => true) do |r| 14 | expect(r.stdout).to match(/keys is \["aaa", "ccc"\]/) 15 | end 16 | end 17 | it 'handles non hashes' 18 | it 'handles empty hashes' 19 | end 20 | describe 'failure' do 21 | it 'handles improper argument counts' 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/deep_merge_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should deep merge two hashes' do 7 | pp = <<-EOS 8 | $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } 9 | $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } 10 | $merged_hash = deep_merge($hash1, $hash2) 11 | 12 | if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } { 13 | fail("Hash was incorrectly merged.") 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/lib/puppet_spec/pops.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | module PuppetSpec::Pops 3 | extend RSpec::Matchers::DSL 4 | 5 | # Checks if an Acceptor has a specific issue in its list of diagnostics 6 | matcher :have_issue do |expected| 7 | match do |actual| 8 | actual.diagnostics.index { |i| i.issue == expected } != nil 9 | end 10 | failure_message_for_should do |actual| 11 | "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to contain issue #{expected.issue_code}" 12 | end 13 | failure_message_for_should_not do |actual| 14 | "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to not contain issue #{expected.issue_code}" 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/join_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'joins arrays' do 7 | pp = <<-EOS 8 | $a = ['aaa','bbb','ccc'] 9 | $b = ':' 10 | $c = 'aaa:bbb:ccc' 11 | $o = join($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | it 'handles non arrays' 22 | end 23 | describe 'failure' do 24 | it 'handles improper argument counts' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'works with "y"' do 7 | pp = <<-EOS 8 | $o = str2saltedsha512('password') 9 | notice(inline_template('str2saltedsha512 is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/str2saltedsha512 is "[a-f0-9]{136}"/) 14 | end 15 | end 16 | end 17 | describe 'failure' do 18 | it 'handles no arguments' 19 | it 'handles more than one argument' 20 | it 'handles non strings' 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/functions/difference_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the difference function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("difference").should == "function_difference" 9 | end 10 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do 12 | lambda { scope.function_difference([]) }.should( raise_error(Puppet::ParseError) ) 13 | end 14 | 15 | it "should return the difference between two arrays" do 16 | result = scope.function_difference([["a","b","c"],["b","c","d"]]) 17 | result.should(eq(["a"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/delete_undef_values_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the array' do 7 | pp = <<-EOS 8 | $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) 9 | if $output == { a => 'A', b => '', d => false } { 10 | notify { 'output correct': } 11 | } 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/Notice: output correct/) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/functions/intersection_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the intersection function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("intersection").should == "function_intersection" 9 | end 10 | 11 | it "should raise a ParseError if there are fewer than 2 arguments" do 12 | lambda { scope.function_intersection([]) }.should( raise_error(Puppet::ParseError) ) 13 | end 14 | 15 | it "should return the intersection of two arrays" do 16 | result = scope.function_intersection([["a","b","c"],["b","c","d"]]) 17 | result.should(eq(["b","c"])) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/member_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'members arrays' do 7 | pp = <<-EOS 8 | $a = ['aaa','bbb','ccc'] 9 | $b = 'ccc' 10 | $c = true 11 | $o = member($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | it 'members arrays without members' 22 | end 23 | describe 'failure' do 24 | it 'handles improper argument counts' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/grep_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'greps arrays' do 7 | pp = <<-EOS 8 | $a = ['aaabbb','bbbccc','dddeee'] 9 | $b = 'bbb' 10 | $c = ['aaabbb','bbbccc'] 11 | $o = grep($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | end 22 | describe 'failure' do 23 | it 'handles improper argument counts' 24 | it 'handles non-arrays' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/reverse_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'reverses strings' do 7 | pp = <<-EOS 8 | $a = "the public art galleries" 9 | # Anagram: Large picture halls, I bet 10 | $o = reverse($a) 11 | notice(inline_template('reverse is <%= @o.inspect %>')) 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/) 16 | end 17 | end 18 | end 19 | describe 'failure' do 20 | it 'handles no arguments' 21 | it 'handles non strings or arrays' 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/swapcase_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'works with strings' do 7 | pp = <<-EOS 8 | $o = swapcase('aBcD') 9 | notice(inline_template('swapcase is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/swapcase is "AbCd"/) 14 | end 15 | end 16 | it 'works with arrays' 17 | end 18 | describe 'failure' do 19 | it 'handles no arguments' 20 | it 'handles non arrays or strings' 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/strftime_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'gives the Century' do 7 | pp = <<-EOS 8 | $o = strftime('%C') 9 | notice(inline_template('strftime is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/strftime is "20"/) 14 | end 15 | end 16 | it 'takes a timezone argument' 17 | end 18 | describe 'failure' do 19 | it 'handles no arguments' 20 | it 'handles invalid format strings' 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/getvar_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'getvars from classes' do 7 | pp = <<-EOS 8 | class a::data { $foo = 'aoeu' } 9 | include a::data 10 | $b = 'aoeu' 11 | $o = getvar("a::data::foo") 12 | if $o == $b { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | end 22 | describe 'failure' do 23 | it 'handles improper argument counts' 24 | it 'handles non-numbers' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/getparam_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'getparam a package' do 7 | pp = <<-EOS 8 | user { "rspec": 9 | ensure => present, 10 | managehome => true, 11 | } 12 | $o = getparam(User['rspec'], 'managehome') 13 | notice(inline_template('getparam is <%= @o.inspect %>')) 14 | EOS 15 | 16 | apply_manifest(pp, :catch_failures => true) do |r| 17 | expect(r.stdout).to match(/getparam is true/) 18 | end 19 | end 20 | end 21 | describe 'failure' do 22 | it 'handles no arguments' 23 | it 'handles non strings' 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/union_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'unions arrays' do 7 | pp = <<-EOS 8 | $a = ["the","public"] 9 | $b = ["art","galleries"] 10 | # Anagram: Large picture halls, I bet 11 | $o = union($a,$b) 12 | notice(inline_template('union is <%= @o.inspect %>')) 13 | EOS 14 | 15 | apply_manifest(pp, :catch_failures => true) do |r| 16 | expect(r.stdout).to match(/union is \["the", "public", "art", "galleries"\]/) 17 | end 18 | end 19 | end 20 | describe 'failure' do 21 | it 'handles no arguments' 22 | it 'handles non arrays' 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | # Only allow Numeric or String types 19 | return false unless value.is_a?(Numeric) or value.is_a?(String) 20 | 21 | if value != value.to_f.to_s and !value.is_a? Float then 22 | return false 23 | else 24 | return true 25 | end 26 | 27 | end 28 | end 29 | 30 | # vim: set ts=2 sw=2 et : 31 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/ensure_packages_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'ensure_packages function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'ensure_packages a package' do 7 | apply_manifest('package { "zsh": ensure => absent, }') 8 | pp = <<-EOS 9 | $a = "zsh" 10 | ensure_packages($a) 11 | EOS 12 | 13 | apply_manifest(pp, :expect_changes => true) do |r| 14 | expect(r.stdout).to match(/Package\[zsh\]\/ensure: created/) 15 | end 16 | end 17 | it 'ensures a package already declared' 18 | it 'takes defaults arguments' 19 | end 20 | describe 'failure' do 21 | it 'handles no arguments' 22 | it 'handles non strings' 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/defined_with_params_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should successfully notify' do 7 | pp = <<-EOS 8 | user { 'dan': 9 | ensure => present, 10 | } 11 | 12 | if defined_with_params(User[dan], {'ensure' => 'present' }) { 13 | notify { 'User defined with ensure=>present': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: User defined with ensure=>present/) 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/difference_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'returns non-duplicates in the first array' do 7 | pp = <<-EOS 8 | $a = ['a','b','c'] 9 | $b = ['b','c','d'] 10 | $c = ['a'] 11 | $o = difference($a, $b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | end 22 | describe 'failure' do 23 | it 'handles non-array arguments' 24 | it 'handles improper argument counts' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/uriescape_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'uriescape strings' do 7 | pp = <<-EOS 8 | $a = ":/?#[]@!$&'()*+,;= \\\"{}" 9 | $o = uriescape($a) 10 | notice(inline_template('uriescape is <%= @o.inspect %>')) 11 | EOS 12 | 13 | apply_manifest(pp, :catch_failures => true) do |r| 14 | expect(r.stdout).to match(/uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"/) 15 | end 16 | end 17 | it 'does nothing if a string is already safe' 18 | end 19 | describe 'failure' do 20 | it 'handles no arguments' 21 | it 'handles non strings or arrays' 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/keys_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'keyss hashes' do 7 | pp = <<-EOS 8 | $a = {'aaa'=>'bbb','ccc'=>'ddd'} 9 | $o = keys($a) 10 | notice(inline_template('keys is <%= @o.sort.inspect %>')) 11 | EOS 12 | 13 | apply_manifest(pp, :catch_failures => true) do |r| 14 | expect(r.stdout).to match(/keys is \["aaa", "ccc"\]/) 15 | end 16 | end 17 | it 'handles non hashes' 18 | it 'handles empty hashes' 19 | end 20 | describe 'failure' do 21 | it 'handles improper argument counts' 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/ensure_resource_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'ensure_resource function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'ensure_resource a package' do 7 | apply_manifest('package { "zsh": ensure => absent, }') 8 | pp = <<-EOS 9 | $a = "zsh" 10 | ensure_resource('package', $a) 11 | EOS 12 | 13 | apply_manifest(pp, :expect_changes => true) do |r| 14 | expect(r.stdout).to match(/Package\[zsh\]\/ensure: created/) 15 | end 16 | end 17 | it 'ensures a resource already declared' 18 | it 'takes defaults arguments' 19 | end 20 | describe 'failure' do 21 | it 'handles no arguments' 22 | it 'handles non strings' 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/deep_merge_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should deep merge two hashes' do 7 | pp = <<-EOS 8 | $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } 9 | $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } 10 | $merged_hash = deep_merge($hash1, $hash2) 11 | 12 | if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } { 13 | fail("Hash was incorrectly merged.") 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/lib/puppet_spec/pops.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | module PuppetSpec::Pops 3 | extend RSpec::Matchers::DSL 4 | 5 | # Checks if an Acceptor has a specific issue in its list of diagnostics 6 | matcher :have_issue do |expected| 7 | match do |actual| 8 | actual.diagnostics.index { |i| i.issue == expected } != nil 9 | end 10 | failure_message_for_should do |actual| 11 | "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to contain issue #{expected.issue_code}" 12 | end 13 | failure_message_for_should_not do |actual| 14 | "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to not contain issue #{expected.issue_code}" 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/hash_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'hashs arrays' do 7 | pp = <<-EOS 8 | $a = ['aaa','bbb','bbb','ccc','ddd','eee'] 9 | $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' } 10 | $o = hash($a) 11 | if $o == $b { 12 | notify { 'output correct': } 13 | } 14 | EOS 15 | 16 | apply_manifest(pp, :catch_failures => true) do |r| 17 | expect(r.stdout).to match(/Notice: output correct/) 18 | end 19 | end 20 | it 'handles odd-length arrays' 21 | end 22 | describe 'failure' do 23 | it 'handles improper argument counts' 24 | it 'handles non-arrays' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/join_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'joins arrays' do 7 | pp = <<-EOS 8 | $a = ['aaa','bbb','ccc'] 9 | $b = ':' 10 | $c = 'aaa:bbb:ccc' 11 | $o = join($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | it 'handles non arrays' 22 | end 23 | describe 'failure' do 24 | it 'handles improper argument counts' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/str2saltedsha512_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'works with "y"' do 7 | pp = <<-EOS 8 | $o = str2saltedsha512('password') 9 | notice(inline_template('str2saltedsha512 is <%= @o.inspect %>')) 10 | EOS 11 | 12 | apply_manifest(pp, :catch_failures => true) do |r| 13 | expect(r.stdout).to match(/str2saltedsha512 is "[a-f0-9]{136}"/) 14 | end 15 | end 16 | end 17 | describe 'failure' do 18 | it 'handles no arguments' 19 | it 'handles more than one argument' 20 | it 'handles non strings' 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/functions/dirname_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper' 3 | 4 | describe "the dirname function" do 5 | let(:scope) { PuppetlabsSpec::PuppetInternals.scope } 6 | 7 | it "should exist" do 8 | Puppet::Parser::Functions.function("dirname").should == "function_dirname" 9 | end 10 | 11 | it "should raise a ParseError if there is less than 1 arguments" do 12 | lambda { scope.function_dirname([]) }.should( raise_error(Puppet::ParseError)) 13 | end 14 | 15 | it "should return dirname for an absolute path" do 16 | result = scope.function_dirname(['/path/to/a/file.ext']) 17 | result.should(eq('/path/to/a')) 18 | end 19 | 20 | it "should return dirname for a relative path" do 21 | result = scope.function_dirname(['path/to/a/file.ext']) 22 | result.should(eq('path/to/a')) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/delete_values_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should delete elements of the hash' do 7 | pp = <<-EOS 8 | $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' } 9 | $b = { 'a' => 'A', 'B' => 'C' } 10 | $o = delete_values($a, 'B') 11 | if $o == $b { 12 | notify { 'output correct': } 13 | } 14 | EOS 15 | 16 | apply_manifest(pp, :catch_failures => true) do |r| 17 | expect(r.stdout).to match(/Notice: output correct/) 18 | end 19 | end 20 | end 21 | describe 'failure' do 22 | it 'handles non-hash arguments' 23 | it 'handles improper argument counts' 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/member_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'members arrays' do 7 | pp = <<-EOS 8 | $a = ['aaa','bbb','ccc'] 9 | $b = 'ccc' 10 | $c = true 11 | $o = member($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | it 'members arrays without members' 22 | end 23 | describe 'failure' do 24 | it 'handles improper argument counts' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D')) 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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/grep_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'greps arrays' do 7 | pp = <<-EOS 8 | $a = ['aaabbb','bbbccc','dddeee'] 9 | $b = 'bbb' 10 | $c = ['aaabbb','bbbccc'] 11 | $o = grep($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | end 22 | describe 'failure' do 23 | it 'handles improper argument counts' 24 | it 'handles non-arrays' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/reverse_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'reverses strings' do 7 | pp = <<-EOS 8 | $a = "the public art galleries" 9 | # Anagram: Large picture halls, I bet 10 | $o = reverse($a) 11 | notice(inline_template('reverse is <%= @o.inspect %>')) 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/) 16 | end 17 | end 18 | end 19 | describe 'failure' do 20 | it 'handles no arguments' 21 | it 'handles non strings or arrays' 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/intersection_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'intersections arrays' do 7 | pp = <<-EOS 8 | $a = ['aaa','bbb','ccc'] 9 | $b = ['bbb','ccc','ddd','eee'] 10 | $c = ['bbb','ccc'] 11 | $o = intersection($a,$b) 12 | if $o == $c { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | it 'intersections empty arrays' 22 | end 23 | describe 'failure' do 24 | it 'handles improper argument counts' 25 | it 'handles non-arrays' 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/lib/puppet/parser/functions/delete_values.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS 3 | Deletes all instances of a given value from a hash. 4 | 5 | *Examples:* 6 | 7 | delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B') 8 | 9 | Would return: {'a'=>'A','c'=>'C','B'=>'D'} 10 | 11 | EOS 12 | ) do |arguments| 13 | 14 | raise(Puppet::ParseError, 15 | "delete_values(): Wrong number of arguments given " + 16 | "(#{arguments.size} of 2)") if arguments.size != 2 17 | 18 | hash, item = arguments 19 | 20 | if not hash.is_a?(Hash) 21 | raise(TypeError, "delete_values(): First argument must be a Hash. " + \ 22 | "Given an argument of class #{hash.class}.") 23 | end 24 | hash.dup.delete_if { |key, val| item == val } 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/lib/puppet/parser/functions/union.rb: -------------------------------------------------------------------------------- 1 | # 2 | # union.rb 3 | # 4 | 5 | module Puppet::Parser::Functions 6 | newfunction(:union, :type => :rvalue, :doc => <<-EOS 7 | This function returns a union of two arrays. 8 | 9 | *Examples:* 10 | 11 | union(["a","b","c"],["b","c","d"]) 12 | 13 | Would return: ["a","b","c","d"] 14 | EOS 15 | ) do |arguments| 16 | 17 | # Two arguments are required 18 | raise(Puppet::ParseError, "union(): Wrong number of arguments " + 19 | "given (#{arguments.size} for 2)") if arguments.size != 2 20 | 21 | first = arguments[0] 22 | second = arguments[1] 23 | 24 | unless first.is_a?(Array) && second.is_a?(Array) 25 | raise(Puppet::ParseError, 'union(): Requires 2 arrays') 26 | end 27 | 28 | result = first | second 29 | 30 | return result 31 | end 32 | end 33 | 34 | # vim: set ts=2 sw=2 et : 35 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_aws_shell/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "awsbox" 3 | config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box" 4 | 5 | config.vm.provider :aws do |aws, override| 6 | aws.access_key_id = "YOUR AWS KEY ID" 7 | aws.secret_access_key = "YOUR AWS SECRET KEY" 8 | aws.keypair_name = "YOUR KEYPAIR NAME" 9 | aws.region = "YOUR AWS REGION" 10 | aws.ami = "ami-7747d01e" 11 | 12 | override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY" 13 | override.ssh.username = "ubuntu" 14 | end 15 | 16 | # define multiple VMs. 17 | config.vm.define :vm1 18 | config.vm.define :vm2 19 | #config.vm.define :vm3 20 | #config.vm.define :vm4 21 | 22 | config.vm.synced_folder "testplans", "/home/ubuntu/testplans" 23 | 24 | # provision with shell 25 | config.vm.provision "shell", path: "setup.sh" 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/abs_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'should accept a string' do 7 | pp = <<-EOS 8 | $input = '-34.56' 9 | $output = abs($input) 10 | notify { $output: } 11 | EOS 12 | 13 | apply_manifest(pp, :catch_failures => true) do |r| 14 | expect(r.stdout).to match(/Notice: 34.56/) 15 | end 16 | end 17 | 18 | it 'should accept a float' do 19 | pp = <<-EOS 20 | $input = -34.56 21 | $output = abs($input) 22 | notify { $output: } 23 | EOS 24 | 25 | apply_manifest(pp, :catch_failures => true) do |r| 26 | expect(r.stdout).to match(/Notice: 34.56/) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'join_keys_to_valuess hashes' do 7 | pp = <<-EOS 8 | $a = {'aaa'=>'bbb','ccc'=>'ddd'} 9 | $b = ':' 10 | $o = join_keys_to_values($a,$b) 11 | notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>')) 12 | EOS 13 | 14 | apply_manifest(pp, :catch_failures => true) do |r| 15 | expect(r.stdout).to match(/join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]/) 16 | end 17 | end 18 | it 'handles non hashes' 19 | it 'handles empty hashes' 20 | end 21 | describe 'failure' do 22 | it 'handles improper argument counts' 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/lib/puppet_spec/modules.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | module PuppetSpec::Modules 3 | class << self 4 | def create(name, dir, options = {}) 5 | module_dir = File.join(dir, name) 6 | FileUtils.mkdir_p(module_dir) 7 | 8 | environment = options[:environment] 9 | 10 | if metadata = options[:metadata] 11 | metadata[:source] ||= 'github' 12 | metadata[:author] ||= 'puppetlabs' 13 | metadata[:version] ||= '9.9.9' 14 | metadata[:license] ||= 'to kill' 15 | metadata[:dependencies] ||= [] 16 | 17 | metadata[:name] = "#{metadata[:author]}/#{name}" 18 | 19 | File.open(File.join(module_dir, 'metadata.json'), 'w') do |f| 20 | f.write(metadata.to_pson) 21 | end 22 | end 23 | 24 | Puppet::Module.new(name, module_dir, environment) 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/stdlib/spec/acceptance/getvar_spec.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby -S rspec 2 | require 'spec_helper_acceptance' 3 | 4 | describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do 5 | describe 'success' do 6 | it 'getvars from classes' do 7 | pp = <<-EOS 8 | class a::data { $foo = 'aoeu' } 9 | include a::data 10 | $b = 'aoeu' 11 | $o = getvar("a::data::foo") 12 | if $o == $b { 13 | notify { 'output correct': } 14 | } 15 | EOS 16 | 17 | apply_manifest(pp, :catch_failures => true) do |r| 18 | expect(r.stdout).to match(/Notice: output correct/) 19 | end 20 | end 21 | end 22 | describe 'failure' do 23 | it 'handles improper argument counts' 24 | it 'handles non-numbers' 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/modules/stdlib/spec/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 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | # Only allow Numeric or String types 19 | return false unless value.is_a?(Numeric) or value.is_a?(String) 20 | 21 | if value != value.to_f.to_s and !value.is_a? Float then 22 | return false 23 | else 24 | return true 25 | end 26 | 27 | end 28 | end 29 | 30 | # vim: set ts=2 sw=2 et : 31 | -------------------------------------------------------------------------------- /scripts/ch5/recipe_vagrant_internal/.tmp/librarian/cache/source/puppet/forge/forge_puppetlabs_com/puppetlabs/stdlib/4.2.1/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 | --------------------------------------------------------------------------------