From 30caaa85aed7015ca0d77216bff175eebd917eb7 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 8 Oct 2019 08:11:14 +0200 Subject: [PATCH] Update stdlib and concat to 6.1.0 both --- 3rdparty/Puppetfile | 5 +- 3rdparty/modules/concat/CHANGELOG.md | 134 + 3rdparty/modules/concat/CONTRIBUTING.md | 222 +- 3rdparty/modules/concat/Gemfile | 187 +- 3rdparty/modules/concat/HISTORY.md | 405 + 3rdparty/modules/concat/NOTICE | 2 +- 3rdparty/modules/concat/README.md | 357 +- 3rdparty/modules/concat/REFERENCE.md | 443 ++ 3rdparty/modules/concat/Rakefile | 97 +- 3rdparty/modules/concat/appveyor.yml | 91 +- 3rdparty/modules/concat/checksums.json | 83 +- 3rdparty/modules/concat/distelli-manifest.yml | 25 + 3rdparty/modules/concat/examples/format.pp | 13 + .../concat/lib/puppet/type/concat_file.rb | 269 +- .../concat/lib/puppet/type/concat_fragment.rb | 93 +- 3rdparty/modules/concat/locales/config.yaml | 1 + .../concat/locales/ja/puppetlabs-concat.po | 110 + .../concat/locales/puppetlabs-concat.pot | 127 + 3rdparty/modules/concat/manifests/fragment.pp | 28 +- 3rdparty/modules/concat/manifests/init.pp | 105 +- 3rdparty/modules/concat/metadata.json | 56 +- 3rdparty/modules/concat/provision.yaml | 19 + .../modules/concat/readmes/README_ja_JP.md | 160 + .../concat/spec/acceptance/backup_spec.rb | 124 +- .../concat/spec/acceptance/concat_spec.rb | 255 +- .../spec/acceptance/concurrency_spec.rb | 52 +- .../concat/spec/acceptance/force_spec.rb | 147 + .../concat/spec/acceptance/format_spec.rb | 214 + .../spec/acceptance/fragment_order_spec.rb | 98 + .../spec/acceptance/fragment_replace_spec.rb | 182 + .../spec/acceptance/fragment_source_spec.rb | 255 +- .../fragments_are_always_replaced_spec.rb | 166 +- .../concat/spec/acceptance/newline_spec.rb | 63 +- .../spec/acceptance/nodesets/debian-9-x64.yml | 20 + .../concat/spec/acceptance/noop_spec.rb | 26 + .../concat/spec/acceptance/order_spec.rb | 123 +- .../concat/spec/acceptance/pup-1963_spec.rb | 69 - .../concat/spec/acceptance/pup_1963_spec.rb | 70 + .../spec/acceptance/quoted_paths_spec.rb | 53 +- .../concat/spec/acceptance/replace_spec.rb | 261 - .../concat/spec/acceptance/specinfra_stubs.rb | 4 +- .../spec/acceptance/symbolic_name_spec.rb | 49 +- .../concat/spec/acceptance/validation_spec.rb | 36 +- .../spec/acceptance/warn_header_spec.rb | 104 +- .../concat/spec/acceptance/warnings_spec.rb | 27 +- .../modules/concat/spec/default_facts.yml | 7 + .../spec/defines/concat_fragment_spec.rb | 156 + .../concat/spec/defines/concat_spec.rb | 402 + 3rdparty/modules/concat/spec/spec_helper.rb | 61 +- .../concat/spec/spec_helper_acceptance.rb | 74 +- .../spec/spec_helper_acceptance_local.rb | 24 + .../modules/concat/spec/spec_helper_local.rb | 75 + .../spec/unit/defines/concat_fragment_spec.rb | 157 - .../concat/spec/unit/defines/concat_spec.rb | 355 - .../concat/spec/unit/type/concat_file_spec.rb | 127 +- .../spec/unit/type/concat_fragment_spec.rb | 111 + 3rdparty/modules/stdlib/CHANGELOG.md | 98 +- 3rdparty/modules/stdlib/Gemfile | 27 +- 3rdparty/modules/stdlib/README.md | 2700 +------ 3rdparty/modules/stdlib/REFERENCE.md | 7057 +++++++++++++++++ 3rdparty/modules/stdlib/Rakefile | 5 +- 3rdparty/modules/stdlib/appveyor.yml | 22 + 3rdparty/modules/stdlib/checksums.json | 610 +- 3rdparty/modules/stdlib/distelli-manifest.yml | 25 + .../modules/stdlib/lib/facter/facter_dot_d.rb | 27 +- .../stdlib/lib/facter/package_provider.rb | 2 + .../modules/stdlib/lib/facter/pe_version.rb | 5 + .../stdlib/lib/facter/puppet_settings.rb | 4 +- .../modules/stdlib/lib/facter/root_home.rb | 9 +- .../lib/puppet/functions/deprecation.rb | 16 +- .../stdlib/lib/puppet/functions/fact.rb | 18 +- .../stdlib/lib/puppet/functions/is_a.rb | 38 +- .../lib/puppet/functions/is_absolute_path.rb | 10 + .../stdlib/lib/puppet/functions/is_array.rb | 10 + .../stdlib/lib/puppet/functions/is_bool.rb | 10 + .../stdlib/lib/puppet/functions/is_float.rb | 10 + .../lib/puppet/functions/is_ip_address.rb | 10 + .../lib/puppet/functions/is_ipv4_address.rb | 10 + .../lib/puppet/functions/is_ipv6_address.rb | 10 + .../stdlib/lib/puppet/functions/is_numeric.rb | 10 + .../stdlib/lib/puppet/functions/is_string.rb | 10 + .../stdlib/lib/puppet/functions/length.rb | 16 +- .../stdlib/lib/puppet/functions/merge.rb | 110 + .../lib/puppet/functions/os_version_gte.rb | 13 +- .../puppet/functions/seeded_rand_string.rb | 3 +- .../lib/puppet/functions/sprintf_hash.rb | 3 +- .../lib/puppet/functions/stdlib/extname.rb | 6 +- .../puppet/functions/stdlib/ip_in_range.rb | 30 + .../stdlib/lib/puppet/functions/to_json.rb | 10 +- .../lib/puppet/functions/to_json_pretty.rb | 20 +- .../stdlib/lib/puppet/functions/to_yaml.rb | 11 +- .../stdlib/lib/puppet/functions/type_of.rb | 7 +- .../functions/validate_absolute_path.rb | 10 + .../lib/puppet/functions/validate_array.rb | 10 + .../lib/puppet/functions/validate_bool.rb | 10 + .../lib/puppet/functions/validate_hash.rb | 10 + .../lib/puppet/functions/validate_integer.rb | 10 + .../puppet/functions/validate_ip_address.rb | 10 + .../puppet/functions/validate_ipv4_address.rb | 10 + .../puppet/functions/validate_ipv6_address.rb | 10 + .../lib/puppet/functions/validate_legacy.rb | 20 +- .../lib/puppet/functions/validate_numeric.rb | 10 + .../lib/puppet/functions/validate_re.rb | 15 + .../lib/puppet/functions/validate_slength.rb | 9 + .../lib/puppet/functions/validate_string.rb | 10 + .../stdlib/lib/puppet/parser/functions/abs.rb | 15 +- .../lib/puppet/parser/functions/any2array.rb | 29 +- .../lib/puppet/parser/functions/any2bool.rb | 6 +- .../puppet/parser/functions/assert_private.rb | 7 +- .../lib/puppet/parser/functions/base64.rb | 37 +- .../lib/puppet/parser/functions/basename.rb | 5 +- .../lib/puppet/parser/functions/bool2num.rb | 27 +- .../lib/puppet/parser/functions/bool2str.rb | 31 +- .../lib/puppet/parser/functions/camelcase.rb | 12 +- .../lib/puppet/parser/functions/capitalize.rb | 13 +- .../lib/puppet/parser/functions/ceiling.rb | 10 +- .../lib/puppet/parser/functions/chomp.rb | 14 +- .../lib/puppet/parser/functions/chop.rb | 16 +- .../lib/puppet/parser/functions/clamp.rb | 20 +- .../lib/puppet/parser/functions/concat.rb | 20 +- .../puppet/parser/functions/convert_base.rb | 26 +- .../lib/puppet/parser/functions/count.rb | 15 +- .../lib/puppet/parser/functions/deep_merge.rb | 22 +- .../parser/functions/defined_with_params.rb | 26 +- .../lib/puppet/parser/functions/delete.rb | 51 +- .../lib/puppet/parser/functions/delete_at.rb | 31 +- .../puppet/parser/functions/delete_regex.rb | 35 +- .../parser/functions/delete_undef_values.rb | 28 +- .../puppet/parser/functions/delete_values.rb | 22 +- .../puppet/parser/functions/deprecation.rb | 9 +- .../lib/puppet/parser/functions/difference.rb | 20 +- .../stdlib/lib/puppet/parser/functions/dig.rb | 44 +- .../lib/puppet/parser/functions/dig44.rb | 33 +- .../lib/puppet/parser/functions/dirname.rb | 5 +- .../lib/puppet/parser/functions/dos2unix.rb | 6 +- .../lib/puppet/parser/functions/downcase.rb | 13 +- .../lib/puppet/parser/functions/empty.rb | 11 +- .../puppet/parser/functions/enclose_ipv6.rb | 7 +- .../parser/functions/ensure_packages.rb | 7 +- .../parser/functions/ensure_resource.rb | 20 +- .../parser/functions/ensure_resources.rb | 10 +- .../lib/puppet/parser/functions/flatten.rb | 16 +- .../lib/puppet/parser/functions/floor.rb | 10 +- .../parser/functions/fqdn_rand_string.rb | 30 +- .../puppet/parser/functions/fqdn_rotate.rb | 22 +- .../lib/puppet/parser/functions/fqdn_uuid.rb | 34 +- .../parser/functions/get_module_path.rb | 18 +- .../lib/puppet/parser/functions/getparam.rb | 45 +- .../lib/puppet/parser/functions/getvar.rb | 21 +- .../lib/puppet/parser/functions/glob.rb | 12 +- .../lib/puppet/parser/functions/grep.rb | 27 +- .../parser/functions/has_interface_with.rb | 22 +- .../puppet/parser/functions/has_ip_address.rb | 6 +- .../puppet/parser/functions/has_ip_network.rb | 6 +- .../lib/puppet/parser/functions/has_key.rb | 33 +- .../lib/puppet/parser/functions/hash.rb | 24 +- .../puppet/parser/functions/intersection.rb | 11 +- .../parser/functions/is_absolute_path.rb | 39 +- .../lib/puppet/parser/functions/is_array.rb | 9 +- .../lib/puppet/parser/functions/is_bool.rb | 9 +- .../puppet/parser/functions/is_domain_name.rb | 10 +- .../parser/functions/is_email_address.rb | 9 +- .../lib/puppet/parser/functions/is_float.rb | 9 +- .../parser/functions/is_function_available.rb | 13 +- .../lib/puppet/parser/functions/is_hash.rb | 9 +- .../lib/puppet/parser/functions/is_integer.rb | 16 +- .../puppet/parser/functions/is_ip_address.rb | 9 +- .../parser/functions/is_ipv4_address.rb | 9 +- .../parser/functions/is_ipv6_address.rb | 9 +- .../puppet/parser/functions/is_mac_address.rb | 9 +- .../lib/puppet/parser/functions/is_numeric.rb | 13 +- .../lib/puppet/parser/functions/is_string.rb | 9 +- .../lib/puppet/parser/functions/join.rb | 15 +- .../parser/functions/join_keys_to_values.rb | 22 +- .../lib/puppet/parser/functions/keys.rb | 10 +- .../parser/functions/load_module_metadata.rb | 10 +- .../lib/puppet/parser/functions/loadjson.rb | 18 +- .../lib/puppet/parser/functions/loadyaml.rb | 10 +- .../lib/puppet/parser/functions/lstrip.rb | 10 +- .../stdlib/lib/puppet/parser/functions/max.rb | 11 +- .../lib/puppet/parser/functions/member.rb | 57 +- .../lib/puppet/parser/functions/merge.rb | 20 +- .../stdlib/lib/puppet/parser/functions/min.rb | 11 +- .../lib/puppet/parser/functions/num2bool.rb | 13 +- .../lib/puppet/parser/functions/parsejson.rb | 13 +- .../lib/puppet/parser/functions/parseyaml.rb | 13 +- .../lib/puppet/parser/functions/pick.rb | 24 +- .../puppet/parser/functions/pick_default.rb | 27 +- .../lib/puppet/parser/functions/prefix.rb | 15 +- .../lib/puppet/parser/functions/private.rb | 6 +- .../stdlib/lib/puppet/parser/functions/pry.rb | 12 +- .../lib/puppet/parser/functions/pw_hash.rb | 20 +- .../lib/puppet/parser/functions/range.rb | 48 +- .../puppet/parser/functions/regexpescape.rb | 7 +- .../lib/puppet/parser/functions/reject.rb | 21 +- .../lib/puppet/parser/functions/reverse.rb | 8 +- .../lib/puppet/parser/functions/round.rb | 18 +- .../lib/puppet/parser/functions/rstrip.rb | 8 +- .../puppet/parser/functions/seeded_rand.rb | 10 +- .../puppet/parser/functions/shell_escape.rb | 8 +- .../lib/puppet/parser/functions/shell_join.rb | 9 +- .../puppet/parser/functions/shell_split.rb | 6 +- .../lib/puppet/parser/functions/shuffle.rb | 4 + .../lib/puppet/parser/functions/size.rb | 8 +- .../lib/puppet/parser/functions/sort.rb | 6 +- .../lib/puppet/parser/functions/squeeze.rb | 6 +- .../lib/puppet/parser/functions/str2bool.rb | 11 +- .../parser/functions/str2saltedsha512.rb | 10 +- .../lib/puppet/parser/functions/strftime.rb | 21 +- .../lib/puppet/parser/functions/strip.rb | 15 +- .../lib/puppet/parser/functions/suffix.rb | 17 +- .../lib/puppet/parser/functions/swapcase.rb | 11 +- .../lib/puppet/parser/functions/time.rb | 15 +- .../lib/puppet/parser/functions/to_bytes.rb | 7 +- .../puppet/parser/functions/try_get_value.rb | 14 +- .../lib/puppet/parser/functions/type.rb | 13 +- .../lib/puppet/parser/functions/type3x.rb | 5 +- .../lib/puppet/parser/functions/union.rb | 12 +- .../lib/puppet/parser/functions/unique.rb | 21 +- .../lib/puppet/parser/functions/unix2dos.rb | 7 +- .../lib/puppet/parser/functions/upcase.rb | 15 +- .../lib/puppet/parser/functions/uriescape.rb | 9 +- .../functions/validate_absolute_path.rb | 55 +- .../puppet/parser/functions/validate_array.rb | 28 +- .../parser/functions/validate_augeas.rb | 26 +- .../puppet/parser/functions/validate_bool.rb | 31 +- .../puppet/parser/functions/validate_cmd.rb | 17 +- .../parser/functions/validate_domain_name.rb | 29 +- .../functions/validate_email_address.rb | 29 +- .../puppet/parser/functions/validate_hash.rb | 28 +- .../parser/functions/validate_integer.rb | 92 +- .../parser/functions/validate_ip_address.rb | 40 +- .../parser/functions/validate_ipv4_address.rb | 22 +- .../parser/functions/validate_ipv6_address.rb | 25 +- .../parser/functions/validate_numeric.rb | 12 +- .../puppet/parser/functions/validate_re.rb | 35 +- .../parser/functions/validate_slength.rb | 32 +- .../parser/functions/validate_string.rb | 35 +- .../functions/validate_x509_rsa_key_pair.rb | 12 +- .../lib/puppet/parser/functions/values.rb | 29 +- .../lib/puppet/parser/functions/values_at.rb | 31 +- .../stdlib/lib/puppet/parser/functions/zip.rb | 14 +- .../lib/puppet/provider/file_line/ruby.rb | 9 + .../modules/stdlib/lib/puppet/type/anchor.rb | 42 +- .../stdlib/lib/puppet/type/file_line.rb | 129 +- 3rdparty/modules/stdlib/manifests/init.pp | 22 +- 3rdparty/modules/stdlib/manifests/stages.pp | 31 +- 3rdparty/modules/stdlib/metadata.json | 17 +- 3rdparty/modules/stdlib/provision.yaml | 16 + .../modules/stdlib/readmes/README_ja_JP.md | 2 +- .../stdlib/spec/acceptance/abs_spec.rb | 27 - .../stdlib/spec/acceptance/anchor_spec.rb | 15 +- .../stdlib/spec/acceptance/any2array_spec.rb | 45 - .../stdlib/spec/acceptance/base64_spec.rb | 16 - .../stdlib/spec/acceptance/bool2num_spec.rb | 31 - .../stdlib/spec/acceptance/build_csv.rb | 89 - .../stdlib/spec/acceptance/capitalize_spec.rb | 30 - .../stdlib/spec/acceptance/ceiling_spec.rb | 37 - .../stdlib/spec/acceptance/chomp_spec.rb | 19 - .../stdlib/spec/acceptance/chop_spec.rb | 41 - .../stdlib/spec/acceptance/clamp_spec.rb | 38 - .../stdlib/spec/acceptance/concat_spec.rb | 52 - .../stdlib/spec/acceptance/count_spec.rb | 27 - .../stdlib/spec/acceptance/deep_merge_spec.rb | 18 - .../acceptance/defined_with_params_spec.rb | 39 - .../stdlib/spec/acceptance/delete_at_spec.rb | 17 - .../stdlib/spec/acceptance/delete_spec.rb | 17 - .../acceptance/delete_undef_values_spec.rb | 17 - .../spec/acceptance/delete_values_spec.rb | 23 - .../spec/acceptance/deprecation_spec.rb | 92 - .../stdlib/spec/acceptance/difference_spec.rb | 24 - .../stdlib/spec/acceptance/dirname_spec.rb | 39 - .../stdlib/spec/acceptance/downcase_spec.rb | 37 - .../stdlib/spec/acceptance/empty_spec.rb | 51 - .../spec/acceptance/ensure_resource_spec.rb | 29 - .../stdlib/spec/acceptance/file_line_spec.rb | 89 + .../stdlib/spec/acceptance/flatten_spec.rb | 37 - .../stdlib/spec/acceptance/floor_spec.rb | 37 - .../spec/acceptance/fqdn_rand_string_spec.rb | 64 - .../spec/acceptance/fqdn_rotate_spec.rb | 62 - .../spec/acceptance/get_module_path_spec.rb | 25 - .../stdlib/spec/acceptance/getparam_spec.rb | 22 - .../stdlib/spec/acceptance/getvar_spec.rb | 24 - .../stdlib/spec/acceptance/grep_spec.rb | 24 - .../acceptance/has_interface_with_spec.rb | 52 - .../spec/acceptance/has_ip_address_spec.rb | 31 - .../spec/acceptance/has_ip_network_spec.rb | 31 - .../stdlib/spec/acceptance/has_key_spec.rb | 39 - .../stdlib/spec/acceptance/hash_spec.rb | 24 - .../spec/acceptance/intersection_spec.rb | 25 - .../stdlib/spec/acceptance/is_a_spec.rb | 27 - .../stdlib/spec/acceptance/is_array_spec.rb | 65 - .../stdlib/spec/acceptance/is_bool_spec.rb | 79 - .../spec/acceptance/is_domain_name_spec.rb | 81 - .../stdlib/spec/acceptance/is_float_spec.rb | 84 - .../acceptance/is_function_available_spec.rb | 56 - .../stdlib/spec/acceptance/is_hash_spec.rb | 61 - .../stdlib/spec/acceptance/is_integer_spec.rb | 93 - .../spec/acceptance/is_ip_address_spec.rb | 78 - .../spec/acceptance/is_ipv4_address_spec.rb | 50 - .../spec/acceptance/is_ipv6_address_spec.rb | 64 - .../spec/acceptance/is_mac_address_spec.rb | 50 - .../stdlib/spec/acceptance/is_numeric_spec.rb | 93 - .../stdlib/spec/acceptance/is_string_spec.rb | 111 - .../acceptance/join_keys_to_values_spec.rb | 22 - .../stdlib/spec/acceptance/join_spec.rb | 24 - .../stdlib/spec/acceptance/keys_spec.rb | 21 - .../stdlib/spec/acceptance/loadjson_spec.rb | 48 - .../stdlib/spec/acceptance/loadyaml_spec.rb | 52 - .../stdlib/spec/acceptance/lstrip_spec.rb | 32 - .../stdlib/spec/acceptance/max_spec.rb | 18 - .../stdlib/spec/acceptance/member_spec.rb | 57 - .../stdlib/spec/acceptance/merge_spec.rb | 22 - .../stdlib/spec/acceptance/min_spec.rb | 18 - .../stdlib/spec/acceptance/num2bool_spec.rb | 76 - .../stdlib/spec/acceptance/parsejson_spec.rb | 50 - .../stdlib/spec/acceptance/parseyaml_spec.rb | 52 - .../spec/acceptance/pick_default_spec.rb | 51 - .../stdlib/spec/acceptance/pick_spec.rb | 42 - .../stdlib/spec/acceptance/prefix_spec.rb | 40 - .../stdlib/spec/acceptance/pw_hash_spec.rb | 31 - .../stdlib/spec/acceptance/range_spec.rb | 34 - .../stdlib/spec/acceptance/reject_spec.rb | 40 - .../stdlib/spec/acceptance/reverse_spec.rb | 21 - .../stdlib/spec/acceptance/rstrip_spec.rb | 32 - .../stdlib/spec/acceptance/shuffle_spec.rb | 32 - .../stdlib/spec/acceptance/size_spec.rb | 53 - .../stdlib/spec/acceptance/sort_spec.rb | 32 - .../stdlib/spec/acceptance/squeeze_spec.rb | 44 - .../stdlib/spec/acceptance/str2bool_spec.rb | 29 - .../spec/acceptance/str2saltedsha512_spec.rb | 20 - .../stdlib/spec/acceptance/strftime_spec.rb | 20 - .../stdlib/spec/acceptance/strip_spec.rb | 32 - .../stdlib/spec/acceptance/suffix_spec.rb | 40 - .../stdlib/spec/acceptance/swapcase_spec.rb | 20 - .../stdlib/spec/acceptance/time_spec.rb | 32 - .../stdlib/spec/acceptance/to_bytes_spec.rb | 25 - .../spec/acceptance/try_get_value_spec.rb | 44 - .../stdlib/spec/acceptance/type3x_spec.rb | 27 - .../stdlib/spec/acceptance/type_spec.rb | 35 - .../stdlib/spec/acceptance/union_spec.rb | 23 - .../stdlib/spec/acceptance/unique_spec.rb | 31 - .../stdlib/spec/acceptance/upcase_spec.rb | 31 - .../stdlib/spec/acceptance/uriescape_spec.rb | 21 - .../acceptance/validate_absolute_path_spec.rb | 19 - .../spec/acceptance/validate_array_spec.rb | 35 - .../spec/acceptance/validate_augeas_spec.rb | 61 - .../spec/acceptance/validate_bool_spec.rb | 35 - .../spec/acceptance/validate_cmd_spec.rb | 50 - .../spec/acceptance/validate_hash_spec.rb | 36 - .../acceptance/validate_ipv4_address_spec.rb | 29 - .../acceptance/validate_ipv6_address_spec.rb | 29 - .../spec/acceptance/validate_re_spec.rb | 46 - .../spec/acceptance/validate_slength_spec.rb | 70 - .../spec/acceptance/validate_string_spec.rb | 42 - .../stdlib/spec/acceptance/values_at_spec.rb | 71 - .../stdlib/spec/acceptance/values_spec.rb | 29 - .../stdlib/spec/acceptance/zip_spec.rb | 71 - .../modules/stdlib/spec/functions/abs_spec.rb | 32 - .../stdlib/spec/functions/basename_spec.rb | 8 +- .../stdlib/spec/functions/bool2num_spec.rb | 8 +- .../stdlib/spec/functions/ceiling_spec.rb | 7 +- .../stdlib/spec/functions/chomp_spec.rb | 6 +- .../stdlib/spec/functions/chop_spec.rb | 6 +- .../stdlib/spec/functions/clamp_spec.rb | 5 +- .../stdlib/spec/functions/concat_spec.rb | 6 +- .../stdlib/spec/functions/delete_at_spec.rb | 10 +- .../spec/functions/delete_regex_spec.rb | 9 +- .../stdlib/spec/functions/delete_spec.rb | 8 +- .../functions/delete_undef_values_spec.rb | 8 +- .../spec/functions/delete_values_spec.rb | 14 +- .../stdlib/spec/functions/difference_spec.rb | 13 +- .../stdlib/spec/functions/dig44_spec.rb | 6 +- .../stdlib/spec/functions/dirname_spec.rb | 17 +- .../stdlib/spec/functions/dos2unix_spec.rb | 6 +- .../stdlib/spec/functions/downcase_spec.rb | 4 +- .../stdlib/spec/functions/empty_spec.rb | 3 +- .../stdlib/spec/functions/flatten_spec.rb | 9 +- .../stdlib/spec/functions/floor_spec.rb | 7 +- .../stdlib/spec/functions/fqdn_uuid_spec.rb | 6 +- .../spec/functions/has_ip_address_spec.rb | 1 + .../spec/functions/has_ip_network_spec.rb | 1 + .../stdlib/spec/functions/ip_in_range_spec.rb | 17 + .../spec/functions/is_domain_name_spec.rb | 6 + .../stdlib/spec/functions/is_float_spec.rb | 26 +- .../functions/is_function_available_spec.rb | 3 + .../stdlib/spec/functions/is_hash_spec.rb | 1 + .../spec/functions/is_ip_address_spec.rb | 18 +- .../spec/functions/is_ipv6_address_spec.rb | 1 + .../stdlib/spec/functions/is_numeric_spec.rb | 1 + .../stdlib/spec/functions/is_string_spec.rb | 1 + .../functions/load_module_metadata_spec.rb | 2 + .../stdlib/spec/functions/loadjson_spec.rb | 2 + .../stdlib/spec/functions/member_spec.rb | 2 + .../stdlib/spec/functions/merge_spec.rb | 65 +- .../modules/stdlib/spec/functions/min_spec.rb | 1 + .../stdlib/spec/functions/num2bool_spec.rb | 1 + .../spec/functions/os_version_gte_spec.rb | 12 + .../stdlib/spec/functions/parseyaml_spec.rb | 17 +- .../stdlib/spec/functions/sort_spec.rb | 4 + .../stdlib/spec/functions/strftime_spec.rb | 2 +- .../stdlib/spec/functions/suffix_spec.rb | 20 +- .../spec/functions/try_get_value_spec.rb | 4 + .../functions/validate_absolute_path_spec.rb | 2 +- .../spec/functions/validate_array_spec.rb | 1 + .../spec/functions/validate_bool_spec.rb | 2 + .../spec/functions/validate_hash_spec.rb | 1 + .../functions/validate_ipv4_address_spec.rb | 5 + .../stdlib/spec/functions/validate_re_spec.rb | 16 +- .../spec/functions/validate_string_spec.rb | 1 + .../modules/stdlib/spec/functions/zip_spec.rb | 3 + 3rdparty/modules/stdlib/spec/spec_helper.rb | 12 +- .../stdlib/spec/spec_helper_acceptance.rb | 125 +- .../type_aliases/objectstore_gsuri_spec.rb | 32 + .../type_aliases/objectstore_s3uri_spec.rb | 32 + .../spec/type_aliases/objectstore_spec.rb | 34 + .../stdlib/spec/type_aliases/yes_no_spec.rb | 44 + 3rdparty/modules/stdlib/types/objectstore.pp | 4 + .../modules/stdlib/types/objectstore/gsuri.pp | 2 + .../modules/stdlib/types/objectstore/s3uri.pp | 1 + .../modules/stdlib/types/syslogfacility.pp | 26 + 3rdparty/modules/stdlib/types/yes_no.pp | 1 + 422 files changed, 14886 insertions(+), 11232 deletions(-) create mode 100644 3rdparty/modules/concat/HISTORY.md create mode 100644 3rdparty/modules/concat/REFERENCE.md create mode 100644 3rdparty/modules/concat/distelli-manifest.yml create mode 100644 3rdparty/modules/concat/examples/format.pp create mode 100644 3rdparty/modules/concat/locales/ja/puppetlabs-concat.po create mode 100644 3rdparty/modules/concat/locales/puppetlabs-concat.pot create mode 100644 3rdparty/modules/concat/provision.yaml create mode 100644 3rdparty/modules/concat/readmes/README_ja_JP.md create mode 100644 3rdparty/modules/concat/spec/acceptance/force_spec.rb create mode 100644 3rdparty/modules/concat/spec/acceptance/format_spec.rb create mode 100644 3rdparty/modules/concat/spec/acceptance/fragment_order_spec.rb create mode 100644 3rdparty/modules/concat/spec/acceptance/fragment_replace_spec.rb create mode 100644 3rdparty/modules/concat/spec/acceptance/nodesets/debian-9-x64.yml create mode 100644 3rdparty/modules/concat/spec/acceptance/noop_spec.rb delete mode 100644 3rdparty/modules/concat/spec/acceptance/pup-1963_spec.rb create mode 100644 3rdparty/modules/concat/spec/acceptance/pup_1963_spec.rb delete mode 100644 3rdparty/modules/concat/spec/acceptance/replace_spec.rb create mode 100644 3rdparty/modules/concat/spec/default_facts.yml create mode 100644 3rdparty/modules/concat/spec/defines/concat_fragment_spec.rb create mode 100644 3rdparty/modules/concat/spec/defines/concat_spec.rb create mode 100644 3rdparty/modules/concat/spec/spec_helper_acceptance_local.rb create mode 100644 3rdparty/modules/concat/spec/spec_helper_local.rb delete mode 100644 3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb delete mode 100644 3rdparty/modules/concat/spec/unit/defines/concat_spec.rb create mode 100644 3rdparty/modules/concat/spec/unit/type/concat_fragment_spec.rb create mode 100644 3rdparty/modules/stdlib/REFERENCE.md create mode 100644 3rdparty/modules/stdlib/distelli-manifest.yml create mode 100644 3rdparty/modules/stdlib/lib/puppet/functions/merge.rb create mode 100644 3rdparty/modules/stdlib/lib/puppet/functions/stdlib/ip_in_range.rb create mode 100644 3rdparty/modules/stdlib/provision.yaml delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/abs_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/any2array_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/base64_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/build_csv.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/capitalize_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/ceiling_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/chomp_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/chop_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/concat_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/count_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/deep_merge_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/defined_with_params_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/delete_at_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/delete_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/delete_values_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/difference_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/dirname_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/downcase_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/empty_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/ensure_resource_spec.rb create mode 100644 3rdparty/modules/stdlib/spec/acceptance/file_line_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/flatten_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/floor_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/get_module_path_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/getparam_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/getvar_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/grep_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/has_interface_with_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/has_ip_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/has_ip_network_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/has_key_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/hash_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/intersection_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_array_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_bool_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_domain_name_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_float_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_function_available_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_hash_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_integer_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_ip_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_mac_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_numeric_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/is_string_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/join_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/keys_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/loadyaml_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/lstrip_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/max_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/member_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/merge_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/min_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/num2bool_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/parsejson_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/parseyaml_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/pick_default_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/pick_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/prefix_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/range_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/reject_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/reverse_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/rstrip_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/shuffle_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/size_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/sort_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/squeeze_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/str2bool_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/strftime_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/strip_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/suffix_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/swapcase_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/time_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/to_bytes_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/type3x_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/type_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/union_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/unique_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/upcase_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/uriescape_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_array_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_augeas_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_bool_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_cmd_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_hash_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_re_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_slength_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/validate_string_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/values_at_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/values_spec.rb delete mode 100644 3rdparty/modules/stdlib/spec/acceptance/zip_spec.rb create mode 100644 3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb create mode 100644 3rdparty/modules/stdlib/spec/type_aliases/objectstore_gsuri_spec.rb create mode 100644 3rdparty/modules/stdlib/spec/type_aliases/objectstore_s3uri_spec.rb create mode 100644 3rdparty/modules/stdlib/spec/type_aliases/objectstore_spec.rb create mode 100644 3rdparty/modules/stdlib/spec/type_aliases/yes_no_spec.rb create mode 100644 3rdparty/modules/stdlib/types/objectstore.pp create mode 100644 3rdparty/modules/stdlib/types/objectstore/gsuri.pp create mode 100644 3rdparty/modules/stdlib/types/objectstore/s3uri.pp create mode 100644 3rdparty/modules/stdlib/types/syslogfacility.pp create mode 100644 3rdparty/modules/stdlib/types/yes_no.pp diff --git a/3rdparty/Puppetfile b/3rdparty/Puppetfile index f23412643..e80b68972 100644 --- a/3rdparty/Puppetfile +++ b/3rdparty/Puppetfile @@ -1,7 +1,8 @@ forge "http://forge.puppetlabs.com" -mod 'puppetlabs/stdlib', '5.2.0' -mod 'puppetlabs/concat', '4.0.1' +mod 'puppetlabs/stdlib', '6.1.0' +mod 'puppetlabs/concat', '6.1.0' + mod 'puppetlabs-postgresql', '5.1.0' mod 'puppet/archive', '2.3.0' diff --git a/3rdparty/modules/concat/CHANGELOG.md b/3rdparty/modules/concat/CHANGELOG.md index 0b88ec782..24d18bba9 100644 --- a/3rdparty/modules/concat/CHANGELOG.md +++ b/3rdparty/modules/concat/CHANGELOG.md @@ -1,3 +1,134 @@ +# Change log + +All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). + +## [v6.1.0](https://github.com/puppetlabs/puppetlabs-concat/tree/v6.1.0) (2019-07-23) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/v6.0.0...v6.1.0) + +### Added + +- FM-8049 - add redhat8 support [\#584](https://github.com/puppetlabs/puppetlabs-concat/pull/584) ([lionce](https://github.com/lionce)) + +### Fixed + +- \(MODULES-9479\) Fix nested array merge behavior [\#593](https://github.com/puppetlabs/puppetlabs-concat/pull/593) ([seanmil](https://github.com/seanmil)) +- \(FM-8317\) Updated regex to allow for windows paths with \'s [\#591](https://github.com/puppetlabs/puppetlabs-concat/pull/591) ([pgrant87](https://github.com/pgrant87)) +- \(bugfix\) allow private keys in ssh testing [\#585](https://github.com/puppetlabs/puppetlabs-concat/pull/585) ([tphoney](https://github.com/tphoney)) + +## [v6.0.0](https://github.com/puppetlabs/puppetlabs-concat/tree/v6.0.0) (2019-05-21) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/5.3.0...v6.0.0) + +### Changed + +- pdksync - \(MODULES-8444\) - Raise lower Puppet bound [\#575](https://github.com/puppetlabs/puppetlabs-concat/pull/575) ([david22swan](https://github.com/david22swan)) + +### Added + +- \(FM-7606\) enable litmus for concat [\#577](https://github.com/puppetlabs/puppetlabs-concat/pull/577) ([tphoney](https://github.com/tphoney)) + +### Fixed + +- \(FM-8073\) litmus block support [\#580](https://github.com/puppetlabs/puppetlabs-concat/pull/580) ([tphoney](https://github.com/tphoney)) + +## [5.3.0](https://github.com/puppetlabs/puppetlabs-concat/tree/5.3.0) (2019-02-20) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/5.2.0...5.3.0) + +### Added + +- \(MODULES-8138\) - Addition of support for SLES 15 [\#545](https://github.com/puppetlabs/puppetlabs-concat/pull/545) ([david22swan](https://github.com/david22swan)) + +### Fixed + +- \(FM-7725\) - Remove OSX testing/support for concat [\#561](https://github.com/puppetlabs/puppetlabs-concat/pull/561) ([lionce](https://github.com/lionce)) +- pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#550](https://github.com/puppetlabs/puppetlabs-concat/pull/550) ([tphoney](https://github.com/tphoney)) + +## [5.2.0](https://github.com/puppetlabs/puppetlabs-concat/tree/5.2.0) (2018-12-10) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/5.1.0...5.2.0) + +### Added + +- \(FM-7339\) - Add i18n implementation [\#537](https://github.com/puppetlabs/puppetlabs-concat/pull/537) ([eimlav](https://github.com/eimlav)) +- \(FM-7341\) - Added REFERENCE.md and updated documentation [\#536](https://github.com/puppetlabs/puppetlabs-concat/pull/536) ([eimlav](https://github.com/eimlav)) +- \(MODULES-5124\) Add support for JSON arrays [\#519](https://github.com/puppetlabs/puppetlabs-concat/pull/519) ([johanfleury](https://github.com/johanfleury)) + +### Fixed + +- \(FM-7581\) - Fix CI failures for Windows 2016 and 10 Enterprise [\#540](https://github.com/puppetlabs/puppetlabs-concat/pull/540) ([eimlav](https://github.com/eimlav)) +- \(MODULES-8287\) - Fix fomat=\>'yaml' allowing only hashes [\#535](https://github.com/puppetlabs/puppetlabs-concat/pull/535) ([eimlav](https://github.com/eimlav)) +- \(FM-7513\) - Removing Windows 2016-core from our support matrix [\#534](https://github.com/puppetlabs/puppetlabs-concat/pull/534) ([pmcmaw](https://github.com/pmcmaw)) +- \(MODULES-8088\) - newline\_spec.rb test expectation update [\#531](https://github.com/puppetlabs/puppetlabs-concat/pull/531) ([lionce](https://github.com/lionce)) +- \(MODULES-7717\) ensure\_newline uses unix line ending on windows [\#517](https://github.com/puppetlabs/puppetlabs-concat/pull/517) ([tkishel](https://github.com/tkishel)) + +## [5.1.0](https://github.com/puppetlabs/puppetlabs-concat/tree/5.1.0) (2018-10-03) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/5.0.0...5.1.0) + +### Added + +- pdksync - \(FM-7392\) - Puppet 6 Testing Changes [\#525](https://github.com/puppetlabs/puppetlabs-concat/pull/525) ([pmcmaw](https://github.com/pmcmaw)) +- pdksync - \(MODULES-6805\) metadata.json shows support for puppet 6 [\#524](https://github.com/puppetlabs/puppetlabs-concat/pull/524) ([tphoney](https://github.com/tphoney)) +- pdksync - \(MODULES-7658\) use beaker4 in puppet-module-gems [\#518](https://github.com/puppetlabs/puppetlabs-concat/pull/518) ([tphoney](https://github.com/tphoney)) + +## [5.0.0](https://github.com/puppetlabs/puppetlabs-concat/tree/5.0.0) (2018-08-24) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/4.2.1...5.0.0) + +### Changed + +- \[FM-6954\] Removal of scientific linux 5 and debian 7 [\#508](https://github.com/puppetlabs/puppetlabs-concat/pull/508) ([david22swan](https://github.com/david22swan)) + +### Added + +- \(FM-7206\) Update concat to support Ubuntu 18.04 [\#510](https://github.com/puppetlabs/puppetlabs-concat/pull/510) ([david22swan](https://github.com/david22swan)) + +### Fixed + +- Handle concat\_file source when not an array [\#493](https://github.com/puppetlabs/puppetlabs-concat/pull/493) ([vicinus](https://github.com/vicinus)) + +## 4.2.1 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/4.2.0...4.2.1) + +### Fixed +- \(MODULES-6817\) noop =\> false for concat\_file [\#492](https://github.com/puppetlabs/puppetlabs-concat/pull/492) ([hunner](https://github.com/hunner)) + +## Supported Release 4.2.0 +### Summary +This release introduces the conversion of the module to use PDK 1.3.2, along with the addition of rubocop with associated fixes. + +#### Changed +- All changes in this release are for enabling rubocop, alongside the module then being converted over to the PDK. + + +## Supported Releases 4.1.1 +### Summary +This release is to update the formatting of the module, rubocop having been run for all ruby files and been set to run automatically on all future commits. + +#### Changed +- Rubocop has been implemented. +- SLES 10, Windows 2003 R2 and OSX 10.9 removed as supported. +- OSX 10.10 and 10.11 added as supported. + +## Supported Releases 4.1.0 +### Summary + +This release is a rollup of changes. The most notable change being the addition of the 'format' attribute which allows output in JSON and YAML formats, and the 'force' attribute which if true forces a merge of duplicate keys for these formats. + +#### Features +- Format and force attributes added. +- Deprecated is_string in favour of puppet language. +- End of Life Ubuntu releases removed as supported. +- Debian 9 added and Debian 6 removed as supported. + +#### Bugfixes +- (MODULES-4359) Fix native types so they can be used directly. +- Update to tests to handle errors containing quote marks. +- Update to tests to follow rspec-puppet pattern. + ## Supported Releases 4.0.1 ### Summary @@ -363,3 +494,6 @@ defining resource defaults. - 2012/08/30 - More Puppet Lint cleanup - 2012/09/04 - RELEASE 0.2.0 - 2012/12/12 - Added (file) $replace parameter to concat + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/3rdparty/modules/concat/CONTRIBUTING.md b/3rdparty/modules/concat/CONTRIBUTING.md index 990edba7e..1a9fb3a5c 100644 --- a/3rdparty/modules/concat/CONTRIBUTING.md +++ b/3rdparty/modules/concat/CONTRIBUTING.md @@ -1,63 +1,75 @@ -Checklist (and a short version for the impatient) -================================================= +# Contributing to Puppet modules - * Commits: +So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing +that very thing while setting expectations around code quality as well as a few tips for making the +process as easy as possible. - - Make commits of logical units. +### Table of Contents - - Check for unnecessary whitespace with "git diff --check" before - committing. +1. [Getting Started](#getting-started) +1. [Commit Checklist](#commit-checklist) +1. [Submission](#submission) +1. [More about commits](#more-about-commits) +1. [Testing](#testing) + - [Running Tests](#running-tests) + - [Writing Tests](#writing-tests) +1. [Get Help](#get-help) - - Commit using Unix line endings (check the settings around "crlf" in - git-config(1)). +## Getting Started - - Do not check in commented out code or unneeded files. +- Fork the module repository on GitHub and clone to your workspace - - The first line of the commit message should be a short - description (50 characters is the soft limit, excluding ticket - number(s)), and should skip the full stop. +- Make your changes! - - Associate the issue in the message. The first line should include - the issue number in the form "(#XXXX) Rest of message". +## Commit Checklist - - The body should provide a meaningful commit message, which: +### The Basics - - uses the imperative, present tense: "change", not "changed" or - "changes". +- [x] my commit is a single logical unit of work - - includes motivation for the change, and contrasts its - implementation with the previous behavior. +- [x] I have checked for unnecessary whitespace with "git diff --check" - - Make sure that you have tests for the bug you are fixing, or - feature you are adding. +- [x] my commit does not include commented out code or unneeded files - - Make sure the test suites passes after your commit: - `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below +### The Content - - When introducing a new feature, make sure it is properly - documented in the README.md +- [x] my commit includes tests for the bug I fixed or feature I added - * Submission: +- [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality + +- [x] my code passes existing test suites - * Pre-requisites: +### The Commit Message - - Make sure you have a [GitHub account](https://github.com/join) +- [x] the first line of my commit message includes: - - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. + - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line" + + - [x] a short description (50 characters is the soft limit, excluding ticket number(s)) - * Preferred method: +- [x] the body of my commit message: - - Fork the repository on GitHub. + - [x] is meaningful - - Push your changes to a topic branch in your fork of the - repository. (the format ticket/1234-short_description_of_change is - usually preferred for this project). + - [x] uses the imperative, present tense: "change", not "changed" or "changes" - - Submit a pull request to the repository in the puppetlabs - organization. + - [x] includes motivation for the change, and contrasts its implementation with the previous behavior -The long version -================ +## Submission + +### Pre-requisites + +- Make sure you have a [GitHub account](https://github.com/join) + +- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. + +### Push and PR + +- Push your changes to your fork + +- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization + +## More about commits 1. Make separate commits for logically separate changes. @@ -104,37 +116,32 @@ The long version GitHub has some pretty good [general documentation](http://help.github.com/) on using their site. They also have documentation on - [creating pull requests](http://help.github.com/send-pull-requests/). + [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). In general, after pushing your topic branch up to your repository on GitHub, you can switch to the branch in the GitHub UI and click "Pull Request" towards the top of the page in order to open a pull request. + 3. Update the related JIRA issue. - 3. Update the related GitHub issue. - - If there is a GitHub issue associated with the change you + If there is a JIRA issue associated with the change you submitted, then you should update the ticket to include the location of your branch, along with any other commentary you may wish to make. -Testing -======= +# Testing -Getting Started ---------------- +## Getting Started -Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby -package manager such as [bundler](http://bundler.io/) what Ruby packages, +Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages, or Gems, are required to build, develop, and test this software. -Please make sure you have [bundler installed](http://bundler.io/#getting-started) -on your system, then use it to install all dependencies needed for this project, -by running +Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to +install all dependencies needed for this project in the project root by running ```shell -% bundle install +% bundle install --path .bundle/gems Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/.. Using rake (10.1.0) @@ -148,7 +155,7 @@ Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. ``` -NOTE some systems may require you to run this command with sudo. +NOTE: some systems may require you to run this command with sudo. If you already have those gems installed, make sure they are up-to-date: @@ -156,26 +163,27 @@ If you already have those gems installed, make sure they are up-to-date: % bundle update ``` -With all dependencies in place and up-to-date we can now run the tests: +## Running Tests + +With all dependencies in place and up-to-date, run the tests: + +### Unit Tests ```shell % bundle exec rake spec ``` -This will execute all the [rspec tests](http://rspec-puppet.com/) tests -under [spec/defines](./spec/defines), [spec/classes](./spec/classes), -and so on. rspec tests may have the same kind of dependencies as the -module they are testing. While the module defines in its [Modulefile](./Modulefile), +This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on. +rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json), rspec tests define them in [.fixtures.yml](./fixtures.yml). -Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) -tests. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/)) with, controlling it with -[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test -scenarios. In order to run these, you will need both of those tools -installed on your system. +### Acceptance Tests + +Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under +[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test +scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system. -You can run them by issuing the following command +Run the tests by issuing the following command ```shell % bundle exec rake spec_clean @@ -183,35 +191,81 @@ You can run them by issuing the following command ``` This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) +install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) and then run all the tests under [spec/acceptance](./spec/acceptance). -Writing Tests -------------- +## Writing Tests + +### Unit Tests -XXX getting started writing tests. +When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a +catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs] +but here's a tiny sample: -If you have commit access to the repository -=========================================== +Sample manifest: -Even if you have commit access to the repository, you will still need to -go through the process above, and have someone else review and merge -in your changes. The rule is that all changes must be reviewed by a -developer on the project (that did not write the code) to ensure that -all changes go through a code review process. +```puppet +file { "a test file": + ensure => present, + path => "/etc/sample", +} +``` + +Sample test: -Having someone other than the author of the topic branch recorded as -performing the merge is the record that they performed the code -review. +```ruby +it 'does a thing' do + expect(subject).to contain_file("a test file").with({:path => "/etc/sample"}) +end +``` +### Acceptance Tests + +Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it +twice to check for idempotency or errors, then run expectations. + +```ruby +it 'does an end-to-end thing' do + pp = <<-EOF + file { 'a test file': + ensure => present, + path => "/etc/sample", + content => "test string", + } + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + +end + +describe file("/etc/sample") do + it { is_expected.to contain "test string" } +end -Additional Resources -==================== +``` -* [Getting additional help](http://puppet.com/community/get-help) +# If you have commit access to the repository -* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) +Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge +in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that +all changes go through a code review process.** -* [General GitHub documentation](http://help.github.com/) +The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch. +# Get Help + +### On the web +* [Puppet help messageboard](http://puppet.com/community/get-help) +* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) +* [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) + +### On chat +* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli +* IRC (freenode) #puppet-dev, #voxpupuli + + +[rspec-puppet]: http://rspec-puppet.com/ +[rspec-puppet_docs]: http://rspec-puppet.com/documentation/ +[beaker]: https://github.com/puppetlabs/beaker +[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec diff --git a/3rdparty/modules/concat/Gemfile b/3rdparty/modules/concat/Gemfile index 5dfff2dbd..33ae7297d 100644 --- a/3rdparty/modules/concat/Gemfile +++ b/3rdparty/modules/concat/Gemfile @@ -1,156 +1,73 @@ -#This file is generated by ModuleSync, do not edit. +source ENV['GEM_SOURCE'] || 'https://rubygems.org' -source ENV['GEM_SOURCE'] || "https://rubygems.org" - -# Determines what type of gem is requested based on place_or_version. -def gem_type(place_or_version) - if place_or_version =~ /^git:/ - :git - elsif place_or_version =~ /^file:/ - :file - else - :gem - end -end - -# Find a location or specific version for a gem. place_or_version can be a -# version, which is most often used. It can also be git, which is specified as -# `git://somewhere.git#branch`. You can also use a file source location, which -# is specified as `file://some/location/on/disk`. def location_for(place_or_version, fake_version = nil) - if place_or_version =~ /^(git[:@][^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact - elsif place_or_version =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] + git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} + file_url_regex = %r{\Afile:\/\/(?.*)} + + if place_or_version && (git_url = place_or_version.match(git_url_regex)) + [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) + ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else - [place_or_version, { :require => false }] + [place_or_version, { require: false }] end end -# Used for gem conditionals -supports_windows = true ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" - -# The following gems are not included by default as they require DevKit on Windows. -# You should probably include them in a Gemfile.local or a ~/.gemfile -#gem 'pry' #this may already be included in the gemfile -#gem 'pry-stack_explorer', :require => false -#if RUBY_VERSION =~ /^2/ -# gem 'pry-byebug' -#else -# gem 'pry-debugger' -#end +minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby" - gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "puppet-module-posix-dev-r#{minor_version}", :require => false, :platforms => "ruby" - gem "puppet-module-win-dev-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "fast_gettext", '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') + gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') + gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-lint-i18n", require: false + gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') end -group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", :require => false, :platforms => "ruby" - gem "puppet-module-win-system-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3') - gem "beaker-pe", :require => false - gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) - gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) - gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') -end +puppet_version = ENV['PUPPET_GEM_VERSION'] +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] -gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) +gems = {} -# Only explicitly specify Facter/Hiera if a version has been specified. -# Otherwise it can lead to strange bundler behavior. If you are seeing weird -# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable -# to `1` and then run bundle install. -gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] -gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] +gems['puppet'] = location_for(puppet_version) -# For Windows dependencies, these could be required based on the version of -# Puppet you are requiring. Anything greater than v3.5.0 is going to have -# Windows-specific dependencies dictated by the gem itself. The other scenario -# is when you are faking out Puppet to use a local file path / git path. -explicitly_require_windows_gems = false -puppet_gem_location = gem_type(ENV['PUPPET_GEM_VERSION']) -# This is not a perfect answer to the version check -if puppet_gem_location != :gem || (ENV['PUPPET_GEM_VERSION'] && Gem::Version.correct?(ENV['PUPPET_GEM_VERSION']) && Gem::Requirement.new('< 3.5.0').satisfied_by?(Gem::Version.new(ENV['PUPPET_GEM_VERSION'].dup))) - if Gem::Platform.local.os == 'mingw32' - explicitly_require_windows_gems = true - end - if puppet_gem_location == :gem - # If facterversion hasn't been specified and we are - # looking for a Puppet Gem version less than 3.5.0, we - # need to ensure we get a good Facter for specs. - gem "facter",">= 1.6.11","<= 1.7.5",:require => false unless ENV['FACTER_GEM_VERSION'] - # If hieraversion hasn't been specified and we are - # looking for a Puppet Gem version less than 3.5.0, we - # need to ensure we get a good Hiera for specs. - gem "hiera",">= 1.0.0","<= 1.3.0",:require => false unless ENV['HIERA_GEM_VERSION'] - end -end - -if explicitly_require_windows_gems - # This also means Puppet Gem less than 3.5.0 - this has been tested back - # to 3.0.0. Any further back is likely not supported. - if puppet_gem_location == :gem - gem "ffi", "1.9.0", :require => false - gem "win32-eventlog", "0.5.3","<= 0.6.5", :require => false - gem "win32-process", "0.6.5","<= 0.7.5", :require => false - gem "win32-security", "~> 0.1.2","<= 0.2.5", :require => false - gem "win32-service", "0.7.2","<= 0.8.8", :require => false - gem "minitar", "0.5.4", :require => false - else - gem "ffi", "~> 1.9.0", :require => false - gem "win32-eventlog", "~> 0.5","<= 0.6.5", :require => false - gem "win32-process", "~> 0.6","<= 0.7.5", :require => false - gem "win32-security", "~> 0.1","<= 0.2.5", :require => false - gem "win32-service", "~> 0.7","<= 0.8.8", :require => false - gem "minitar", "~> 0.5.4", :require => false - end - - gem "win32-dir", "~> 0.3","<= 0.4.9", :require => false - gem "win32console", "1.3.2", :require => false if RUBY_VERSION =~ /^1\./ +# If facter or hiera versions have been specified via the environment +# variables - # sys-admin was removed in Puppet 3.7.0+, and doesn't compile - # under Ruby 2.3 - so restrict it to Ruby 1.x - gem "sys-admin", "1.5.6", :require => false if RUBY_VERSION =~ /^1\./ +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version - # Puppet less than 3.7.0 requires these. - # Puppet 3.5.0+ will control the actual requirements. - # These are listed in formats that work with all versions of - # Puppet from 3.0.0 to 3.6.x. After that, these were no longer used. - # We do not want to allow newer versions than what came out after - # 3.6.x to be used as they constitute some risk in breaking older - # functionality. So we set these to exact versions. - gem "win32-api", "1.4.8", :require => false - gem "win32-taskscheduler", "0.2.2", :require => false - gem "windows-api", "0.4.3", :require => false - gem "windows-pr", "1.2.3", :require => false -else - if Gem::Platform.local.os == 'mingw32' - # If we're using a Puppet gem on windows, which handles its own win32-xxx gem dependencies (Pup 3.5.0 and above), set maximum versions - # Required due to PUP-6445 - gem "win32-dir", "<= 0.4.9", :require => false - gem "win32-eventlog", "<= 0.6.5", :require => false - gem "win32-process", "<= 0.7.5", :require => false - gem "win32-security", "<= 0.2.5", :require => false - gem "win32-service", "<= 0.8.8", :require => false - end +if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} + # If we're using a Puppet gem on Windows which handles its own win32-xxx gem + # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). + gems['win32-dir'] = ['<= 0.4.9', require: false] + gems['win32-eventlog'] = ['<= 0.6.5', require: false] + gems['win32-process'] = ['<= 0.7.5', require: false] + gems['win32-security'] = ['<= 0.2.5', require: false] + gems['win32-service'] = ['0.8.8', require: false] end -# Evaluate Gemfile.local if it exists -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) +gems.each do |gem_name, gem_params| + gem gem_name, *gem_params end -# Evaluate ~/.gemfile if it exists -if File.exists?(File.join(Dir.home, '.gemfile')) - eval(File.read(File.join(Dir.home, '.gemfile')), binding) -end +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] -# vim:ft=ruby +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end +end +# vim: syntax=ruby diff --git a/3rdparty/modules/concat/HISTORY.md b/3rdparty/modules/concat/HISTORY.md new file mode 100644 index 000000000..abbf1bd70 --- /dev/null +++ b/3rdparty/modules/concat/HISTORY.md @@ -0,0 +1,405 @@ +## 4.2.1 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-concat/compare/4.2.0...4.2.1) + +### Fixed +- \(MODULES-6817\) noop =\> false for concat\_file [\#492](https://github.com/puppetlabs/puppetlabs-concat/pull/492) ([hunner](https://github.com/hunner)) + +## Supported Release 4.2.0 +### Summary +This release introduces the conversion of the module to use PDK 1.3.2, along with the addition of rubocop with associated fixes. + +#### Changed +- All changes in this release are for enabling rubocop, alongside the module then being converted over to the PDK. + + +## Supported Releases 4.1.1 +### Summary +This release is to update the formatting of the module, rubocop having been run for all ruby files and been set to run automatically on all future commits. + +#### Changed +- Rubocop has been implemented. +- SLES 10, Windows 2003 R2 and OSX 10.9 removed as supported. +- OSX 10.10 and 10.11 added as supported. + +## Supported Releases 4.1.0 +### Summary + +This release is a rollup of changes. The most notable change being the addition of the 'format' attribute which allows output in JSON and YAML formats, and the 'force' attribute which if true forces a merge of duplicate keys for these formats. + +#### Features +- Format and force attributes added. +- Deprecated is_string in favour of puppet language. +- End of Life Ubuntu releases removed as supported. +- Debian 9 added and Debian 6 removed as supported. + +#### Bugfixes +- (MODULES-4359) Fix native types so they can be used directly. +- Update to tests to handle errors containing quote marks. +- Update to tests to follow rspec-puppet pattern. + +## Supported Releases 4.0.1 +### Summary + +This is a small release that updates regex in a test due to changes made in Puppet. + +#### Bugfixes + +- (MODULES-5085) Ensure that replace test handles qoutes in change message + +## Supported Releases 3.0.0 & 4.0.0 +### Summary + +This double release adds new Puppet 4 data types. The 3.0.0 release is fully backwards compatible to +existing Puppet 4 configurations and provides you with [deprecation warnings](https://github.com/puppetlabs/puppetlabs-stdlib#deprecation) for every argument that +will not work as expected with the final 4.0.0 release. See the [stdlib docs](https://github.com/puppetlabs/puppetlabs-stdlib#validate_legacy) for an in-depth discussion of this. + +If you're still running Puppet 3, remain on the latest puppetlabs-concat 2.x release for now, and see the documentation to [upgrade to Puppet 4](https://docs.puppet.com/puppet/4.6/reference/upgrade_major_pre.html). + +#### Added +- puppet-strings documentation +- Puppet 4 data types and deprecation warnings + +#### Changed +- stdlib dependency changed to 4.13.1 +- supported Puppet version changed to 4.7. + +## Supported Release 2.2.1 +### Summary + +This is a backwards compatible bugfix release. + +#### Bugfixes + +- (MODULES-4350) Makes :path the namevar for concat_file +- (MODULES-4351) Prevents the :order parameter from accepting arbitrary values in concat_file +- (MODULES-4352) Restricts the :replace parameter to values accepted by file +- (MODULES-4474) Drops auto requirement of fragments +- (MODULES-3900) Improves error messages in concat::fragment +- Uses the whole fragment title when sorting + +## Supported Release 2.2.0 +### Summary + +This release includes support for Debian 8 and Ubuntu 16.04 in addition to numerous bugfixes. + +#### Features +- Adds Debian 8 support +- Adds Ubuntu 16.04 support + +#### Bugfixes +- Fixes the stdlib lower dependency. +- (MODULES-3027) Fixes escaping the '*' character in tag creation. +- (MODULES-3097) Fixes fragment sorting by alpha +- Correctly propagates 'validate_cmd' parameter to generated file resource +- Correctly escapes disallowed characters in fragment tag creation +- (MODULES-3332) Correct the target path validation +- (MODULES-3463) Properly passes metaparams to generated resource + +## Supported Release 2.1.0 +### Summary + +This is a re-release of concat as a resource type. This release also includes new features and bugfixes on top of the previously YANKED 2.0.1 release. + +#### Features +- Adds the show_diff property. +- Adds the selinux related file params. +- Allows integer UID/GID values to be passed into `$owner` and `$group` + +#### Bugfixes +- Adds a workaround to PUP-1963: generated resources never receiving dependency edges. +- Fixes occassional failure to find directory environment. + +## Supported Release 1.2.5 +### Summary + +Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. + +## 2015-07-21 - Supported Release 1.2.4 +### Summary + +This release includes some ruby path and lint fixes. + +#### Bugfixes +- Use correct ruby path with PE and AIO +- Lint fixes +- Use correct ruby path on FreeBSD +- Test fixes + +## 2015-06-02 - Supported Release 2.0.1 [YANKED] +### Summary + +This is a bugfix release. + +#### Bugfixes +- Fixes dependency graphing with concurrent modification of the same file. +- Fixes handling fragment target. +- Fixes the defaulted force behavior to handle empty concats correctly. + +## 2015-06-02 - Supported Release 1.2.3 +### Summary + +This release includes a README fix to document correct behavior of fragment target parameter. + +#### Bugfixes +- README Fix to correctly document how a fragment $target param should work. + +## 2015-05-12 - Supported Release 2.0.0 [YANKED] +### Summary + +This is a major release. Includes re-implementation of concat to use native Type and Providers, resulting in significantly improved performance and testability. Also includes a bugfix to alpha ordering of fragments. + +#### Features +- Re-implementation of concat to use native Type and Providers. + +#### Bugfixes +- Fixes a bug in alpha ordering of fragments. + +## 2015-05-12 - Supported Release 1.2.2 +### Summary + +This release includes a bugfix. + +#### Bugfixes +- Fixes a bug introduced by MODULES-1700, in handling default retrieval of fragment backup parameter. + +## 2015-04-14 - Supported Release 1.2.1 +### Summary + +This release includes bugfixes, test improvements, and a rewritten README. + +#### Bugfixes + +- Verifies existence of $is_pe before using it. +- Adds validation for $order param to not allow restricted characters. +- Sets the group id on Fragments for versions of Facter that contain the $gid fact. +- Sets the script group to 0 if the script is owned by root. +- Explicitly sets script and concat directories to the same owner and group. +- Re-adds support for fragment backup, so that static compiler can work with filebucket (MODULES-1700). + +## 2015-02-17 - Supported Release 1.2.0 +### Summary + +This release includes a number of bugfixes and adds support for running a validation command when using puppet >= 3.5.0. + +#### Features +- Support running a validation command for Puppet >= 3.5.0 + +#### Bugfixes +- Reset poisoned defaults from Exec +- Use concatfragments.rb on AIX since it doesn't support print0 +- Make sure ruby is in the path for PE (MODULES-1456) +- Fix missing method for check_is_owned_by for windows (MODULES-1764) +- Fix sort by numeric + +## 2014-10-28 - Supported Release 1.1.2 +### Summary + +This release includes bugfixes and test improvements. The module was tested against SLES10 and SLES12 and found to work against those platforms with no module improvements. Metadata was updated to include those as supported platforms. + +#### Bugfixes +- newline didn't work for Windows and Solaris. This has been fixed. +- Install certs on Windows for acceptance tests +- Update tests to work with strict variables (no module updates were required) +- Update tests to work on Windows +- Fix typo in CHANGELOG.md + +## 2014-09-10 - Supported Release 1.1.1 +### Summary + +This is a bugfix release, and the first supported release of the 1.1.x series. + +#### Bugfixes +- Make the `$order` parameter default to a string and be validated as an integer + or a string +- Use the ruby script on Solaris to not break Sol10 support +- Add quotes to the ruby script location for Windows +- Fix typos in README.md +- Make regex in concat::setup case-insensitive to make it work on Windows +- Make sure concat fragments are always replaced +- Fix validation to allow `$backup` to be a boolean +- Remove dependency on stdlib 4.x +- Fix for lack of idempotency with `ensure => 'absent'` +- Fix tests and spec_helper +- Synchronized files for more consistency across modules via modulesync + +## 2014-05-14 - Release 1.1.0 +### Summary + +This release is primarily a bugfix release since 1.1.0-rc1. + +#### Features +- Improved testing, with tests moved to beaker + +#### Bugfixes +- No longer attempts to set fragment owner and mode on Windows +- Fix numeric sorting +- Fix incorrect quoting +- Fix newlines + +## 2014-01-03 - Release 1.1.0-rc1 +### Summary + +This release of concat was 90% written by Joshua Hoblitt, and the module team +would like to thank him for the huge amount of work he put into this release. + +This module deprecates a bunch of old parameters and usage patterns, modernizes +much of the manifest code, simplifies a whole bunch of logic and makes +improvements to almost all parts of the module. + +The other major feature is windows support, courtesy of luisfdez, with an +alternative version of the concat bash script in ruby. We've attempted to +ensure that there are no backwards incompatible changes, all users of 1.0.0 +should be able to use 1.1.0 without any failures, but you may find deprecation +warnings and we'll be aggressively moving for a 2.0 to remove those too. + +For further information on deprecations, please read: +https://github.com/puppetlabs/puppetlabs-concat/blob/master/README.md#api-deprecations + +#### Removed +- Puppet 0.24 support. +- Filebucket backup of all file resources except the target concatenated file. +- Default owner/user/group values. +- Purging of long unused /usr/local/bin/concatfragments.sh + +### Features +- Windows support via a ruby version of the concat bash script. +- Huge amount of acceptance testing work added. +- Documentation (README) completely rewritten. +- New parameters in concat: + - `ensure`: Controls if the file should be present/absent at all. + - Remove requirement to include concat::setup in manifests. + - Made `gnu` parameter deprecated. + - Added parameter validation. + +### Bugfixes + - Ensure concat::setup runs before concat::fragment in all cases. + - Pluginsync references updated for modern Puppet. + - Fix incorrect group parameter. + - Use $owner instead of $id to avoid confusion with $::id + - Compatibility fixes for Puppet 2.7/ruby 1.8.7 + - Use LC_ALL=C instead of LANG=C + - Always exec the concatfragments script as root when running as root. + - Syntax and other cleanup changes. + +## 2014-06-25 - Supported Release 1.0.4 +### Summary + +This release has test fixes. + +#### Features +- Added test support for OSX. + +#### Bugfixes + +#### Known bugs + +* Not supported on Windows. + +## 2014-06-04 - Release 1.0.3 +### Summary + +This release adds compatibility for PE3.3 and fixes tests. + +#### Features +- Added test support for Ubuntu Trusty. + +#### Bugfixes + +#### Known bugs + +*Not supported on Windows. + +## 2014-03-04 - Supported Release 1.0.2 +### Summary + +This is a supported release. No functional changes were made from 1.0.1. + +#### Features +- Huge amount of tests backported from 1.1. +- Documentation rewrite. + +#### Bugfixes + +#### Known Bugs + +* Not supported on Windows. + + +## 2014-02-12 - 1.0.1 +### Summary + +Minor bugfixes for sorting of fragments and ordering of resources. + +#### Bugfixes +- LANG => C replaced with LC_ALL => C to reduce spurious recreation of +fragments. +- Corrected pluginsync documentation. +- Ensure concat::setup always runs before fragments. + + +## 2013-08-09 - 1.0.0 +### Summary + +Many new features and bugfixes in this release, and if you're a heavy concat +user you should test carefully before upgrading. The features should all be +backwards compatible but only light testing has been done from our side before +this release. + +#### Features +- New parameters in concat: + - `replace`: specify if concat should replace existing files. + - `ensure_newline`: controls if fragments should contain a newline at the end. +- Improved README documentation. +- Add rspec:system tests (rake spec:system to test concat) + +#### Bugfixes +- Gracefully handle \n in a fragment resource name. +- Adding more helpful message for 'pluginsync = true' +- Allow passing `source` and `content` directly to file resource, rather than +defining resource defaults. +- Added -r flag to read so that filenames with \ will be read correctly. +- sort always uses LANG=C. +- Allow WARNMSG to contain/start with '#'. +- Replace while-read pattern with for-do in order to support Solaris. + +#### CHANGELOG: +- 2010/02/19 - initial release +- 2010/03/12 - add support for 0.24.8 and newer + - make the location of sort configurable + - add the ability to add shell comment based warnings to + top of files + - add the ablity to create empty files +- 2010/04/05 - fix parsing of WARN and change code style to match rest + of the code + - Better and safer boolean handling for warn and force + - Don't use hard coded paths in the shell script, set PATH + top of the script + - Use file{} to copy the result and make all fragments owned + by root. This means we can chnage the ownership/group of the + resulting file at any time. + - You can specify ensure => "/some/other/file" in concat::fragment + to include the contents of a symlink into the final file. +- 2010/04/16 - Add more cleaning of the fragment name - removing / from the $name +- 2010/05/22 - Improve documentation and show the use of ensure => +- 2010/07/14 - Add support for setting the filebucket behavior of files +- 2010/10/04 - Make the warning message configurable +- 2010/12/03 - Add flags to make concat work better on Solaris - thanks Jonathan Boyett +- 2011/02/03 - Make the shell script more portable and add a config option for root group +- 2011/06/21 - Make base dir root readable only for security +- 2011/06/23 - Set base directory using a fact instead of hardcoding it +- 2011/06/23 - Support operating as non privileged user +- 2011/06/23 - Support dash instead of bash or sh +- 2011/07/11 - Better solaris support +- 2011/12/05 - Use fully qualified variables +- 2011/12/13 - Improve Nexenta support +- 2012/04/11 - Do not use any GNU specific extensions in the shell script +- 2012/03/24 - Comply to community style guides +- 2012/05/23 - Better errors when basedir isnt set +- 2012/05/31 - Add spec tests +- 2012/07/11 - Include concat::setup in concat improving UX +- 2012/08/14 - Puppet Lint improvements +- 2012/08/30 - The target path can be different from the $name +- 2012/08/30 - More Puppet Lint cleanup +- 2012/09/04 - RELEASE 0.2.0 +- 2012/12/12 - Added (file) $replace parameter to concat diff --git a/3rdparty/modules/concat/NOTICE b/3rdparty/modules/concat/NOTICE index 89dd0b569..53ff2a771 100644 --- a/3rdparty/modules/concat/NOTICE +++ b/3rdparty/modules/concat/NOTICE @@ -1,6 +1,6 @@ Puppet Module - puppetlabs-concat -Copyright 2017 Puppet, Inc. +Copyright 2018 Puppet, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/3rdparty/modules/concat/README.md b/3rdparty/modules/concat/README.md index 6b04070c6..6c2f08c79 100644 --- a/3rdparty/modules/concat/README.md +++ b/3rdparty/modules/concat/README.md @@ -4,25 +4,24 @@ 1. [Overview](#overview) 2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with concat](#setup) - * [What concat affects](#what-concat-affects) * [Beginning with concat](#beginning-with-concat) 4. [Usage - Configuration options and additional functionality](#usage) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Defines](#defines) - * [Parameters](#parameters) * [Removed functionality](#removed-functionality) 6. [Limitations - OS compatibility, etc.](#limitations) 7. [Development - Guide for contributing to the module](#development) + ## Overview The concat module lets you construct files from multiple ordered fragments of text. + ## Module Description The concat module lets you gather `concat::fragment` resources from your other modules and order them into a coherent file through a single `concat` resource. + ### Beginning with concat To start using concat you need to create: @@ -44,6 +43,7 @@ concat::fragment { 'tmpfile': } ~~~ + ## Usage ### Maintain a list of the major modules on a node @@ -60,7 +60,7 @@ class motd { mode => '0644' } - concat::fragment{ 'motd_header': + concat::fragment { 'motd_header': target => $motd, content => "\nPuppet modules on this server:\n\n", order => '01' @@ -68,7 +68,7 @@ class motd { # let local users add to the motd by creating a file called # /etc/motd.local - concat::fragment{ 'motd_local': + concat::fragment { 'motd_local': target => $motd, source => '/etc/motd.local', order => '15' @@ -76,14 +76,17 @@ class motd { } # let other modules register themselves in the motd -define motd::register($content="", $order='10') { +define motd::register ( + $content = "", + $order = '10', +) { if $content == "" { $body = $name } else { $body = $content } - concat::fragment{ "motd_fragment_$name": + concat::fragment { "motd_fragment_$name": target => '/etc/motd', order => $order, content => " -- $body\n" @@ -97,7 +100,7 @@ Then, in the declarations for each module on the node, add `motd::register{ 'Apa class apache { include apache::install, apache::config, apache::service - motd::register{ 'Apache': } + motd::register { 'Apache': } } ~~~ @@ -114,332 +117,12 @@ When you're finished, the motd file will look something like this: ~~~ + ## Reference -### Defines -* `concat`: Manages a file, compiled from one or more text fragments. -* `concat::fragment`: Manages a fragment of text to be compiled into a file. - -### Types -* `concat_file`: Generates a file with content from fragments sharing a common unique tag. -* `concat_fragment`: Manages the fragment. - -### Parameters - -#### Define: `concat` - -All the parameters listed below are optional. - -##### `backup` - -Data type: Boolean, String. - -Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: `true`, `false`, or a string representing either a target filebucket or a filename extension beginning with ".". - -Default value: 'puppet'. - -##### `ensure` - -Data type: String. - -Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. - -Default value: 'present'. - -##### `ensure_newline` - -Data type: Boolean. - -Specifies whether to add a line break at the end of each fragment that doesn't already end in one. Valid options: `true` and `false`. - -Default value: `false`. - -##### `group` - -Optional. - -Data type: String, Integer. - -Specifies a permissions group for the destination file. Valid options: a string containing a group name. - -Default value: `undef`. - -##### `mode` - -Data type: String. - -Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. - -Default value: '0644'. - -##### `order` - -Data type: String. - -Specifies a method for sorting your fragments by name within the destination file. Valid options: 'alpha' (e.g., '1, 10, 2') or 'numeric' (e.g., '1, 2, 10'). - -You can override this setting for individual fragments by adjusting the `order` parameter in their `concat::fragment` declarations. - -Default value: 'alpha'. - -##### `owner` - -Optional. - -Data type: String, Integer. - -Specifies the owner of the destination file. Valid options: a string containing a username. - -Default value: `undef`. - -##### `path` - -Data type: Stdlib::AbsolutePath. - -Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. - -Default value: `namevar` - -##### `replace` - -Data type: Boolean. - -Specifies whether to overwrite the destination file if it already exists. Valid options: `true` and `false`. - -Default value: `true`. - -##### `show_diff` - -Data type: Boolean. - -Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure reporting methods. Valid options: `true`. - -Default value: `true`. - -##### `validate_cmd` - -Optional. - -Data type: String. - -Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. - -Default value: `undef`. - -##### `warn` - -Data type: Boolean, String. - -Specifies whether to add a header message at the top of the destination file. Valid options: the booleans `true` and `false`, or a string to serve as the header. - -If you set 'warn' to `true`, `concat` adds the following line with an `order` of `0`: - -Default value: `false`. - -~~~ -# This file is managed by Puppet. DO NOT EDIT. -~~~ - -Before 2.0.0, this parameter would add a newline at the end of the warn -message. To improve flexibilty, this was removed. Please add it explicitly if -you need it. - -##### `selinux_ignore_defaults` - -See the `file` type's -[`selinux_ignore_defaults`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults) -documentention. - -##### `selrange` - -See the `file` type's -[`selrange`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange) -documentention. - -##### `selrole` - -See the `file` type's -[`selrole`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole) -documentention. - -##### `seltype` - -See the `file` type's -[`seltype`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype) -documentention. - -##### `seluser` - -See the `file` type's -[`seluser`](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser) -documentention. - - -#### Define: `concat::fragment` - -Except where noted, all the below parameters are optional. - -##### `content` - -Data type: String. - -Supplies the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string. - -Default value: `undef`. - -##### `order` - -Data type: String, Integer. - -Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. Valid options: a string (recommended) or an integer. - -Default value: '10'. - -##### `source` - -Data type: String, Array. - -Specifies a file to read into the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string or an array, containing one or more Puppet URLs. - -Default value: `undef`. - -##### `target` - -*Required.* - -Data type: String. - -Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent `concat` resource. - - -#### Type: `concat_file` - -##### `backup` - -Data type: String, Boolean. - -Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's [native `file` resource](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-backup) for execution. Valid options: `true`, `false`, or a string representing either a target filebucket or a filename extension beginning with ".". - -Default value: 'puppet'. - -##### `ensure` - -Data type: String. - -Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and negates the effect of any other parameters. Valid options: 'present' and 'absent'. - -Default value: 'present'. - -##### `ensure_newline` - -Data type: Boolean. - -Specifies whether to add a line break at the end of each fragment that doesn't already end in one. Valid options: `true` and `false`. - -Default value: `false`. - -##### `group` - -Data type: String, Integer. - -Specifies a permissions group for the destination file. Valid options: a string containing a group name. - -Default value: `undef`. - -##### `mode` - -Data type: String. - -Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. - -Default value: '0644'. - -##### `order` - -Data type: String. - -Specifies a method for sorting your fragments by name within the destination file. Valid options: 'alpha' (e.g., '1, 10, 2') or 'numeric' (e.g., '1, 2, 10'). - -You can override this setting for individual fragments by adjusting the `order` parameter in their `concat::fragment` declarations. - -Default value: 'numeric'. - -##### `owner` - -Data type: String, Integer. - -Specifies the owner of the destination file. Valid options: a string containing a username. - -Default value: `undef`. - -##### `path` - -Data type: String. - -Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the title of your declared resource. - -Default value: `namevar`. - -##### `replace` - -Data type: Boolean. - -Specifies whether to overwrite the destination file if it already exists. Valid options: `true` and `false`. - -Default value: `true`. - -##### `tag` - -Data type: String. - -*Required.* Specifies a unique tag reference to collect all concat_fragments with the same tag. - -##### `validate_cmd` - -Data typeL String - -Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to be passed to a file resource. - -Default value: `undef`. - -#### Type: `concat_fragment` - -##### `content` - -Data type: String. - -Supplies the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string. - -Default value: `undef`. - -##### `order` - -Data type: String, Integer. - -Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. Valid options: a string (recommended) or an integer. - -Default value: '10'. - -##### `source` - -Data type: String. - -Specifies a file to read into the content of the fragment. **Note**: You must supply either a `content` parameter or a `source` parameter. Valid options: a string or an array, containing one or more Puppet URLs. - -Default value: `undef`. - -##### `tag` - -Data type: String. - -*Required.* Specifies a unique tag to be used by concat_file to reference and collect content. - -##### `target` - -Data type: String. - -*Required.* Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent `concat_file` resource. +See [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-concat/blob/master/REFERENCE.md) + ### Removed functionality The following functionality existed in previous versions of the concat module, but was removed in version 2.0.0: @@ -455,17 +138,23 @@ The `concat::setup` class has also been removed. Prior to concat version 2.0.0, if you set the `warn` parameter to a string value of `true`, `false`, 'yes', 'no', 'on', or 'off', the module translated the string to the corresponding boolean value. In concat version 2.0.0 and newer, the `warn_header` parameter treats those values the same as other strings and uses them as the content of your header message. To avoid that, pass the `true` and `false` values as booleans instead of strings. + ## Limitations This module has been tested on [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix), and no issues have been identified. +For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-concat/blob/master/metadata.json) + + ## Development +We are experimenting with a new tool for running acceptance tests. It's name is [puppet_litmus](https://github.com/puppetlabs/puppet_litmus) this replaces beaker as the test runner. To run the acceptance tests follow the instructions [here](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module). + Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. -For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) +For more information, see our [module contribution guide](https://puppet.com/docs/puppet/latest/contributing.html). ### Contributors @@ -473,4 +162,4 @@ Richard Pijnenburg ([@Richardp82](http://twitter.com/richardp82)) Joshua Hoblitt ([@jhoblitt](http://twitter.com/jhoblitt)) -[More contributors.](https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors) +[More contributors](https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors). diff --git a/3rdparty/modules/concat/REFERENCE.md b/3rdparty/modules/concat/REFERENCE.md new file mode 100644 index 000000000..46e5a26aa --- /dev/null +++ b/3rdparty/modules/concat/REFERENCE.md @@ -0,0 +1,443 @@ +# Reference + + +## Table of Contents + +**Defined types** + +* [`concat`](#concat): Manages a file, compiled from one or more text fragments. +* [`concat::fragment`](#concatfragment): Manages a fragment of text to be compiled into a file. + +**Resource types** + +* [`concat_file`](#concat_file): Generates a file with content from fragments sharing a common unique tag. +* [`concat_fragment`](#concat_fragment): Manages the fragment. + +## Defined types + +### concat + +Manages a file, compiled from one or more text fragments. + +#### Examples + +##### + +```puppet +concat { '/tmp/concat': + ensure => present, + owner => 'root', + group => 'root', + mode => '0644', +} +``` + +#### Parameters + +The following parameters are available in the `concat` defined type. + +##### `backup` + +Data type: `Variant[Boolean, String]` + +Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's native file +resource for execution. Valid options: true, false, or a string representing either a target filebucket or a filename extension +beginning with ".". + +Default value: 'puppet' + +##### `ensure` + +Data type: `Enum['present', 'absent']` + +Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and +negates the effect of any other parameters. + +Default value: 'present' + +##### `ensure_newline` + +Data type: `Boolean` + +Specifies whether to add a line break at the end of each fragment that doesn't already end in one. + +Default value: `false` + +##### `format` + +Data type: `Optional[String]` + +Specify what data type to merge the fragments as. Valid options: 'plain', 'yaml', 'json', 'json-array', 'json-pretty', +'json-array-pretty'. + +Default value: 'plain' + +##### `force` + +Data type: `Optional[Boolean]` + +Specifies whether to merge data structures, keeping the values with higher order. Used when format is specified as a value other than +'plain'. + +Default value: `false` + +##### `group` + +Data type: `Optional[Variant[String, Integer]]` + +Specifies a permissions group for the destination file. Valid options: a string containing a group name or integer containing a gid. + +Default value: `undef` + +##### `mode` + +Data type: `String` + +Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. + +Default value: '0644' + +##### `order` + +Data type: `Enum['alpha','numeric']` + +Specifies a method for sorting your fragments by name within the destination file. You can override this setting for individual +fragments by adjusting the order parameter in their concat::fragment declarations. + +Default value: 'alpha' + +##### `owner` + +Data type: `Optional[Variant[String, Integer]]` + +Specifies the owner of the destination file. Valid options: a string containing a username or integer containing a uid. + +Default value: `undef` + +##### `path` + +Data type: `Stdlib::Absolutepath` + +Specifies a destination file for the combined fragments. + +Default value: $name + +##### `replace` + +Data type: `Boolean` + +Specifies whether to overwrite the destination file if it already exists. + +Default value: `true` + +##### `selinux_ignore_defaults` + +Data type: `Optional[Boolean]` + +See the file type's selinux_ignore_defaults documentention: +https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults + +Default value: `undef` + +##### `selrange` + +Data type: `Optional[String]` + +See the file type's selrange documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange + +Default value: `undef` + +##### `selrole` + +Data type: `Optional[String]` + +See the file type's selrole documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole + +Default value: `undef` + +##### `seltype` + +Data type: `Optional[String]` + +See the file type's seltype documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype + +Default value: `undef` + +##### `seluser` + +Data type: `Optional[String]` + +See the file type's seluser documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser + +Default value: `undef` + +##### `show_diff` + +Data type: `Boolean` + +Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure +reporting methods. + +Default value: `true` + +##### `validate_cmd` + +Data type: `Optional[String]` + +Specifies a validation command to apply to the destination file. + +Default value: `undef` + +##### `warn` + +Data type: `Variant[Boolean, String]` + +Specifies whether to add a header message at the top of the destination file. Valid options: the booleans true and false, or a string +to serve as the header. +If you set 'warn' to true, concat adds the following line with an order of 0: +`# This file is managed by Puppet. DO NOT EDIT.` +Before 2.0.0, this parameter would add a newline at the end of the warn message. To improve flexibilty, this was removed. Please add +it explicitly if you need it. + +Default value: `false` + +### concat::fragment + +Manages a fragment of text to be compiled into a file. + +#### Parameters + +The following parameters are available in the `concat::fragment` defined type. + +##### `content` + +Data type: `Optional[String]` + +Supplies the content of the fragment. Note: You must supply either a content parameter or a source parameter. + +Default value: `undef` + +##### `order` + +Data type: `Variant[String, Integer]` + +Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. The string +option is recommended. + +Default value: '10' + +##### `source` + +Data type: `Optional[Variant[String, Array]]` + +Specifies a file to read into the content of the fragment. Note: You must supply either a content parameter or a source parameter. +Valid options: a string or an array, containing one or more Puppet URLs. + +Default value: `undef` + +##### `target` + +Data type: `String` + +Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent concat resource. + +## Resource types + +### concat_file + +Generates a file with content from fragments sharing a common unique tag. + +#### Examples + +##### + +```puppet +Concat_fragment <<| tag == 'unique_tag' |>> + +concat_file { '/tmp/file': + tag => 'unique_tag', # Optional. Default to undef + path => '/tmp/file', # Optional. If given it overrides the resource name + owner => 'root', # Optional. Default to undef + group => 'root', # Optional. Default to undef + mode => '0644' # Optional. Default to undef + order => 'numeric' # Optional, Default to 'numeric' + ensure_newline => false # Optional, Defaults to false +} +``` + +#### Properties + +The following properties are available in the `concat_file` type. + +##### `ensure` + +Valid values: present, absent + +Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and +negates the effect of any other parameters. + +Default value: present + +#### Parameters + +The following parameters are available in the `concat_file` type. + +##### `tag` + +Required. Specifies a unique tag reference to collect all concat_fragments with the same tag. + +##### `path` + +Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the +title of your declared resource. + +##### `owner` + +Specifies the owner of the destination file. Valid options: a string containing a username or integer containing a uid. + +##### `group` + +Specifies a permissions group for the destination file. Valid options: a string containing a group name or integer containing a +gid. + +##### `mode` + +Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. + +##### `order` + +Valid values: alpha, numeric + +Specifies a method for sorting your fragments by name within the destination file. You can override this setting for individual +fragments by adjusting the order parameter in their concat::fragment declarations. + +Default value: numeric + +##### `backup` + +Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's native file +resource for execution. Valid options: true, false, or a string representing either a target filebucket or a filename extension +beginning with ".".' + +##### `replace` + +Valid values: `true`, `false`, yes, no + +Specifies whether to overwrite the destination file if it already exists. + +Default value: `true` + +##### `validate_cmd` + +Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to +be passed to a file resource. + +##### `ensure_newline` + +Valid values: `true`, `false`, yes, no + +Specifies whether to add a line break at the end of each fragment that doesn't already end in one. + +Default value: `false` + +##### `format` + +Valid values: plain, yaml, json, json-array, json-pretty, json-array-pretty + +Specify what data type to merge the fragments as. Valid options: 'plain', 'yaml', 'json', 'json-array', 'json-pretty', 'json-array-pretty'. + +Default value: plain + +##### `force` + +Valid values: `true`, `false`, yes, no + +Specifies whether to merge data structures, keeping the values with higher order. + +Default value: `false` + +##### `selinux_ignore_defaults` + +Valid values: `true`, `false`, yes, no + +See the file type's selinux_ignore_defaults documentention: +https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults. + +##### `selrange` + +See the file type's selrange documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange + +##### `selrole` + +See the file type's selrole documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole + +##### `seltype` + +See the file type's seltype documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype + +##### `seluser` + +See the file type's seluser documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser + +##### `show_diff` + +Valid values: `true`, `false`, yes, no + +Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure +reporting methods. + +### concat_fragment + +Manages the fragment. + +#### Examples + +##### + +```puppet +# The example is based on exported resources. + +concat_fragment { \"uniqe_name_${::fqdn}\": + tag => 'unique_name', + order => 10, # Optional. Default to 10 + content => 'some content' # OR + # content => template('template.erb') + source => 'puppet:///path/to/file' +} +``` + +#### Parameters + +The following parameters are available in the `concat_fragment` type. + +##### `name` + +namevar + +Name of resource. + +##### `target` + +Required. Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent +concat_file resource. + +##### `content` + +Supplies the content of the fragment. Note: You must supply either a content parameter or a source parameter. Valid options: a string + +##### `source` + +Specifies a file to read into the content of the fragment. Note: You must supply either a content parameter or a source parameter. +Valid options: a string or an array, containing one or more Puppet URLs. + +##### `order` + +Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. The string +option is recommended. + +Default value: 10 + +##### `tag` + +Specifies a unique tag to be used by concat_file to reference and collect content. + diff --git a/3rdparty/modules/concat/Rakefile b/3rdparty/modules/concat/Rakefile index d12d85495..13b58c86d 100644 --- a/3rdparty/modules/concat/Rakefile +++ b/3rdparty/modules/concat/Rakefile @@ -1,37 +1,78 @@ +require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? +require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? +require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? +require 'puppet_pot_generator/rake_tasks' -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.send('relative') +def changelog_user + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = nil || JSON.load(File.read('metadata.json'))['author'] + raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator user:#{returnVal}" + returnVal +end -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' +def changelog_project + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = nil || JSON.load(File.read('metadata.json'))['source'].match(%r{.*/([^/]*)})[1] + raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator project:#{returnVal}" + returnVal +end - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' - end +def changelog_future_release + return unless Rake.application.top_level_tasks.include? "changelog" + returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] + raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? + puts "GitHubChangelogGenerator future_release:#{returnVal}" + returnVal +end - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' - end +PuppetLint.configuration.send('disable_relative') - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) +if Bundler.rubygems.find_name('github_changelog_generator').any? + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? + config.user = "#{changelog_user}" + config.project = "#{changelog_project}" + config.future_release = "#{changelog_future_release}" + config.exclude_labels = ['maintenance'] + config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." + config.add_pr_wo_labels = true + config.issues = false + config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.configure_sections = { + "Changed" => { + "prefix" => "### Changed", + "labels" => ["backwards-incompatible"], + }, + "Added" => { + "prefix" => "### Added", + "labels" => ["feature", "enhancement"], + }, + "Fixed" => { + "prefix" => "### Fixed", + "labels" => ["bugfix"], + }, + } + end +else + desc 'Generate a Changelog from GitHub' + task :changelog do + raise <= Gem::Version.new('2.2.2')" +EOM end - puts nodeset end + diff --git a/3rdparty/modules/concat/appveyor.yml b/3rdparty/modules/concat/appveyor.yml index 39ca16e45..dd5f850aa 100644 --- a/3rdparty/modules/concat/appveyor.yml +++ b/3rdparty/modules/concat/appveyor.yml @@ -1,38 +1,75 @@ +--- version: 1.1.x.{build} +branches: + only: + - master + - release skip_commits: message: /^\(?doc\)?.*/ clone_depth: 10 init: -- SET -- 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' -- 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' -- 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' -- 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' + - SET + - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' + - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' environment: matrix: - - PUPPET_GEM_VERSION: ~> 4.0 - RUBY_VER: 21 - - PUPPET_GEM_VERSION: ~> 4.0 - RUBY_VER: 21-x64 - - PUPPET_GEM_VERSION: ~> 4.0 - RUBY_VER: 23 - - PUPPET_GEM_VERSION: ~> 4.0 - RUBY_VER: 23-x64 -matrix: - fast_finish: true + - + RUBY_VERSION: 24-x64 + CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 5.0 + RUBY_VERSION: 24-x64 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 6.0 + RUBY_VERSION: 25 + CHECK: parallel_spec + - + PUPPET_GEM_VERSION: ~> 6.0 + RUBY_VERSION: 25-x64 + CHECK: parallel_spec + - + RUBY_VERSION: 25-x64 + ACCEPTANCE: yes + TARGET_HOST: localhost + - + RUBY_VERSION: 25-x64 + ACCEPTANCE: yes + TARGET_HOST: localhost + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 +for: +- + matrix: + only: + - ACCEPTANCE: yes + install: + - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% + - bundle install --jobs 4 --retry 2 + - type Gemfile.lock + test_script: + - bundle exec rake spec_prep + - bundle exec rake litmus:acceptance:localhost install: -- SET PATH=C:\Ruby%RUBY_VER%\bin;%PATH% -- bundle install --jobs 4 --retry 2 --without system_tests -- type Gemfile.lock + - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% + - bundle install --jobs 4 --retry 2 --without system_tests + - type Gemfile.lock build: off test_script: -- bundle exec puppet -V -- ruby -v -- bundle exec rake spec SPEC_OPTS='--format documentation' + - bundle exec puppet -V + - ruby -v + - gem -v + - bundle -v + - bundle exec rake %CHECK% notifications: -- provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false + - provider: Email + to: + - nobody@nowhere.com + on_build_success: false + on_build_failure: false + on_build_status_changed: false diff --git a/3rdparty/modules/concat/checksums.json b/3rdparty/modules/concat/checksums.json index 5451202d3..7c2c54867 100644 --- a/3rdparty/modules/concat/checksums.json +++ b/3rdparty/modules/concat/checksums.json @@ -1,45 +1,62 @@ { - "CHANGELOG.md": "a2dcd11b610fa3584f6951c5d98c3966", - "CONTRIBUTING.md": "77d0440d7cd4206497f99065c60bed46", - "Gemfile": "424b47eb0cccebbdb5f9de35eebee23f", + "CHANGELOG.md": "797c894a671170434fb97d03c426cbd7", + "CONTRIBUTING.md": "4d17f3c942e7c93d1577cc4438a231e4", + "Gemfile": "547549329fb7fa5d97ab51bfe6f72080", + "HISTORY.md": "6ed37ec5db19c992030f012c570b3de9", "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", "MAINTAINERS.md": "c7098fb93e4b0bbeda9e9e2baf2b6476", - "NOTICE": "4a364fe76a22fc737554e108567f5602", - "README.md": "d2b92162dd61835201cfe7beccf328e5", - "Rakefile": "3851f083966b9bbd6d46e50dba5aa52a", - "appveyor.yml": "9b63832ea6e33639c858898d6fd22006", + "NOTICE": "a7e1bd471af3f5e5721d066c0788c07b", + "README.md": "0a2f83b9deb3df7ea2db7f52974f994d", + "REFERENCE.md": "36b601fecfe92afdd81c7820bc0fb735", + "Rakefile": "8e02a195f05b3a18f0a4eb2ec42bc2f4", + "appveyor.yml": "f08d010dcb4b78e15d1d06b5b9e4f795", + "distelli-manifest.yml": "1062db8d0f11c21c6e4f2e072c19b2fd", + "examples/format.pp": "c2cd3b0bf81517c5d79063a896b171af", "examples/fragment.pp": "01096a870ef7d1a1425999745f64cc2d", "examples/init.pp": "356477e6c25394550886bf1c1edb72a4", - "lib/puppet/type/concat_file.rb": "e7b02f157ef1d05bff5c9eb7e05a7772", - "lib/puppet/type/concat_fragment.rb": "3203ea0608a63551676dea9ed53de110", - "locales/config.yaml": "29ee1ea8ad1de5805229f70b552c8d95", - "manifests/fragment.pp": "7e54230e838158d71f5ae1211c849eb9", - "manifests/init.pp": "691979d16e4c2edc8dd50bc235cfd4a3", - "metadata.json": "774d10eeafd64bcf580fca3fb660c602", - "spec/acceptance/backup_spec.rb": "242ce4dce1efba5efb21850b9bb2a342", - "spec/acceptance/concat_spec.rb": "80fdb7d63a419b6bb9f9f42bc217171e", - "spec/acceptance/concurrency_spec.rb": "53984b19ec3a34d7084d7796f98f6857", - "spec/acceptance/fragment_source_spec.rb": "85deac6d359ffffd363c0e96bab173b3", - "spec/acceptance/fragments_are_always_replaced_spec.rb": "be39ed9ed30e7bb48aaccda2d7f730ac", - "spec/acceptance/newline_spec.rb": "5aaf65972c4f8ed4fd1592cd863583f5", + "lib/puppet/type/concat_file.rb": "b9d607321c1da31aaf36f0e89b6648f7", + "lib/puppet/type/concat_fragment.rb": "c3eb08d9825c22bb6a2f5355cdb82265", + "locales/config.yaml": "841206ffdcf2451b3c6f45ddf754c0fe", + "locales/ja/puppetlabs-concat.po": "c9dad056a76901974ded7b150267573a", + "locales/puppetlabs-concat.pot": "1ef3e0fa652481a4cafd9ff04243be00", + "manifests/fragment.pp": "366ccea2a72e680a029890940c278b9b", + "manifests/init.pp": "cb5521955a61dc31d83f80803724269f", + "metadata.json": "20590d54014797ec06448cdd58a8b470", + "provision.yaml": "f277ad496a0f3cac622041f2b8e767d6", + "readmes/README_ja_JP.md": "6cdafdb9ebc17ad8f4ddd08803fdcdb5", + "spec/acceptance/backup_spec.rb": "e02454efb1b50e8c6e6468eb0334fbf4", + "spec/acceptance/concat_spec.rb": "5d21ce75998196377a6d12564372da22", + "spec/acceptance/concurrency_spec.rb": "eb933badd90dbab7fe878fdcce658d81", + "spec/acceptance/force_spec.rb": "c938a20208f9167b2dd33f42fe3818ed", + "spec/acceptance/format_spec.rb": "00f4074b66fc7bafe7ff8a6ed2c42200", + "spec/acceptance/fragment_order_spec.rb": "fff55b113a981eb68d6d598ea2190257", + "spec/acceptance/fragment_replace_spec.rb": "caf3e9227365df59baad17cc10d3a2d7", + "spec/acceptance/fragment_source_spec.rb": "380353070da4ec5750504f0398d7b163", + "spec/acceptance/fragments_are_always_replaced_spec.rb": "f6697b94cbe8e676932d8e934e0741b9", + "spec/acceptance/newline_spec.rb": "7c3db81f9cd382eeacb98da367301bcd", "spec/acceptance/nodesets/centos-7-x64.yml": "a713f3abd3657f0ae2878829badd23cd", "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39", + "spec/acceptance/nodesets/debian-9-x64.yml": "adab00029a0b8d577eb6ab89503c25ca", "spec/acceptance/nodesets/default.yml": "a77662a1375bdf0dde4ed6bd798f2f45", "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae", "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df", "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58", - "spec/acceptance/order_spec.rb": "14e739dc02b4a4b48c5ed4d2c9bf1d17", - "spec/acceptance/pup-1963_spec.rb": "71e8a59d674f7a1dafeeba87438a0ca9", - "spec/acceptance/quoted_paths_spec.rb": "9cce52e33e894f10847b986f1d6e56d2", - "spec/acceptance/replace_spec.rb": "5807d3eb55c4503a99f37e81173774ef", - "spec/acceptance/specinfra_stubs.rb": "27839261403d8bbccf506552f9d8ef38", - "spec/acceptance/symbolic_name_spec.rb": "b40452adbfebb0ea9d56547d9daee700", - "spec/acceptance/validation_spec.rb": "e54226b10f46cfa9e89e57398eddbbd2", - "spec/acceptance/warn_header_spec.rb": "269e9329646674ec6975c34e0c58e8c1", - "spec/acceptance/warnings_spec.rb": "07ec0edb14f8d32fa0527c8232a73dfe", - "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07", - "spec/spec_helper_acceptance.rb": "7dc33118a3c8ebadf9bab062754de943", - "spec/unit/defines/concat_fragment_spec.rb": "517d7dd3f2e6d19528df065520d471e8", - "spec/unit/defines/concat_spec.rb": "2defcafce92ad271d8c764736a662c31", - "spec/unit/type/concat_file_spec.rb": "b9671fa2de84ca8b4137cd6aaba8e796" + "spec/acceptance/noop_spec.rb": "39fdfbd52898b3af9a0d6f1422313d3b", + "spec/acceptance/order_spec.rb": "e799c40b9ba1cebf2f81848d600a70fe", + "spec/acceptance/pup_1963_spec.rb": "9155b6cd0919ea62f9ad99cd9893a5b9", + "spec/acceptance/quoted_paths_spec.rb": "dd4708e4e78cc528b8da442a6d97fdab", + "spec/acceptance/specinfra_stubs.rb": "886a6978e8d36d2790c7041ff5df399f", + "spec/acceptance/symbolic_name_spec.rb": "c7d7dc9702df13895c5bee319112fb1e", + "spec/acceptance/validation_spec.rb": "0195705d1532889519d3a6418267cd15", + "spec/acceptance/warn_header_spec.rb": "ada8fdc56b26c81e4a1ff8e458210681", + "spec/acceptance/warnings_spec.rb": "f394e083b9c32803a321a2ec33ce19c3", + "spec/default_facts.yml": "d4442f09ee2f33f2d55f078d0ee2634f", + "spec/defines/concat_fragment_spec.rb": "9f5c0eced6518d617d9cd2911516b65d", + "spec/defines/concat_spec.rb": "80db64041f35b8c3bcb02ce94bc8fb61", + "spec/spec_helper.rb": "ec40d36ed109d8dba0df527c34c2c6db", + "spec/spec_helper_acceptance.rb": "9681de54bf44c9c507adc13d12bada2a", + "spec/spec_helper_acceptance_local.rb": "87be6f6a4f91c9d13b64964b0262f968", + "spec/spec_helper_local.rb": "1b62040c7efa09ba90245a881b545fe8", + "spec/unit/type/concat_file_spec.rb": "93d9a7d169882c19014aa8be92c98ba0", + "spec/unit/type/concat_fragment_spec.rb": "ec3f0a496a70ec7a5b55a2372cfbeb79" } \ No newline at end of file diff --git a/3rdparty/modules/concat/distelli-manifest.yml b/3rdparty/modules/concat/distelli-manifest.yml new file mode 100644 index 000000000..6e8cebc79 --- /dev/null +++ b/3rdparty/modules/concat/distelli-manifest.yml @@ -0,0 +1,25 @@ +team-modules/puppetlabs-concat: + PreBuild: + - source /opt/rh/rh-ruby25/enable + - echo "--- LETS update BUNDLER ---" + - bundle install --path vendor/bundle --jobs 3 + Build: + - echo "--- PROVISIONING ---" + - source /opt/rh/rh-ruby25/enable + - bundle exec rake litmus:provision_list[release_checks] + - cat inventory.yaml + - echo "--- AGENT INSTALLATION ---" + - bundle exec rake litmus:install_agent + - echo "--- MODULE INSTALLATION ---" + - bundle exec rake litmus:install_module + - echo "--- TESTS RUNNING ---" + - bundle exec rake litmus:acceptance:parallel + AfterBuildSuccess: + - source /opt/rh/rh-ruby25/enable + - bundle exec rake litmus:tear_down + AfterBuildFailure: + - source /opt/rh/rh-ruby25/enable + - bundle exec rake litmus:tear_down + CommitData: + - RepoType: Git + - RepoPath: . diff --git a/3rdparty/modules/concat/examples/format.pp b/3rdparty/modules/concat/examples/format.pp new file mode 100644 index 000000000..f91d2d61a --- /dev/null +++ b/3rdparty/modules/concat/examples/format.pp @@ -0,0 +1,13 @@ +concat { '/tmp/file': + format => 'yaml', # See REFERENCE.md for more formats +} + +concat::fragment { '1': + target => '/tmp/file', + content => '{"one": "foo"}', +} + +concat::fragment { '2': + target => '/tmp/file', + content => '{"two": "bar"}', +} \ No newline at end of file diff --git a/3rdparty/modules/concat/lib/puppet/type/concat_file.rb b/3rdparty/modules/concat/lib/puppet/type/concat_file.rb index 359c96341..6dd068ec1 100644 --- a/3rdparty/modules/concat/lib/puppet/type/concat_file.rb +++ b/3rdparty/modules/concat/lib/puppet/type/concat_file.rb @@ -4,14 +4,15 @@ require 'puppet/type/file/mode' require 'puppet/util/checksums' Puppet::Type.newtype(:concat_file) do - @doc = "Gets all the file fragments and puts these into the target file. - This will mostly be used with exported resources. + @doc = <<-DOC + @summary + Generates a file with content from fragments sharing a common unique tag. - example: + @example Concat_fragment <<| tag == 'unique_tag' |>> concat_file { '/tmp/file': - tag => 'unique_tag', # Mandatory + tag => 'unique_tag', # Optional. Default to undef path => '/tmp/file', # Optional. If given it overrides the resource name owner => 'root', # Optional. Default to undef group => 'root', # Optional. Default to undef @@ -19,9 +20,14 @@ Puppet::Type.newtype(:concat_file) do order => 'numeric' # Optional, Default to 'numeric' ensure_newline => false # Optional, Defaults to false } - " + DOC ensurable do + desc <<-DOC + Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and + negates the effect of any other parameters. + DOC + defaultvalues defaultto { :present } @@ -32,33 +38,46 @@ Puppet::Type.newtype(:concat_file) do end newparam(:tag) do - desc "Tag reference to collect all concat_fragment's with the same tag" + desc 'Required. Specifies a unique tag reference to collect all concat_fragments with the same tag.' end - newparam(:path, :namevar => true) do - desc "The output file" + newparam(:path, namevar: true) do + desc <<-DOC + Specifies a destination file for the combined fragments. Valid options: a string containing an absolute path. Default value: the + title of your declared resource. + DOC validate do |value| - unless (Puppet::Util.absolute_path?(value, :posix) or Puppet::Util.absolute_path?(value, :windows)) - raise ArgumentError, "File paths must be fully qualified, not '#{value}'" + unless Puppet::Util.absolute_path?(value, :posix) || Puppet::Util.absolute_path?(value, :windows) + raise ArgumentError, _("File paths must be fully qualified, not '%{_value}'") % { _value: value } end end end - newparam(:owner, :parent => Puppet::Type::File::Owner) do - desc "Desired file owner." + newparam(:owner, parent: Puppet::Type::File::Owner) do + desc <<-DOC + Specifies the owner of the destination file. Valid options: a string containing a username or integer containing a uid. + DOC end - newparam(:group, :parent => Puppet::Type::File::Group) do - desc "Desired file group." + newparam(:group, parent: Puppet::Type::File::Group) do + desc <<-DOC + Specifies a permissions group for the destination file. Valid options: a string containing a group name or integer containing a + gid. + DOC end - newparam(:mode, :parent => Puppet::Type::File::Mode) do - desc "Desired file mode." + newparam(:mode, parent: Puppet::Type::File::Mode) do + desc <<-DOC + Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. + DOC end newparam(:order) do - desc "Controls the ordering of fragments. Can be set to alpha or numeric." + desc <<-DOC + Specifies a method for sorting your fragments by name within the destination file. You can override this setting for individual + fragments by adjusting the order parameter in their concat::fragment declarations. + DOC newvalues(:alpha, :numeric) @@ -66,82 +85,215 @@ Puppet::Type.newtype(:concat_file) do end newparam(:backup) do - desc "Controls the filebucketing behavior of the final file and see File type reference for its use." - defaultto 'puppet' + desc <<-DOC + Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's native file + resource for execution. Valid options: true, false, or a string representing either a target filebucket or a filename extension + beginning with ".".' + DOC + + validate do |value| + unless [TrueClass, FalseClass, String].include?(value.class) + raise ArgumentError, _('Backup must be a Boolean or String') + end + end end - newparam(:replace, :boolean => true, :parent => Puppet::Parameter::Boolean) do - desc "Whether to replace a file that already exists on the local system." - defaultto :true + newparam(:replace, boolean: true, parent: Puppet::Parameter::Boolean) do + desc 'Specifies whether to overwrite the destination file if it already exists.' + defaultto true end newparam(:validate_cmd) do - desc "Validates file." + desc <<-DOC + Specifies a validation command to apply to the destination file. Requires Puppet version 3.5 or newer. Valid options: a string to + be passed to a file resource. + DOC + + validate do |value| + unless value.is_a?(String) + raise ArgumentError, _('Validate_cmd must be a String') + end + end + end + + newparam(:ensure_newline, boolean: true, parent: Puppet::Parameter::Boolean) do + desc "Specifies whether to add a line break at the end of each fragment that doesn't already end in one." + defaultto false + end + + newparam(:format) do + desc <<-DOC + Specify what data type to merge the fragments as. Valid options: 'plain', 'yaml', 'json', 'json-array', 'json-pretty', 'json-array-pretty'. + DOC + + newvalues(:plain, :yaml, :json, :'json-array', :'json-pretty', :'json-array-pretty') + + defaultto :plain end - newparam(:ensure_newline, :boolean => true, :parent => Puppet::Parameter::Boolean) do - desc "Whether to ensure there is a newline after each fragment." - defaultto :false + newparam(:force, boolean: true, parent: Puppet::Parameter::Boolean) do + desc 'Specifies whether to merge data structures, keeping the values with higher order.' + + defaultto false end - # Inherit File parameters - newparam(:selinux_ignore_defaults) do + newparam(:selinux_ignore_defaults, boolean: true, parent: Puppet::Parameter::Boolean) do + desc <<-DOC + See the file type's selinux_ignore_defaults documentention: + https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults. + DOC end newparam(:selrange) do + desc "See the file type's selrange documentation: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange" + validate do |value| + raise ArgumentError, _('Selrange must be a String') unless value.is_a?(String) + end end newparam(:selrole) do + desc "See the file type's selrole documentation: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole" + validate do |value| + raise ArgumentError, _('Selrole must be a String') unless value.is_a?(String) + end end newparam(:seltype) do + desc "See the file type's seltype documentation: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype" + validate do |value| + raise ArgumentError, _('Seltype must be a String') unless value.is_a?(String) + end end newparam(:seluser) do + desc "See the file type's seluser documentation: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser" + validate do |value| + raise ArgumentError, _('Seluser must be a String') unless value.is_a?(String) + end end - newparam(:show_diff) do + newparam(:show_diff, boolean: true, parent: Puppet::Parameter::Boolean) do + desc <<-DOC + Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure + reporting methods. + DOC end - # End file parameters # Autorequire the file we are generating below + # Why is this necessary ? autorequire(:file) do [self[:path]] end + def fragments + # Collect fragments that target this resource by path, title or tag. + @fragments ||= catalog.resources.map { |resource| + next unless resource.is_a?(Puppet::Type.type(:concat_fragment)) + + if resource[:target] == self[:path] || resource[:target] == title || + (resource[:tag] && resource[:tag] == self[:tag]) + resource + end + }.compact + end + + def decompound(d) + d.split('___', 2).map { |v| (v =~ %r{^\d+$}) ? v.to_i : v } + end + def should_content return @generated_content if @generated_content - @generated_content = "" + @generated_content = '' content_fragments = [] - resources = catalog.resources.select do |r| - r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag] - end - - resources.each do |r| + fragments.each do |r| content_fragments << ["#{r[:order]}___#{r[:name]}", fragment_content(r)] end - if self[:order] == :numeric - sorted = content_fragments.sort do |a, b| - def decompound(d) - d.split('___', 2).map { |v| v =~ /^\d+$/ ? v.to_i : v } + sorted = if self[:order] == :numeric + content_fragments.sort do |a, b| + decompound(a[0]) <=> decompound(b[0]) + end + else + content_fragments.sort_by do |a| + a_order, a_name = a[0].split('__', 2) + [a_order, a_name] + end + end + + case self[:format] + when :plain + @generated_content = sorted.map { |cf| cf[1] }.join + when :yaml + content_array = sorted.map do |cf| + YAML.safe_load(cf[1]) + end + content_hash = content_array.reduce({}) do |memo, current| + nested_merge(memo, current) + end + @generated_content = content_hash.to_yaml + when :json, :'json-array', :'json-pretty', :'json-array-pretty' + content_array = sorted.map do |cf| + JSON.parse(cf[1]) + end + + if [:json, :'json-pretty'].include?(self[:format]) + content_hash = content_array.reduce({}) do |memo, current| + nested_merge(memo, current) end - decompound(a[0]) <=> decompound(b[0]) - end - else - sorted = content_fragments.sort_by do |a| - a_order, a_name = a[0].split('__', 2) - [a_order, a_name] + @generated_content = + if self[:format] == :json + content_hash.to_json + else + JSON.pretty_generate(content_hash) + end + else + @generated_content = + if self[:format] == :'json-array' + content_array.to_json + else + JSON.pretty_generate(content_array) + end end end - @generated_content = sorted.map { |cf| cf[1] }.join - @generated_content end + def nested_merge(hash1, hash2) + # If a hash is empty, simply return the other + return hash1 if hash2.empty? + return hash2 if hash1.empty? + + # Unique merge for arrays + if hash1.is_a?(Array) && hash2.is_a?(Array) + return (hash1 + hash2).uniq + end + + # Deep-merge Hashes; higher order value is kept + hash1.merge(hash2) do |k, v1, v2| + if v1.is_a?(Hash) && v2.is_a?(Hash) + nested_merge(v1, v2) + elsif v1.is_a?(Array) && v2.is_a?(Array) + nested_merge(v1, v2) + else + # Fail if there are duplicate keys without force + unless v1 == v2 + unless self[:force] + err_message = [ + "Duplicate key '#{k}' found with values '#{v1}' and #{v2}'.", + "Use 'force' attribute to merge keys.", + ] + raise(_(err_message.join(' '))) + end + Puppet.debug("Key '#{k}': replacing '#{v2}' with '#{v1}'.") + end + v1 + end + end + end + def fragment_content(r) if r[:content].nil? == false fragment_content = r[:content] @@ -149,17 +301,18 @@ Puppet::Type.newtype(:concat_file) do @source = nil Array(r[:source]).each do |source| if Puppet::FileServing::Metadata.indirection.find(source) - @source = source + @source = source break end end - self.fail "Could not retrieve source(s) #{r[:source].join(", ")}" unless @source + raise _('Could not retrieve source(s) %{_array}') % { _array: Array(r[:source]).join(', ') } unless @source tmp = Puppet::FileServing::Content.indirection.find(@source) fragment_content = tmp.content unless tmp.nil? end if self[:ensure_newline] - fragment_content<<"\n" unless fragment_content =~ /\n$/ + newline = Puppet::Util::Platform.windows? ? "\r\n" : "\n" + fragment_content << newline unless fragment_content =~ %r{#{newline}$} end fragment_content @@ -167,7 +320,7 @@ Puppet::Type.newtype(:concat_file) do def generate file_opts = { - :ensure => self[:ensure] == :absent ? :absent : :file, + ensure: (self[:ensure] == :absent) ? :absent : :file, } [:path, @@ -183,18 +336,16 @@ Puppet::Type.newtype(:concat_file) do :seluser, :validate_cmd, :show_diff].each do |param| - unless self[param].nil? - file_opts[param] = self[param] - end + file_opts[param] = self[param] unless self[param].nil? end metaparams = Puppet::Type.metaparams - excluded_metaparams = [ :before, :notify, :require, :subscribe, :tag ] + excluded_metaparams = [:before, :notify, :require, :subscribe, :tag] metaparams.reject! { |param| excluded_metaparams.include? param } metaparams.each do |metaparam| - file_opts[metaparam] = self[metaparam] if self[metaparam] + file_opts[metaparam] = self[metaparam] unless self[metaparam].nil? end [Puppet::Type.type(:file).new(file_opts)] @@ -203,10 +354,10 @@ Puppet::Type.newtype(:concat_file) do def eval_generate content = should_content - if !content.nil? and !content.empty? + if !content.nil? && !content.empty? catalog.resource("File[#{self[:path]}]")[:content] = content end - [ catalog.resource("File[#{self[:path]}]") ] + [catalog.resource("File[#{self[:path]}]")] end end diff --git a/3rdparty/modules/concat/lib/puppet/type/concat_fragment.rb b/3rdparty/modules/concat/lib/puppet/type/concat_fragment.rb index 45f080194..c66a55769 100644 --- a/3rdparty/modules/concat/lib/puppet/type/concat_fragment.rb +++ b/3rdparty/modules/concat/lib/puppet/type/concat_fragment.rb @@ -1,64 +1,95 @@ Puppet::Type.newtype(:concat_fragment) do - @doc = "Create a concat fragment to be used by concat. - the `concat_fragment` type creates a file fragment to be collected by concat based on the tag. - The example is based on exported resources. - - Example: - @@concat_fragment { \"uniqe_name_${::fqdn}\": - tag => 'unique_name', - order => 10, # Optional. Default to 10 - content => 'some content' # OR - content => template('template.erb') # OR - source => 'puppet:///path/to/file' - } - " - - newparam(:name, :namevar => true) do - desc "Unique name" + @doc = <<-DOC + @summary + Manages the fragment. + + @example + # The example is based on exported resources. + + concat_fragment { \"uniqe_name_${::fqdn}\": + tag => 'unique_name', + order => 10, # Optional. Default to 10 + content => 'some content' # OR + # content => template('template.erb') + source => 'puppet:///path/to/file' + } + DOC + + newparam(:name, namevar: true) do + desc 'Name of resource.' end newparam(:target) do - desc "Target" + desc <<-DOC + Required. Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent + concat_file resource. + DOC + + validate do |value| + raise ArgumentError, _('Target must be a String') unless value.is_a?(String) + end end newparam(:content) do - desc "Content" + desc <<-DOC + Supplies the content of the fragment. Note: You must supply either a content parameter or a source parameter. Valid options: a string + DOC + + validate do |value| + raise ArgumentError, _('Content must be a String') unless value.is_a?(String) + end end newparam(:source) do - desc "Source" + desc <<-DOC + Specifies a file to read into the content of the fragment. Note: You must supply either a content parameter or a source parameter. + Valid options: a string or an array, containing one or more Puppet URLs. + DOC + + validate do |value| + raise ArgumentError, _('Content must be a String or Array') unless [String, Array].include?(value.class) + end end newparam(:order) do - desc "Order" + desc <<-DOC + Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. The string + option is recommended. + DOC + defaultto '10' validate do |val| - fail Puppet::ParseError, '$order is not a string or integer.' if !(val.is_a? String or val.is_a? Integer) - fail Puppet::ParseError, "Order cannot contain '/', ':', or '\n'." if val.to_s =~ /[:\n\/]/ + raise Puppet::ParseError, _('$order is not a string or integer.') unless val.is_a?(String) || val.is_a?(Integer) + raise Puppet::ParseError, _('Order cannot contain \'/\', \':\', or \'\\n\'.') if val.to_s =~ %r{[:\n\/]} end end newparam(:tag) do - desc "Tag name to be used by concat to collect all concat_fragments by tag name" + desc 'Specifies a unique tag to be used by concat_file to reference and collect content.' end autorequire(:file) do - if catalog.resources.select {|x| x.class == Puppet::Type.type(:concat_file) and (x[:path] == self[:target] || x.title == self[:target]) }.empty? - warning "Target Concat_file with path of #{self[:target]} not found in the catalog" + found = catalog.resources.select do |resource| + next unless resource.is_a?(Puppet::Type.type(:concat_file)) + + resource[:path] == self[:target] || resource.title == self[:target] || + (resource[:tag] && resource[:tag] == self[:tag]) + end + + if found.empty? + tag_message = (self[:tag]) ? "or tag '#{self[:tag]} " : '' + warning "Target Concat_file with path or title '#{self[:target]}' #{tag_message}not found in the catalog" end end validate do # Check if target is set - fail Puppet::ParseError, "Target not set" if self[:target].nil? - - # Check if tag is set - fail Puppet::ParseError, "Tag not set" if self[:tag].nil? + raise Puppet::ParseError, _("No 'target' or 'tag' set") unless self[:target] || self[:tag] # Check if either source or content is set. raise error if none is set - fail Puppet::ParseError, "Set either 'source' or 'content'" if self[:source].nil? && self[:content].nil? + raise Puppet::ParseError, _("Set either 'source' or 'content'") if self[:source].nil? && self[:content].nil? # Check if both are set, if so rais error - fail Puppet::ParseError, "Can't use 'source' and 'content' at the same time" if !self[:source].nil? && !self[:content].nil? + raise Puppet::ParseError, _("Can't use 'source' and 'content' at the same time") if !self[:source].nil? && !self[:content].nil? end end diff --git a/3rdparty/modules/concat/locales/config.yaml b/3rdparty/modules/concat/locales/config.yaml index e7f36d7e0..b97d80bdd 100644 --- a/3rdparty/modules/concat/locales/config.yaml +++ b/3rdparty/modules/concat/locales/config.yaml @@ -22,4 +22,5 @@ gettext: # Patterns for +Dir.glob+ used to find all files that might contain # translatable content, relative to the project root directory source_files: + - './lib/**/*.rb' diff --git a/3rdparty/modules/concat/locales/ja/puppetlabs-concat.po b/3rdparty/modules/concat/locales/ja/puppetlabs-concat.po new file mode 100644 index 000000000..72c69f576 --- /dev/null +++ b/3rdparty/modules/concat/locales/ja/puppetlabs-concat.po @@ -0,0 +1,110 @@ +# #-#-#-#-# puppetlabs-concat.pot (puppetlabs-concat 5.1.0-17-g0f37d63) #-#-#-#-# +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2018 Puppet, Inc. +# This file is distributed under the same license as the puppetlabs-concat package. +# FIRST AUTHOR , 2018. +# +# #-#-#-#-# puppetlabs-concat_metadata.pot (PACKAGE VERSION) #-#-#-#-# +# +# Translators: +# Kojima Ai , 2018 +# 下宮 祐子 , 2018 +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-30T14:59:51+00:00\n" +"PO-Revision-Date: 2018-12-15 00:41+0000\n" +"Last-Translator: 下宮 祐子 , 2018\n" +"Language-Team: Japanese (Japan) (https://www.transifex.com/puppet/teams/41915/ja_JP/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ja_JP\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Translate Toolkit 2.0.0\n" + +#. ./manifests/fragment.pp:27 +msgid "" +"%{_resource}['%{_title}']: 'order' cannot contain '/', ':', or '\n" +"'." +msgstr "" +"%{_resource}['%{_title}']: 'order'には、'/'、':'、'\n" +"'を含めることはできません。" + +#. ./manifests/fragment.pp:33 +msgid "" +"%{_resource}['%{_title}']: Can't use 'source' and 'content' at the same " +"time." +msgstr "%{_resource}['%{_title}']: 'source'と'content'は同時に使用できません。" + +#: ../lib/puppet/type/concat_file.rb:52 +msgid "File paths must be fully qualified, not '%{_value}'" +msgstr "ファイルパスは'%{_value}'ではなく、完全修飾でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:96 +msgid "Backup must be a Boolean or String" +msgstr "バックアップはブール値または文字列でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:114 +msgid "Validate_cmd must be a String" +msgstr "Validate_cmdは文字列でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:150 +msgid "Selrange must be a String" +msgstr "Selrangeは文字列でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:157 +msgid "Selrole must be a String" +msgstr "Selroleは文字列でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:164 +msgid "Seltype must be a String" +msgstr "Seltypeは文字列でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:171 +msgid "Seluser must be a String" +msgstr "Seluserは文字列でなければなりません" + +#: ../lib/puppet/type/concat_file.rb:306 +msgid "Could not retrieve source(s) %{_array}" +msgstr "ソース%{_array}を取得できませんでした" + +#: ../lib/puppet/type/concat_fragment.rb:29 +msgid "Target must be a String" +msgstr "ターゲットは文字列でなければなりません" + +#: ../lib/puppet/type/concat_fragment.rb:39 +msgid "Content must be a String" +msgstr "コンテンツは文字列でなければなりません" + +#: ../lib/puppet/type/concat_fragment.rb:50 +msgid "Content must be a String or Array" +msgstr "コンテンツは文字列または配列でなければなりません" + +#: ../lib/puppet/type/concat_fragment.rb:62 +msgid "$order is not a string or integer." +msgstr "$orderは文字列ではなく整数でもありません。" + +#: ../lib/puppet/type/concat_fragment.rb:63 +msgid "Order cannot contain '/', ':', or '\\n'." +msgstr "オーダには、'/'、':'、'\\n'を含めることはできません。" + +#: ../lib/puppet/type/concat_fragment.rb:87 +msgid "No 'target' or 'tag' set" +msgstr "'target'または'tag'が設定されていません" + +#: ../lib/puppet/type/concat_fragment.rb:90 +msgid "Set either 'source' or 'content'" +msgstr "'source'または'content'を設定してください" + +#: ../lib/puppet/type/concat_fragment.rb:93 +msgid "Can't use 'source' and 'content' at the same time" +msgstr "'source'と'content'は同時に使用できません" + +#. metadata.json +#: .summary +msgid "Construct files from multiple fragments." +msgstr "複数のフラグメントからファイルを構築します。" diff --git a/3rdparty/modules/concat/locales/puppetlabs-concat.pot b/3rdparty/modules/concat/locales/puppetlabs-concat.pot new file mode 100644 index 000000000..bd64e49ed --- /dev/null +++ b/3rdparty/modules/concat/locales/puppetlabs-concat.pot @@ -0,0 +1,127 @@ +# #-#-#-#-# puppetlabs-concat.pot (puppetlabs-concat 5.1.0-17-g0f37d63) #-#-#-#-# +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2018 Puppet, Inc. +# This file is distributed under the same license as the puppetlabs-concat package. +# FIRST AUTHOR , 2018. +# +# #-#-#-#-# puppetlabs-concat_metadata.pot (PACKAGE VERSION) #-#-#-#-# +# +#, fuzzy +msgid "" +msgstr "" +"#-#-#-#-# puppet.pot (PACKAGE VERSION) #-#-#-#-#\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-30 15:33:30 +0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Translate Toolkit 2.0.0\n" +"#-#-#-#-# puppetlabs-concat.pot (puppetlabs-concat 5.1.0-17-g0f37d63) #-#-" +"#-#-#\n" +"Project-Id-Version: puppetlabs-concat 5.1.0-17-g0f37d63\n" +"\n" +"Report-Msgid-Bugs-To: docs@puppet.com\n" +"POT-Creation-Date: 2018-11-30 15:33+0000\n" +"PO-Revision-Date: 2018-11-30 15:33+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"#-#-#-#-# puppetlabs-concat_metadata.pot (PACKAGE VERSION) #-#-#-#-#\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To:\n" +"POT-Creation-Date: 2018-11-30T14:59:51+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Translate Toolkit 2.0.0\n" + +#. ./manifests/fragment.pp:27 +msgid "" +"%{_resource}['%{_title}']: 'order' cannot contain '/', ':', or '\n" +"'." +msgstr "" + +#. ./manifests/fragment.pp:33 +msgid "" +"%{_resource}['%{_title}']: Can't use 'source' and 'content' at the same time." +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:52 +msgid "File paths must be fully qualified, not '%{_value}'" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:96 +msgid "Backup must be a Boolean or String" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:114 +msgid "Validate_cmd must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:150 +msgid "Selrange must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:157 +msgid "Selrole must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:164 +msgid "Seltype must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:171 +msgid "Seluser must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_file.rb:306 +msgid "Could not retrieve source(s) %{_array}" +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:29 +msgid "Target must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:39 +msgid "Content must be a String" +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:50 +msgid "Content must be a String or Array" +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:62 +msgid "$order is not a string or integer." +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:63 +msgid "Order cannot contain '/', ':', or '\\n'." +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:87 +msgid "No 'target' or 'tag' set" +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:90 +msgid "Set either 'source' or 'content'" +msgstr "" + +#: ../lib/puppet/type/concat_fragment.rb:93 +msgid "Can't use 'source' and 'content' at the same time" +msgstr "" + +#. metadata.json +#: .summary +msgid "Construct files from multiple fragments." +msgstr "" diff --git a/3rdparty/modules/concat/manifests/fragment.pp b/3rdparty/modules/concat/manifests/fragment.pp index e30732ca8..8d9a0a00c 100644 --- a/3rdparty/modules/concat/manifests/fragment.pp +++ b/3rdparty/modules/concat/manifests/fragment.pp @@ -1,11 +1,19 @@ -# Creates a concat_fragment in the catalogue +# @summary +# Manages a fragment of text to be compiled into a file. +# +# @param content +# Supplies the content of the fragment. Note: You must supply either a content parameter or a source parameter. # -# @param target The file that these fragments belong to -# @param content If present puts the content into the file -# @param source If content was not specified, use the source # @param order -# By default all files gets a 10_ prefix in the directory you can set it to -# anything else using this to influence the order of the content in the file +# Reorders your fragments within the destination file. Fragments that share the same order number are ordered by name. The string +# option is recommended. +# +# @param source +# Specifies a file to read into the content of the fragment. Note: You must supply either a content parameter or a source parameter. +# Valid options: a string or an array, containing one or more Puppet URLs. +# +# @param target +# Specifies the destination file of the fragment. Valid options: a string containing the path or title of the parent concat resource. # define concat::fragment( String $target, @@ -15,17 +23,17 @@ define concat::fragment( ) { $resource = 'Concat::Fragment' - if (is_string($order) and $order =~ /[:\n\/]/) { - fail("${resource}['${title}']: 'order' cannot contain '/', ':', or '\n'.") + if ($order =~ String and $order =~ /[:\n\/]/) { + fail(translate("%{_resource}['%{_title}']: 'order' cannot contain '/', ':', or '\\n'.", {'_resource' => $resource, '_title' => $title})) } if ! ($content or $source) { crit('No content, source or symlink specified') } elsif ($content and $source) { - fail("${resource}['${title}']: Can't use 'source' and 'content' at the same time.") + fail(translate("%{_resource}['%{_title}']: Can't use 'source' and 'content' at the same time.", {'_resource' => $resource, '_title' => $title})) } - $safe_target_name = regsubst($target, '[/:~\n\s\+\*\(\)@]', '_', 'GM') + $safe_target_name = regsubst($target, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'GM') concat_fragment { $name: target => $target, diff --git a/3rdparty/modules/concat/manifests/init.pp b/3rdparty/modules/concat/manifests/init.pp index 0a19b344f..5e46d2516 100644 --- a/3rdparty/modules/concat/manifests/init.pp +++ b/3rdparty/modules/concat/manifests/init.pp @@ -1,46 +1,83 @@ -# Sets up so that you can use fragments to build a final config file, +# @summary +# Manages a file, compiled from one or more text fragments. +# +# @example +# concat { '/tmp/concat': +# ensure => present, +# owner => 'root', +# group => 'root', +# mode => '0644', +# } +# +# @param backup +# Specifies whether (and how) to back up the destination file before overwriting it. Your value gets passed on to Puppet's native file +# resource for execution. Valid options: true, false, or a string representing either a target filebucket or a filename extension +# beginning with ".". # # @param ensure -# Present/Absent -# @param path -# The path to the final file. Use this in case you want to differentiate -# between the name of a resource and the file path. Note: Use the name you -# provided in the target of your fragments. -# @param owner -# Who will own the file +# Specifies whether the destination file should exist. Setting to 'absent' tells Puppet to delete the destination file if it exists, and +# negates the effect of any other parameters. +# +# @param ensure_newline +# Specifies whether to add a line break at the end of each fragment that doesn't already end in one. +# +# @param format +# Specify what data type to merge the fragments as. Valid options: 'plain', 'yaml', 'json', 'json-array', 'json-pretty', +# 'json-array-pretty'. +# +# @param force +# Specifies whether to merge data structures, keeping the values with higher order. Used when format is specified as a value other than +# 'plain'. +# # @param group -# Who will own the file +# Specifies a permissions group for the destination file. Valid options: a string containing a group name or integer containing a gid. +# # @param mode -# The mode of the final file -# @param show_diff -# Use metaparam for files to show/hide diffs for reporting when using eyaml -# secrets. Defaults to true -# @param warn -# Adds a normal shell style comment top of the file indicating that it is -# built by puppet. -# Before 2.0.0, this parameter would add a newline at the end of the warn -# message. To improve flexibilty, this was removed. Please add it explicitely -# if you need it. -# @param backup -# Controls the filebucketing behavior of the final file and see File type -# reference for its use. Defaults to 'puppet' -# @param replace -# Whether to replace a file that already exists on the local system +# Specifies the permissions mode of the destination file. Valid options: a string containing a permission mode value in octal notation. +# # @param order -# Select whether to order associated fragments by 'alpha' or 'numeric'. -# Defaults to 'alpha'. -# @param ensure_newline -# Specifies whether to ensure there's a new line at the end of each fragment. -# Valid options: 'true' and 'false'. Default value: 'false'. +# Specifies a method for sorting your fragments by name within the destination file. You can override this setting for individual +# fragments by adjusting the order parameter in their concat::fragment declarations. +# +# @param owner +# Specifies the owner of the destination file. Valid options: a string containing a username or integer containing a uid. +# +# @param path +# Specifies a destination file for the combined fragments. +# +# @param replace +# Specifies whether to overwrite the destination file if it already exists. +# # @param selinux_ignore_defaults +# See the file type's selinux_ignore_defaults documentention: +# https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selinux_ignore_defaults +# # @param selrange +# See the file type's selrange documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrange +# # @param selrole +# See the file type's selrole documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-selrole +# # @param seltype +# See the file type's seltype documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seltype +# # @param seluser +# See the file type's seluser documentention: https://docs.puppetlabs.com/references/latest/type.html#file-attribute-seluser +# +# @param show_diff +# Specifies whether to set the show_diff parameter for the file resource. Useful for hiding secrets stored in hiera from insecure +# reporting methods. +# # @param validate_cmd # Specifies a validation command to apply to the destination file. -# Requires Puppet version 3.5 or newer. Valid options: a string to be passed -# to a file resource. Default value: undefined. +# +# @param warn +# Specifies whether to add a header message at the top of the destination file. Valid options: the booleans true and false, or a string +# to serve as the header. +# If you set 'warn' to true, concat adds the following line with an order of 0: +# `# This file is managed by Puppet. DO NOT EDIT.` +# Before 2.0.0, this parameter would add a newline at the end of the warn message. To improve flexibilty, this was removed. Please add +# it explicitly if you need it. # define concat( Enum['present', 'absent'] $ensure = 'present', @@ -60,9 +97,11 @@ define concat( Optional[String] $selrole = undef, Optional[String] $seltype = undef, Optional[String] $seluser = undef, + Optional[String] $format = 'plain', + Optional[Boolean] $force = false, ) { - $safe_name = regsubst($name, '[/:~\n\s\+\*\(\)@]', '_', 'G') + $safe_name = regsubst($name, '[\\\\/:~\n\s\+\*\(\)@]', '_', 'G') $default_warn_message = "# This file is managed by Puppet. DO NOT EDIT.\n" case $warn { @@ -98,6 +137,8 @@ define concat( order => $order, ensure_newline => $ensure_newline, validate_cmd => $validate_cmd, + format => $format, + force => $force, } if $_append_header { diff --git a/3rdparty/modules/concat/metadata.json b/3rdparty/modules/concat/metadata.json index a143f2b98..dfadb9a77 100644 --- a/3rdparty/modules/concat/metadata.json +++ b/3rdparty/modules/concat/metadata.json @@ -1,14 +1,21 @@ { "name": "puppetlabs-concat", - "version": "4.0.1", - "author": "Puppet Labs", + "version": "6.1.0", + "author": "puppetlabs", "summary": "Construct files from multiple fragments.", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-concat", "project_page": "https://github.com/puppetlabs/puppetlabs-concat", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.13.1 < 5.0.0"} + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.13.1 < 7.0.0" + }, + { + "name": "puppetlabs/translate", + "version_requirement": ">= 1.0.0 < 3.0.0" + } ], "data_provider": null, "operatingsystem_support": [ @@ -17,7 +24,8 @@ "operatingsystemrelease": [ "5", "6", - "7" + "7", + "8" ] }, { @@ -39,7 +47,6 @@ { "operatingsystem": "Scientific", "operatingsystemrelease": [ - "5", "6", "7" ] @@ -47,26 +54,24 @@ { "operatingsystem": "SLES", "operatingsystemrelease": [ - "10 SP4", "11 SP1", - "12" + "12", + "15" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ - "6", - "7", - "8" + "8", + "9" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "10.04", - "12.04", "14.04", - "16.04" + "16.04", + "18.04" ] }, { @@ -79,10 +84,14 @@ { "operatingsystem": "Windows", "operatingsystemrelease": [ - "Server 2003 R2", - "Server 2008 R2", - "Server 2012", - "Server 2012 R2" + "2008 R2", + "2012", + "2012 R2", + "2016", + "2012 R2 Core", + "7", + "8.1", + "10" ] }, { @@ -92,18 +101,15 @@ "6.1", "7.1" ] - }, - { - "operatingsystem": "OSX", - "operatingsystemrelease": [ - "10.9" - ] } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.7.0 < 5.0.0" + "version_requirement": ">= 5.5.10 < 7.0.0" } - ] + ], + "template-url": "https://github.com/puppetlabs/pdk-templates/#master", + "template-ref": "heads/master-0-gb096033", + "pdk-version": "1.11.1" } diff --git a/3rdparty/modules/concat/provision.yaml b/3rdparty/modules/concat/provision.yaml new file mode 100644 index 000000000..5b6a76c91 --- /dev/null +++ b/3rdparty/modules/concat/provision.yaml @@ -0,0 +1,19 @@ +--- +default: + provisioner: docker + images: ['waffleimage/centos7'] +travis_deb: + provisioner: docker + images: ['debian:8', 'debian:9', 'ubuntu:14.04', 'ubuntu:16.04', 'ubuntu:18.04'] +waffle_deb: + provisioner: docker + images: ['waffleimage/debian8', 'waffleimage/debian9', 'waffleimage/ubuntu14.04', 'waffleimage/ubuntu16.04', 'waffleimage/ubuntu18.04'] +travis_el: + provisioner: docker + images: ['centos:6', 'centos:7', 'oraclelinux:6', 'oraclelinux:7', 'scientificlinux/sl:6', 'scientificlinux/sl:7'] +waffle_el: + provisioner: docker + images: ['waffleimage/centos6', 'waffleimage/centos7', 'waffleimage/oraclelinux6', 'waffleimage/oraclelinux7', 'waffleimage/scientificlinux6', 'waffleimage/scientificlinux7'] +release_checks: + provisioner: vmpooler + images: ['redhat-5-x86_64', 'redhat-6-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'centos-5-x86_64', 'centos-6-x86_64', 'centos-7-x86_64', 'oracle-5-x86_64', 'oracle-6-x86_64', 'oracle-7-x86_64', 'scientific-6-x86_64', 'scientific-7-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'sles-11-x86_64', 'sles-12-x86_64', 'sles-15-x86_64', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'win-2008r2-x86_64', 'win-2012r2-x86_64', 'win-2016-x86_64', 'win-10-pro-x86_64'] diff --git a/3rdparty/modules/concat/readmes/README_ja_JP.md b/3rdparty/modules/concat/readmes/README_ja_JP.md new file mode 100644 index 000000000..b1924f866 --- /dev/null +++ b/3rdparty/modules/concat/readmes/README_ja_JP.md @@ -0,0 +1,160 @@ +# concat + +#### 目次 + +1. [概要](#overview) +2. [説明 - モジュールの機能とその有益性](#module-description) + * [concatを開始する](#beginning-with-concat) +4. [使用方法 - 設定オプションと追加機能](#usage) +5. [参考 - モジュールの機能と動作について](#reference) + * [削除した機能](#removed-functionality) +6. [制約事項 - OSの互換性など](#limitations) +7. [開発 - モジュール貢献についてのガイド](#development) + + +## 概要 + +concatモジュールでは、複数の順序付きテキストフラグメントからファイルを構築できます。 + + +## モジュールの概要 + +concatモジュールでは、他のモジュールから`concat::fragment`リソースを収集し、それを単一の`concat` リソースを通じて整合性のあるファイルに並べることができます。 + + +### concatを開始する + +concatを開始するには、以下の作成が必要です。 + +* 最終ファイルのconcat{}リソース。 +* 1つ以上のconcat::fragment{}。 + +最小限の例: + +~~~ +concat { '/tmp/file': + ensure => present, +} + +concat::fragment { 'tmpfile': + target => '/tmp/file', + content => 'test contents', + order => '01' +} +~~~ + + +## 使用方法 + +### ノードの主要モジュールのリストを維持します + +いずれかのノードのモジュールをリストするmotdファイルを維持するには、まずファイルをフレームするクラスを作成します。 + +~~~ +class motd { + $motd = '/etc/motd' + + concat { $motd: + owner => 'root', + group => 'root', + mode => '0644' + } + + concat::fragment{ 'motd_header': + target => $motd, + content => "\nPuppet modules on this server:\n\n", + order => '01' + } + + # let local users add to the motd by creating a file called + # /etc/motd.local + concat::fragment{ 'motd_local': + target => $motd, + source => '/etc/motd.local', + order => '15' + } +} + +# let other modules register themselves in the motd +define motd::register($content="", $order='10') { + if $content == "" { + $body = $name + } else { + $body = $content + } + + concat::fragment{ "motd_fragment_$name": + target => '/etc/motd', + order => $order, + content => " -- $body\n" + } +} +~~~ + +次に、ノードの各モジュールの宣言に`motd::register{ 'Apache': }`を追加し、motdのモジュールを登録します。 + +~~~ +class apache { + include apache::install, apache::config, apache::service + + motd::register{ 'Apache': } +} +~~~ + +これらの2つのステップは、インストールされ、登録されたモジュールのリストを/etc/motdファイルに追加します。このファイルは、登録済みモジュールの`include`行を削除しただけであっても最新の状態を保ちます。システム管理者は、/etc/motd.localに書き込むことでリストにテキストを追加できます。 + +完成したmotdファイルは、以下のようになります。 + +~~~ + Puppet modules on this server: + + -- Apache + -- MySQL + + +~~~ + + +## リファレンス + +[REFERENCE.md](https://github.com/puppetlabs/puppetlabs-concat/blob/master/REFERENCE.md)を参照してください。 + + +### 削除した機能 + +次の機能は、concatモジュールの過去のバージョンには存在していましたが、バージョン2.0.0では削除されています。 + +`concat::fragment`から削除されたパラメータ: +* `gnu` +* `backup` +* `group` +* `mode` +* `owner` + +`concat::setup`クラスも削除されました。 + +バージョン2.0.0以前のconcatでは、`warn`パラメータを`true`、`false`、'yes'、'no'、'on'、または'off'の文字列値に設定すると、モジュールは文字列を対応するブール値に変換していました。concatバージョン2.0.0以降では、`warn_header`パラメータはこれらの値を他の文字列と同じように扱い、ヘッダメッセージの内容として使用します。これを回避するには、`true`および`false`値を文字列ではなくブール値として渡します。 + + +## 制約事項 + +このモジュールは[PE対応のすべてのプラットフォーム](https://forge.puppetlabs.com/supported#compat-matrix)上でテスト済みであり、問題は発見されていません。 + +サポートされているオペレーティングシステムの一覧については、[metadata.json](https://github.com/puppetlabs/puppetlabs-concat/blob/master/metadata.json)を参照してください。 + + +## 開発 + +Puppet Forge上のPuppetモジュールはオープンプロジェクトであり、その価値を維持するにはコミュニティからの貢献が欠かせません。Puppetが提供する膨大な数のプラットフォームや、無数のハードウェア、ソフトウェア、デプロイ設定に弊社がアクセスすることは不可能です。 + +弊社は、できるだけ変更に貢献しやすくして、弊社のモジュールがユーザの環境で機能する状態を維持したいと考えています。弊社では、状況を把握できるよう、貢献者に従っていただくべきいくつかのガイドラインを設けています。 + +詳細については、[モジュール貢献ガイド](https://docs.puppetlabs.com/forge/contributing.html)を参照してください。 + +### コントリビュータ + +Richard Pijnenburg ([@Richardp82](http://twitter.com/richardp82)) + +Joshua Hoblitt ([@jhoblitt](http://twitter.com/jhoblitt)) + +[その他のコントリビュータ](https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors) diff --git a/3rdparty/modules/concat/spec/acceptance/backup_spec.rb b/3rdparty/modules/concat/spec/acceptance/backup_spec.rb index 0a737a556..80a987940 100644 --- a/3rdparty/modules/concat/spec/acceptance/backup_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/backup_spec.rb @@ -1,115 +1,77 @@ require 'spec_helper_acceptance' describe 'concat backup parameter' do - basedir = default.tmpdir('concat') - context '=> puppet' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, + before(:all) do + @basedir = setup_test_directory + end + + describe 'when puppet' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + backup => 'puppet', } - file { '#{basedir}/file': - content => "old contents\n", + concat::fragment { 'new file': + target => '#{@basedir}/file', + content => 'new contents', } - EOS - apply_manifest(pp) + MANIFEST end - pp = <<-EOS - concat { '#{basedir}/file': - backup => 'puppet', - } - concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', - } - EOS it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/Filebucketed #{basedir}\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) - end - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } + expect(apply_manifest(pp, catch_failures: true, debug: true).stdout).to match(%r{Filebucketed.*to puppet with sum.*}) + apply_manifest(pp, catch_changes: true) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{new contents} end end - context '=> .backup' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': + describe 'when .backup' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': backup => '.backup', } concat::fragment { 'new file': - target => '#{basedir}/file', - content => 'new contents', + target => '#{@basedir}/file', + content => 'backup extension', } - EOS + MANIFEST + end # XXX Puppet doesn't mention anything about filebucketing with a given # extension like .backup - it 'applies the manifest twice no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } - end - describe file("#{basedir}/file.backup") do - it { should be_file } - its(:content) { should match /old contents/ } + it 'applies the manifest twice no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{backup extension} + expect(file("#{@basedir}/file.backup")).to be_file + expect(file("#{@basedir}/file.backup").content).to match %r{new contents} end end # XXX The backup parameter uses validate_string() and thus can't be the # boolean false value, but the string 'false' has the same effect in Puppet 3 - context "=> 'false'" do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "old contents\n", - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': + describe "when 'false'" do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': backup => '.backup', } concat::fragment { 'new file': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => 'new contents', } - EOS + MANIFEST + end it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to_not match(/Filebucketed/) + apply_manifest(pp, catch_failures: true) do |r| + expect(r.stdout).not_to match(%r{Filebucketed}) end - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match /new contents/ } + apply_manifest(pp, catch_changes: true) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{new contents} end end end diff --git a/3rdparty/modules/concat/spec/acceptance/concat_spec.rb b/3rdparty/modules/concat/spec/acceptance/concat_spec.rb index 3e24a583c..6de9766ec 100644 --- a/3rdparty/modules/concat/spec/acceptance/concat_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/concat_spec.rb @@ -1,116 +1,65 @@ require 'spec_helper_acceptance' -case fact('osfamily') - when 'AIX' - username = 'root' - groupname = 'system' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end - when 'Darwin' - username = 'root' - groupname = 'wheel' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end - when 'windows' - username = 'Administrator' - groupname = 'Administrators' - scriptname = 'concatfragments.rb' - result = on default, "echo #{default.puppet['vardir']}" - vardir = result.raw_output.chomp - when 'Solaris' - username = 'root' - groupname = 'root' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end - else - username = 'root' - groupname = 'root' - scriptname = 'concatfragments.rb' - vardir = default.puppet['vardir'] - if vardir.nil? or vardir == '' - vardir = '/opt/puppetlabs/puppet/cache' - end +case os[:family] +when 'aix' + username = 'root' + groupname = 'system' +when 'darwin' + username = 'root' + groupname = 'wheel' +when 'windows' + username = 'Administrator' + groupname = 'Administrators' +else + username = 'root' + groupname = 'root' end describe 'basic concat test' do - basedir = default.tmpdir('concat') - safe_basedir = basedir.gsub(/[\/:]/, '_') - - shared_examples 'successfully_applied' do |pp| - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end + before(:all) do + @basedir = setup_test_directory end - context 'owner/group root' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, + describe 'with owner/group root' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + owner => '#{username}', + group => '#{groupname}', + mode => '0644', } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - order => '01', - } - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - order => '02', - } - EOS + concat::fragment { '1': + target => '#{@basedir}/file', + content => '1', + order => '01', + } - it_behaves_like 'successfully_applied', pp + concat::fragment { '2': + target => '#{@basedir}/file', + content => '2', + order => '02', + } + MANIFEST + end - describe file("#{basedir}/file") do - it { should be_file } - it { should be_owned_by username } - it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname } - it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { - should be_mode 644 - } - its(:content) { - should match '1' - should match '2' - } + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file")).to be_owned_by username unless os[:family] == 'windows' + expect(file("#{@basedir}/file")).to be_grouped_into groupname unless os[:family] == 'windows' || os[:family] == 'darwin' + expect(file("#{@basedir}/file")).to be_mode 644 unless os[:family] == 'aix' || os[:family] == 'windows' + expect(file("#{@basedir}/file").content).to match '1' + expect(file("#{@basedir}/file").content).to match '2' end end - context 'ensure' do - context 'works when set to present with path set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" + describe 'when present with path set' do + let(:pp) do + <<-MANIFEST concat { 'file': ensure => present, - path => '#{basedir}/file', + path => '#{@basedir}/file', mode => '0644', } concat::fragment { '1': @@ -118,31 +67,23 @@ describe 'basic concat test' do content => '1', order => '01', } - " - - it_behaves_like 'successfully_applied', pp + MANIFEST + end - describe file("#{basedir}/file") do - it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { - should be_mode 644 - } - its(:content) { should match '1' } - end + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file")).to be_mode 644 unless os[:family] == 'aix' || os[:family] == 'windows' + expect(file("#{@basedir}/file").content).to match '1' end - context 'works when set to absent with path set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" + end + + describe 'when absent with path set' do + let(:pp) do + <<-MANIFEST concat { 'file': ensure => absent, - path => '#{basedir}/file', + path => '#{@basedir}/file', mode => '0644', } concat::fragment { '1': @@ -150,32 +91,23 @@ describe 'basic concat test' do content => '1', order => '01', } - " - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end + MANIFEST + end - describe file("#{basedir}/file") do - it { should_not be_file } - end + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).not_to be_file end - context 'works when set to present with path that has special characters' do - filename = fact('osfamily') == 'windows' ? 'file(1)' : 'file(1:2)' + end - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" + describe 'when present with path that has special characters' do + filename = (os[:family] == 'windows') ? 'file(1)' : 'file(1:2)' + + let(:pp) do + <<-MANIFEST concat { '#{filename}': ensure => present, - path => '#{basedir}/#{filename}', + path => '#{@basedir}/#{filename}', mode => '0644', } concat::fragment { '1': @@ -183,31 +115,23 @@ describe 'basic concat test' do content => '1', order => '01', } - " - - it_behaves_like 'successfully_applied', pp + MANIFEST + end - describe file("#{basedir}/#{filename}") do - it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { - should be_mode 644 - } - its(:content) { should match '1' } - end + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/#{filename}")).to be_file + expect(file("#{@basedir}/#{filename}")).to be_mode 644 unless os[:family] == 'aix' || os[:family] == 'windows' + expect(file("#{@basedir}/#{filename}").content).to match '1' end - context 'noop properly' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp=" + end + + describe 'with noop properly' do + let(:pp) do + <<-MANIFEST concat { 'file': ensure => present, - path => '#{basedir}/file', + path => '#{@basedir}/file', mode => '0644', noop => true, } @@ -216,13 +140,12 @@ describe 'basic concat test' do content => '1', order => '01', } - " - - it_behaves_like 'successfully_applied', pp + MANIFEST + end - describe file("#{basedir}/file") do - it { should_not be_file } - end + it 'applies manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).not_to be_file end end end diff --git a/3rdparty/modules/concat/spec/acceptance/concurrency_spec.rb b/3rdparty/modules/concat/spec/acceptance/concurrency_spec.rb index fcffdbd10..49d39e42c 100644 --- a/3rdparty/modules/concat/spec/acceptance/concurrency_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/concurrency_spec.rb @@ -1,37 +1,35 @@ require 'spec_helper_acceptance' -describe 'with file recursive purge' do - basedir = default.tmpdir('concat') - context 'should still create concat file' do - pp = <<-EOS - file { '#{basedir}/bar': - ensure => directory, - purge => true, - recurse => true, - } +describe 'concurrency, with file recursive purge' do + before(:all) do + @basedir = setup_test_directory + end - concat { "foobar": - ensure => 'present', - path => '#{basedir}/bar/foobar', - } + describe 'when run should still create concat file' do + let(:pp) do + <<-MANIFEST + file { '#{@basedir}/bar': + ensure => directory, + purge => true, + recurse => true, + } - concat::fragment { 'foo': - target => 'foobar', - content => 'foo', - } - EOS + concat { "foobar": + ensure => 'present', + path => '#{@basedir}/bar/foobar', + } - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + concat::fragment { 'foo': + target => 'foobar', + content => 'foo', + } + MANIFEST end - describe file("#{basedir}/bar/foobar") do - it { should be_file } - its(:content) { - should match 'foo' - } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/bar/foobar")).to be_file + expect(file("#{@basedir}/bar/foobar").content).to match 'foo' end end end - diff --git a/3rdparty/modules/concat/spec/acceptance/force_spec.rb b/3rdparty/modules/concat/spec/acceptance/force_spec.rb new file mode 100644 index 000000000..2aa92eded --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/force_spec.rb @@ -0,0 +1,147 @@ +require 'spec_helper_acceptance' + +describe 'force merge of file' do + before(:all) do + @basedir = setup_test_directory + end + + describe 'when run should not force' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'yaml', + force => false, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": "bar"}', + } + MANIFEST + end + + it 'applies manifest twice with stderr check' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match("Duplicate key 'one' found with values 'foo' and bar'. Use 'force' attribute to merge keys.") + expect(apply_manifest(pp, expect_failures: true).stderr).to match("Duplicate key 'one' found with values 'foo' and bar'. Use 'force' attribute to merge keys.") + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match 'file exists' + expect(file("#{@basedir}/file").content).not_to match 'one: foo' + expect(file("#{@basedir}/file").content).not_to match 'one: bar' + end + end + + describe 'when run should not force by default' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'yaml', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": "bar"}', + } + MANIFEST + end + + it 'applies manifest twice with stderr check' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match("Duplicate key 'one' found with values 'foo' and bar'. Use 'force' attribute to merge keys.") + expect(apply_manifest(pp, expect_failures: true).stderr).to match("Duplicate key 'one' found with values 'foo' and bar'. Use 'force' attribute to merge keys.") + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match 'file exists' + expect(file("#{@basedir}/file").content).not_to match 'one: foo' + expect(file("#{@basedir}/file").content).not_to match 'one: bar' + end + end + + describe 'when run should force' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'yaml', + force => true, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": "bar"}', + } + MANIFEST + end + + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match 'one: foo' + end + end + + describe 'when run should force merge nested arrays' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'json', + force => true, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": [1]}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": [2]}', + } + MANIFEST + end + + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to contain '{"one":\[1,2\]}' + end + end + + describe 'when run should not force on plain' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + force => true, + format => plain, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": "bar"}', + } + MANIFEST + end + + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '{"one": "foo"}{"one": "bar"}' + end + end +end diff --git a/3rdparty/modules/concat/spec/acceptance/format_spec.rb b/3rdparty/modules/concat/spec/acceptance/format_spec.rb new file mode 100644 index 000000000..7bd1994a3 --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/format_spec.rb @@ -0,0 +1,214 @@ +require 'spec_helper_acceptance' + +describe 'format of file' do + before(:all) do + @basedir = setup_test_directory + end + + describe 'when run should default to plain' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '{"one": "foo"}{"one": "bar"}' + end + end + + describe 'when run should output to plain format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => plain, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"one": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '{"one": "foo"}{"one": "bar"}' + end + end + + describe 'when run should output to yaml format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'yaml', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"two": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match 'one: foo\Rtwo: bar' + end + end + + describe 'when run should output yaml arrays to yaml format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'yaml', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => to_yaml([{ 'one.a' => 'foo', 'one.b' => 'bar' }]), + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => to_yaml([{ 'two.a' => 'dip', 'two.b' => 'doot' }]), + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '- one.a: foo\R one.b: bar\R- two.a: dip\R two.b: doot' + end + end + + describe 'when run should output to json format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'json', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"two": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '{"one":"foo","two":"bar"}' + end + end + + describe 'when run should output to json-array format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'json-array', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"two": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '[{"one":"foo"},{"two":"bar"}]' + end + end + + describe 'when run should output to json-pretty format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'json-pretty', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"two": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '{\R "one": "foo",\R "two": "bar"\R}' + end + end + + describe 'when run should output to json-array-pretty format' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + format => 'json-array-pretty', + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '{"one": "foo"}', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '{"two": "bar"}', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '[\n {\n "one": "foo"\n },\n {\n "two": "bar"\n }\n]' + end + end +end diff --git a/3rdparty/modules/concat/spec/acceptance/fragment_order_spec.rb b/3rdparty/modules/concat/spec/acceptance/fragment_order_spec.rb new file mode 100644 index 000000000..2e2e39a94 --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/fragment_order_spec.rb @@ -0,0 +1,98 @@ +require 'spec_helper_acceptance' + +describe 'concat::fragment order' do + before(:all) do + @basedir = setup_test_directory + end + + describe 'with reverse order, alphabetical' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': + order => 'alpha' + } + concat::fragment { '1': + target => '#{@basedir}/foo', + content => 'string1', + order => '15', + } + concat::fragment { '2': + target => '#{@basedir}/foo', + content => 'string2', + # default order 10 + } + concat::fragment { '3': + target => '#{@basedir}/foo', + content => 'string3', + order => '1', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string3string2string1} + end + end + + describe 'with reverse order, numeric' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': + order => 'numeric' + } + concat::fragment { '1': + target => '#{@basedir}/foo', + content => 'string1', + order => '15', + } + concat::fragment { '2': + target => '#{@basedir}/foo', + content => 'string2', + # default order 10 + } + concat::fragment { '3': + target => '#{@basedir}/foo', + content => 'string3', + order => '1', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string3string2string1} + end + end + + describe 'with normal order' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': } + concat::fragment { '1': + target => '#{@basedir}/foo', + content => 'string1', + order => '01', + } + concat::fragment { '2': + target => '#{@basedir}/foo', + content => 'string2', + order => '02' + } + concat::fragment { '3': + target => '#{@basedir}/foo', + content => 'string3', + order => '03', + } + MANIFEST + end + + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string1string2string3} + end + end +end diff --git a/3rdparty/modules/concat/spec/acceptance/fragment_replace_spec.rb b/3rdparty/modules/concat/spec/acceptance/fragment_replace_spec.rb new file mode 100644 index 000000000..f552f7bfc --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/fragment_replace_spec.rb @@ -0,0 +1,182 @@ +require 'spec_helper_acceptance' + +describe 'replacement of' do + before(:all) do + @basedir = setup_test_directory + end + + describe 'file' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + replace => false, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '1', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '2', + } + + concat { '#{@basedir}/file2': + replace => true, + } + + concat::fragment { 'file2_1': + target => '#{@basedir}/file2', + content => '1', + } + + concat::fragment { 'file2_2': + target => '#{@basedir}/file2', + content => '2', + } + MANIFEST + end + + it 'when file should not succeed' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match 'file exists' + expect(file("#{@basedir}/file").content).not_to match '1' + expect(file("#{@basedir}/file").content).not_to match '2' + end + it 'when file should succeed' do + expect(file("#{@basedir}/file2")).to be_file + expect(file("#{@basedir}/file2").content).not_to match 'file exists' + expect(file("#{@basedir}/file2").content).to match '1' + expect(file("#{@basedir}/file2").content).to match '2' + end + end + + describe 'symlink', unless: (os[:family] == 'windows') do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + pp = <<-MANIFEST + file { '#{@basedir}': + ensure => directory, + } + file { '#{@basedir}/file': + ensure => link, + target => '#{@basedir}/dangling', + } + MANIFEST + apply_manifest(pp) + end + + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + replace => false, + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '1', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '2', + } + + concat { '#{@basedir}/file2': + replace => true, + } + + concat::fragment { 'file2_1': + target => '#{@basedir}/file2', + content => '1', + } + + concat::fragment { 'file2_2': + target => '#{@basedir}/file2', + content => '2', + } + MANIFEST + end + + it 'when symlink should not succeed' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_linked_to "#{@basedir}/dangling" unless os[:family] == 'aix' || os[:family] == 'windows' + expect(file("#{@basedir}/dangling")).not_to be_file + expect(file("#{@basedir}/dangling")).not_to be_directory + end + it 'when symlink should succeed' do + expect(file("#{@basedir}/file2")).to be_file + expect(file("#{@basedir}/file2").content).to match '1' + expect(file("#{@basedir}/file2").content).to match '2' + end + end + + describe 'when directory should not succeed' do + before(:all) do + pp = <<-MANIFEST + file { '#{@basedir}': + ensure => directory, + } + file { '#{@basedir}/file': + ensure => directory, + } + MANIFEST + apply_manifest(pp) + end + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '1', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '2', + } + MANIFEST + end + + it 'applies the manifest twice with stderr' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{change from '?directory'? to '?file'? failed}) + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{change from '?directory'? to '?file'? failed}) + expect(file("#{@basedir}/file")).to be_directory + end + end + + # XXX + # when there are no fragments, and the replace param will only replace + # files and symlinks, not directories. The semantics either need to be + # changed, extended, or a new param introduced to control directory + # replacement. + describe 'when directory should succeed', pending: 'not yet implemented' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': + } + + concat::fragment { '1': + target => '#{@basedir}/file', + content => '1', + } + + concat::fragment { '2': + target => '#{@basedir}/file', + content => '2', + } + MANIFEST + end + + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '1' + end + end +end diff --git a/3rdparty/modules/concat/spec/acceptance/fragment_source_spec.rb b/3rdparty/modules/concat/spec/acceptance/fragment_source_spec.rb index b208979ac..614bd96a1 100644 --- a/3rdparty/modules/concat/spec/acceptance/fragment_source_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/fragment_source_spec.rb @@ -1,156 +1,143 @@ require 'spec_helper_acceptance' -case fact('osfamily') - when 'AIX' - username = 'root' - groupname = 'system' - when 'Darwin' - username = 'root' - groupname = 'wheel' - when 'windows' - username = 'Administrator' - groupname = 'Administrators' - else - username = 'root' - groupname = 'root' +case os[:family] +when 'aix' + username = 'root' + groupname = 'system' +when 'darwin' + username = 'root' + groupname = 'wheel' +when 'windows' + username = 'Administrator' + groupname = 'Administrators' +else + username = 'root' + groupname = 'root' end describe 'concat::fragment source' do - basedir = default.tmpdir('concat') - context 'should read file fragments from local system' do - pp = <<-EOS - file { '#{basedir}/file1': - content => "file1 contents\n" - } - file { '#{basedir}/file2': - content => "file2 contents\n" - } - concat { '#{basedir}/foo': } + before(:all) do + @basedir = setup_test_directory + end - concat::fragment { '1': - target => '#{basedir}/foo', - source => '#{basedir}/file1', - require => File['#{basedir}/file1'], - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string1 contents', - } - concat::fragment { '3': - target => '#{basedir}/foo', - source => '#{basedir}/file2', - require => File['#{basedir}/file2'], - } - EOS + describe 'when run should read file fragments from local system' do + let(:pp) do + <<-MANIFEST + file { '#{@basedir}/file1': + content => "file1 contents\n" + } + file { '#{@basedir}/file2': + content => "file2 contents\n" + } + concat { '#{@basedir}/foo': } - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + concat::fragment { '1': + target => '#{@basedir}/foo', + source => '#{@basedir}/file1', + require => File['#{@basedir}/file1'], + } + concat::fragment { '2': + target => '#{@basedir}/foo', + content => 'string1 contents', + } + concat::fragment { '3': + target => '#{@basedir}/foo', + source => '#{@basedir}/file2', + require => File['#{@basedir}/file2'], + } + MANIFEST end - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should match 'file1 contents' - should match 'string1 contents' - should match 'file2 contents' - } + it 'idempotent, file matches' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match 'file1 contents' + expect(file("#{@basedir}/foo").content).to match 'file2 contents' end - end # should read file fragments from local system - - context 'should create files containing first match only.' do - pp = <<-EOS - file { '#{basedir}/file1': - content => "file1 contents\n" - } - file { '#{basedir}/file2': - content => "file2 contents\n" - } - concat { '#{basedir}/result_file1': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - concat { '#{basedir}/result_file2': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } - concat { '#{basedir}/result_file3': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } + end - concat::fragment { '1': - target => '#{basedir}/result_file1', - source => [ '#{basedir}/file1', '#{basedir}/file2' ], - require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], - order => '01', - } - concat::fragment { '2': - target => '#{basedir}/result_file2', - source => [ '#{basedir}/file2', '#{basedir}/file1' ], - require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], - order => '01', - } - concat::fragment { '3': - target => '#{basedir}/result_file3', - source => [ '#{basedir}/file1', '#{basedir}/file2' ], - require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ], - order => '01', - } - EOS + describe 'when run should create files containing first match only.' do + let(:pp) do + <<-MANIFEST + file { '#{@basedir}/file1': + content => "file1 contents\n" + } + file { '#{@basedir}/file2': + content => "file2 contents\n" + } + concat { '#{@basedir}/result_file1': + owner => '#{username}', + group => '#{groupname}', + mode => '0644', + } + concat { '#{@basedir}/result_file2': + owner => '#{username}', + group => '#{groupname}', + mode => '0644', + } + concat { '#{@basedir}/result_file3': + owner => '#{username}', + group => '#{groupname}', + mode => '0644', + } - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + concat::fragment { '1': + target => '#{@basedir}/result_file1', + source => [ '#{@basedir}/file1', '#{@basedir}/file2' ], + require => [ File['#{@basedir}/file1'], File['#{@basedir}/file2'] ], + order => '01', + } + concat::fragment { '2': + target => '#{@basedir}/result_file2', + source => [ '#{@basedir}/file2', '#{@basedir}/file1' ], + require => [ File['#{@basedir}/file1'], File['#{@basedir}/file2'] ], + order => '01', + } + concat::fragment { '3': + target => '#{@basedir}/result_file3', + source => [ '#{@basedir}/file1', '#{@basedir}/file2' ], + require => [ File['#{@basedir}/file1'], File['#{@basedir}/file2'] ], + order => '01', + } + MANIFEST end - describe file("#{basedir}/result_file1") do - it { should be_file } - its(:content) { - should match 'file1 contents' - should_not match 'file2 contents' - } - end - describe file("#{basedir}/result_file2") do - it { should be_file } - its(:content) { - should match 'file2 contents' - should_not match 'file1 contents' - } - end - describe file("#{basedir}/result_file3") do - it { should be_file } - its(:content) { - should match 'file1 contents' - should_not match 'file2 contents' - } + + it 'idempotent, files match' do + idempotent_apply(pp) + expect(file("#{@basedir}/result_file1")).to be_file + expect(file("#{@basedir}/result_file1").content).to match 'file1 contents' + expect(file("#{@basedir}/result_file1").content).not_to match 'file2 contents' + + expect(file("#{@basedir}/result_file2")).to be_file + expect(file("#{@basedir}/result_file2").content).to match 'file2 contents' + expect(file("#{@basedir}/result_file2").content).not_to match 'file1 contents' + + expect(file("#{@basedir}/result_file3")).to be_file + expect(file("#{@basedir}/result_file3").content).to match 'file1 contents' + expect(file("#{@basedir}/result_file3").content).not_to match 'file2 contents' end end - context 'should fail if no match on source.' do - pp = <<-EOS - concat { '#{basedir}/fail_no_source': - owner => '#{username}', - group => '#{groupname}', - mode => '0644', - } + describe 'when run should fail if no match on source.' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/fail_no_source': + owner => '#{username}', + group => '#{groupname}', + mode => '0644', + } - concat::fragment { '1': - target => '#{basedir}/fail_no_source', - source => [ '#{basedir}/nofilehere', '#{basedir}/nothereeither' ], - order => '01', - } - EOS + concat::fragment { '1': + target => '#{@basedir}/fail_no_source', + source => [ '#{@basedir}/nofilehere', '#{@basedir}/nothereeither' ], + order => '01', + } + MANIFEST + end it 'applies the manifest with resource failures' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/Failed to generate additional resources using 'eval_generate'/) - end - describe file("#{basedir}/fail_no_source") do - #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. - it { should_not be_directory } + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Failed to generate additional resources using 'eval_generate'}) + expect(file("#{@basedir}/fail_no_source")).not_to be_directory end end end - diff --git a/3rdparty/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb b/3rdparty/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb index 70d738288..fc3f96a33 100644 --- a/3rdparty/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/fragments_are_always_replaced_spec.rb @@ -1,139 +1,101 @@ require 'spec_helper_acceptance' describe 'concat::fragment replace' do - basedir = default.tmpdir('concat') - - context 'should create fragment files' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) - end - - pp1 = <<-EOS - concat { '#{basedir}/foo': } - + before(:all) do + @basedir = setup_test_directory + end + + describe 'when run should create fragment files' do + let(:pp1) do + <<-MANIFEST + concat { '#{@basedir}/foo': } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'caller has replace unset run 1', } - EOS - pp2 = <<-EOS - concat { '#{basedir}/foo': } - + MANIFEST + end + let(:pp2) do + <<-MANIFEST + concat { '#{@basedir}/foo': } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'caller has replace unset run 2', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp1, :catch_failures => true) - apply_manifest(pp1, :catch_changes => true) - apply_manifest(pp2, :catch_failures => true) - apply_manifest(pp2, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should_not match 'caller has replace unset run 1' - should match 'caller has replace unset run 2' - } - end - end # should create fragment files - - context 'should replace its own fragment files when caller has File { replace=>true } set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp1) + idempotent_apply(pp2) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).not_to match 'caller has replace unset run 1' + expect(file("#{@basedir}/foo").content).to match 'caller has replace unset run 2' end + end + # should create fragment files - pp1 = <<-EOS + describe 'when run should replace its own fragment files when caller has File { replace=>true } set' do + let(:pp1) do + <<-MANIFEST File { replace=>true } - concat { '#{basedir}/foo': } - + concat { '#{@basedir}/foo': } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'caller has replace true set run 1', } - EOS - pp2 = <<-EOS + MANIFEST + end + let(:pp2) do + <<-MANIFEST File { replace=>true } - concat { '#{basedir}/foo': } - + concat { '#{@basedir}/foo': } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'caller has replace true set run 2', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp1, :catch_failures => true) - apply_manifest(pp1, :catch_changes => true) - apply_manifest(pp2, :catch_failures => true) - apply_manifest(pp2, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should_not match 'caller has replace true set run 1' - should match 'caller has replace true set run 2' - } - end - end # should replace its own fragment files when caller has File(replace=>true) set - - context 'should replace its own fragment files even when caller has File { replace=>false } set' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - EOS - apply_manifest(pp) + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp1) + idempotent_apply(pp2) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).not_to match 'caller has replace true set run 1' + expect(file("#{@basedir}/foo").content).to match 'caller has replace true set run 2' end + end + # should replace its own fragment files when caller has File(replace=>true) set - pp1 = <<-EOS + describe 'when run should replace its own fragment files even when caller has File { replace=>false } set' do + let(:pp1) do + <<-MANIFEST File { replace=>false } - concat { '#{basedir}/foo': } - + concat { '#{@basedir}/foo': } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'caller has replace false set run 1', } - EOS - pp2 = <<-EOS + MANIFEST + end + let(:pp2) do + <<-MANIFEST File { replace=>false } - concat { '#{basedir}/foo': } - + concat { '#{@basedir}/foo': } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'caller has replace false set run 2', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp1, :catch_failures => true) - apply_manifest(pp1, :catch_changes => true) - apply_manifest(pp2, :catch_failures => true) - apply_manifest(pp2, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { - should_not match 'caller has replace false set run 1' - should match 'caller has replace false set run 2' - } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp1) + idempotent_apply(pp2) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).not_to match 'caller has replace false set run 1' + expect(file("#{@basedir}/foo").content).to match 'caller has replace false set run 2' end - end # should replace its own fragment files even when caller has File(replace=>false) set - + end + # should replace its own fragment files even when caller has File(replace=>false) set end diff --git a/3rdparty/modules/concat/spec/acceptance/newline_spec.rb b/3rdparty/modules/concat/spec/acceptance/newline_spec.rb index c1fa16a10..7a8bfdf4e 100644 --- a/3rdparty/modules/concat/spec/acceptance/newline_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/newline_spec.rb @@ -1,67 +1,54 @@ require 'spec_helper_acceptance' describe 'concat ensure_newline parameter' do - basedir = default.tmpdir('concat') - context '=> false' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory - } - EOS - - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': + before(:all) do + @basedir = setup_test_directory + end + describe 'when false' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': ensure_newline => false, } concat::fragment { '1': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '1', } concat::fragment { '2': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '2', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match '12' } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '12' end end - context '=> true' do - pp = <<-EOS - concat { '#{basedir}/file': + describe 'when true' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': ensure_newline => true, } concat::fragment { '1': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '1', } concat::fragment { '2': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '2', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /1\n2\n/ - } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{1\r?\n2\r?\n} end end end diff --git a/3rdparty/modules/concat/spec/acceptance/nodesets/debian-9-x64.yml b/3rdparty/modules/concat/spec/acceptance/nodesets/debian-9-x64.yml new file mode 100644 index 000000000..9f7d3cab8 --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/nodesets/debian-9-x64.yml @@ -0,0 +1,20 @@ +HOSTS: + debian-9-x64: + pe_dir: + pe_ver: + pe_upgrade_dir: + pe_upgrade_ver: + hypervisor: vmpooler + platform: debian-9-x64 + ruby_arch: x64 + template: debian-9-x86_64 + roles: + - agent + - master + - database + - dashboard + - default +CONFIG: + nfs_server: none + consoleport: 443 + pooling_api: http://vmpooler.delivery.puppetlabs.net/ diff --git a/3rdparty/modules/concat/spec/acceptance/noop_spec.rb b/3rdparty/modules/concat/spec/acceptance/noop_spec.rb new file mode 100644 index 000000000..3432ae733 --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/noop_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper_acceptance' + +describe 'concat noop parameter', if: ['debian', 'redhat', 'ubuntu'].include?(os[:family]) do + before(:all) do + @basedir = setup_test_directory + end + describe 'with "/usr/bin/test -e %"' do + let(:pp) do + <<-MANIFEST + concat_file { '#{@basedir}/file': + noop => false, + } + concat_fragment { 'content': + target => '#{@basedir}/file', + content => 'content', + } + MANIFEST + end + + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to contain 'content' + end + end +end diff --git a/3rdparty/modules/concat/spec/acceptance/order_spec.rb b/3rdparty/modules/concat/spec/acceptance/order_spec.rb index b746b1c9c..307502b18 100644 --- a/3rdparty/modules/concat/spec/acceptance/order_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/order_spec.rb @@ -1,123 +1,66 @@ require 'spec_helper_acceptance' describe 'concat order' do - basedir = default.tmpdir('concat') - - context '=> ' do - shared_examples 'sortby' do |order_by, match_output| - pp = <<-EOS - concat { '#{basedir}/foo': - order => '#{order_by}' + before(:all) do + @basedir = setup_test_directory + end + describe 'sortby alpha' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': + order => 'alpha' } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string1', order => '1', } concat::fragment { '2': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string2', order => '2', } concat::fragment { '10': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string10', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match match_output } - end + MANIFEST end - describe 'alpha' do - it_behaves_like 'sortby', 'alpha', /string1string10string2/ - end - - describe 'numeric' do - it_behaves_like 'sortby', 'numeric', /string1string2string10/ + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string1string10string2} end end -end # concat order -describe 'concat::fragment order' do - basedir = default.tmpdir('concat') - - context '=> reverse order' do - shared_examples 'order_by' do |order_by, match_output| - pp = <<-EOS - concat { '#{basedir}/foo': - order => '#{order_by}' + describe 'sortby numeric' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': + order => 'numeric' } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string1', - order => '15', - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string2', - # default order 10 - } - concat::fragment { '3': - target => '#{basedir}/foo', - content => 'string3', order => '1', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match match_output } - end - end - describe 'alpha' do - it_should_behave_like 'order_by', 'alpha', /string3string2string1/ - end - describe 'numeric' do - it_should_behave_like 'order_by', 'numeric', /string3string2string1/ - end - end - - context '=> normal order' do - pp = <<-EOS - concat { '#{basedir}/foo': } - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'string1', - order => '01', - } concat::fragment { '2': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string2', - order => '02' + order => '2', } - concat::fragment { '3': - target => '#{basedir}/foo', - content => 'string3', - order => '03', + concat::fragment { '10': + target => '#{@basedir}/foo', + content => 'string10', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match /string1string2string3/ } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string1string2string10} end end -end # concat::fragment order +end diff --git a/3rdparty/modules/concat/spec/acceptance/pup-1963_spec.rb b/3rdparty/modules/concat/spec/acceptance/pup-1963_spec.rb deleted file mode 100644 index c36fe41cd..000000000 --- a/3rdparty/modules/concat/spec/acceptance/pup-1963_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'spec_helper_acceptance' - -case fact('osfamily') - when 'Windows' - command = 'cmd.exe /c echo triggered' - else - command = 'echo triggered' -end - -describe 'with metaparameters' do - describe 'with subscribed resources' do - basedir = default.tmpdir('concat') - - context 'should trigger refresh' do - pp = <<-EOS - concat { "foobar": - ensure => 'present', - path => '#{basedir}/foobar', - } - - concat::fragment { 'foo': - target => 'foobar', - content => 'foo', - } - - exec { 'trigger': - path => $::path, - command => "#{command}", - subscribe => Concat['foobar'], - refreshonly => true, - } - EOS - - it 'applies the manifest twice with stdout regex' do - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/Triggered 'refresh'/) - expect(apply_manifest(pp, :catch_changes => true).stdout).to_not match(/Triggered 'refresh'/) - end - end - end - - describe 'with resources to notify' do - basedir = default.tmpdir('concat') - context 'should notify' do - pp = <<-EOS - exec { 'trigger': - path => $::path, - command => "#{command}", - refreshonly => true, - } - - concat { "foobar": - ensure => 'present', - path => '#{basedir}/foobar', - notify => Exec['trigger'], - } - - concat::fragment { 'foo': - target => 'foobar', - content => 'foo', - } - EOS - - it 'applies the manifest twice with stdout regex' do - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/Triggered 'refresh'/) - expect(apply_manifest(pp, :catch_changes => true).stdout).to_not match(/Triggered 'refresh'/) - end - end - end -end diff --git a/3rdparty/modules/concat/spec/acceptance/pup_1963_spec.rb b/3rdparty/modules/concat/spec/acceptance/pup_1963_spec.rb new file mode 100644 index 000000000..c42e3fc26 --- /dev/null +++ b/3rdparty/modules/concat/spec/acceptance/pup_1963_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper_acceptance' + +command = case os[:family] + when 'windows' + 'cmd.exe /c echo triggered' + else + 'echo triggered' + end + +describe 'with metaparameters' do + before(:each) do + @basedir = setup_test_directory + end + + describe 'with subscribed resources' do + let(:pp) do + <<-MANIFEST + concat { "foobar": + ensure => 'present', + path => '#{@basedir}/foobar', + } + + concat::fragment { 'foo': + target => 'foobar', + content => 'foo', + } + + exec { 'trigger': + path => $::path, + command => "#{command}", + subscribe => Concat['foobar'], + refreshonly => true, + } + MANIFEST + end + + it 'applies the manifest twice with no changes second apply' do + expect(apply_manifest(pp, catch_failures: true).stdout).to match(%r{Triggered 'refresh'}) + expect(apply_manifest(pp, catch_changes: true).stdout).not_to match(%r{Triggered 'refresh'}) + end + end + + describe 'with resources to notify' do + let(:pp) do + <<-MANIFEST + exec { 'trigger': + path => $::path, + command => "#{command}", + refreshonly => true, + } + + concat { "foobar": + ensure => 'present', + path => '#{@basedir}/foobar', + notify => Exec['trigger'], + } + + concat::fragment { 'foo': + target => 'foobar', + content => 'foo', + } + MANIFEST + end + + it 'applies the manifest twice with no changes second apply' do + expect(apply_manifest(pp, catch_failures: true).stdout).to match(%r{Triggered 'refresh'}) + expect(apply_manifest(pp, catch_changes: true).stdout).not_to match(%r{Triggered 'refresh'}) + end + end +end diff --git a/3rdparty/modules/concat/spec/acceptance/quoted_paths_spec.rb b/3rdparty/modules/concat/spec/acceptance/quoted_paths_spec.rb index 6f9f9fd5f..e331c08f8 100644 --- a/3rdparty/modules/concat/spec/acceptance/quoted_paths_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/quoted_paths_spec.rb @@ -1,42 +1,33 @@ require 'spec_helper_acceptance' describe 'quoted paths' do - basedir = default.tmpdir('concat') - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/concat test': - ensure => directory, - } - EOS - apply_manifest(pp) + @basedir = setup_test_directory end - context 'path with blanks' do - pp = <<-EOS - concat { '#{basedir}/concat test/foo': - } - concat::fragment { '1': - target => '#{basedir}/concat test/foo', - content => 'string1', - } - concat::fragment { '2': - target => '#{basedir}/concat test/foo', - content => 'string2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + describe 'with path with blanks' do + let(:pp) do + <<-MANIFEST + file { '#{@basedir}/concat test': + ensure => directory, + } + concat { '#{@basedir}/concat test/foo': + } + concat::fragment { '1': + target => '#{@basedir}/concat test/foo', + content => 'string1', + } + concat::fragment { '2': + target => '#{@basedir}/concat test/foo', + content => 'string2', + } + MANIFEST end - describe file("#{basedir}/concat test/foo") do - it { should be_file } - its(:content) { should match /string1string2/ } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/concat test/foo")).to be_file + expect(file("#{@basedir}/concat test/foo").content).to match %r{string1string2} end end end diff --git a/3rdparty/modules/concat/spec/acceptance/replace_spec.rb b/3rdparty/modules/concat/spec/acceptance/replace_spec.rb deleted file mode 100644 index c9e28ecc4..000000000 --- a/3rdparty/modules/concat/spec/acceptance/replace_spec.rb +++ /dev/null @@ -1,261 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'replacement of' do - basedir = default.tmpdir('concat') - context 'file' do - context 'should not succeed' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "file exists\n" - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - replace => false, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match 'file exists' - should_not match '1' - should_not match '2' - } - end - end - - context 'should succeed' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - content => "file exists\n" - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': - replace => true, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should_not match 'file exists' - should match '1' - should match '2' - } - end - end - end # file - - context 'symlink', :unless => (fact("osfamily") == "windows") do - context 'should not succeed' do - # XXX the core puppet file type will replace a symlink with a plain file - # when using ensure => present and source => ... but it will not when using - # ensure => present and content => ...; this is somewhat confusing behavior - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - ensure => link, - target => '#{basedir}/dangling', - } - EOS - apply_manifest(pp) - end - - pp = <<-EOS - concat { '#{basedir}/file': - replace => false, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - # XXX specinfra doesn't support be_linked_to on AIX - describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or fact("osfamily") == "windows") do - it { should be_linked_to "#{basedir}/dangling" } - end - - describe file("#{basedir}/dangling") do - # XXX serverspec does not have a matcher for 'exists' - it { should_not be_file } - it { should_not be_directory } - end - end - - context 'should succeed' do - # XXX the core puppet file type will replace a symlink with a plain file - # when using ensure => present and source => ... but it will not when using - # ensure => present and content => ...; this is somewhat confusing behavior - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - ensure => link, - target => '#{basedir}/dangling', - } - EOS - apply_manifest(pp) - end - - pp = <<-EOS - concat { '#{basedir}/file': - replace => true, - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match '1' - should match '2' - } - end - end - end # symlink - - context 'directory' do - context 'should not succeed' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory, - } - file { '#{basedir}/file': - ensure => directory, - } - EOS - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with stderr for changing to file' do - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from '?directory'? to '?file'? failed/) - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from '?directory'? to '?file'? failed/) - end - - describe file("#{basedir}/file") do - it { should be_directory } - end - end - - # XXX - # when there are no fragments, and the replace param will only replace - # files and symlinks, not directories. The semantics either need to be - # changed, extended, or a new param introduced to control directory - # replacement. - context 'should succeed', :pending => 'not yet implemented' do - pp = <<-EOS - concat { '#{basedir}/file': - } - - concat::fragment { '1': - target => '#{basedir}/file', - content => '1', - } - - concat::fragment { '2': - target => '#{basedir}/file', - content => '2', - } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { should match '1' } - end - end - end # directory -end diff --git a/3rdparty/modules/concat/spec/acceptance/specinfra_stubs.rb b/3rdparty/modules/concat/spec/acceptance/specinfra_stubs.rb index bae85eff0..94622ca06 100644 --- a/3rdparty/modules/concat/spec/acceptance/specinfra_stubs.rb +++ b/3rdparty/modules/concat/spec/acceptance/specinfra_stubs.rb @@ -1,3 +1,4 @@ +# class Specinfra::Command::Windows::Base::File class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Base class << self def check_is_owned_by(file, owner) @@ -8,8 +9,7 @@ class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Bas end end end - - +# class Specinfra::Command::Base::File class Specinfra::Command::Base::File < Specinfra::Command::Base class << self def get_content(file) diff --git a/3rdparty/modules/concat/spec/acceptance/symbolic_name_spec.rb b/3rdparty/modules/concat/spec/acceptance/symbolic_name_spec.rb index df8d54f52..1a55a842a 100644 --- a/3rdparty/modules/concat/spec/acceptance/symbolic_name_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/symbolic_name_spec.rb @@ -1,35 +1,34 @@ require 'spec_helper_acceptance' describe 'symbolic name' do - basedir = default.tmpdir('concat') - pp = <<-EOS - concat { 'not_abs_path': - path => '#{basedir}/file', - } + before(:all) do + @basedir = setup_test_directory + end - concat::fragment { '1': - target => 'not_abs_path', - content => '1', - order => '01', - } + let(:pp) do + <<-MANIFEST + concat { 'not_abs_path': + path => '#{@basedir}/file', + } - concat::fragment { '2': - target => 'not_abs_path', - content => '2', - order => '02', - } - EOS + concat::fragment { '1': + target => 'not_abs_path', + content => '1', + order => '01', + } - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + concat::fragment { '2': + target => 'not_abs_path', + content => '2', + order => '02', + } + MANIFEST end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match '1' - should match '2' - } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match '1' + expect(file("#{@basedir}/file").content).to match '2' end end diff --git a/3rdparty/modules/concat/spec/acceptance/validation_spec.rb b/3rdparty/modules/concat/spec/acceptance/validation_spec.rb index c35871b9b..7a3641a71 100644 --- a/3rdparty/modules/concat/spec/acceptance/validation_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/validation_spec.rb @@ -1,35 +1,27 @@ require 'spec_helper_acceptance' -describe 'concat validate_cmd parameter', :unless => (fact('kernel') != 'Linux') do - basedir = default.tmpdir('concat') - context '=> "/usr/bin/test -e %"' do - before(:all) do - pp = <<-EOS - file { '#{basedir}': - ensure => directory - } - EOS +describe 'validation, concat validate_cmd parameter', if: ['debian', 'redhat', 'ubuntu'].include?(os[:family]) do + before(:all) do + @basedir = setup_test_directory + end - apply_manifest(pp) - end - pp = <<-EOS - concat { '#{basedir}/file': + context 'with "/usr/bin/test -e %"' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': validate_cmd => '/usr/bin/test -e %', } concat::fragment { 'content': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => 'content', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/file") do - it { should be_file } - it { should contain 'content' } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to contain 'content' end end end diff --git a/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb b/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb index b73414e34..84894b482 100644 --- a/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/warn_header_spec.rb @@ -1,104 +1,84 @@ require 'spec_helper_acceptance' -describe 'concat warn =>' do - basedir = default.tmpdir('concat') - context 'true should enable default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': +describe 'concat warn_header =>' do + before(:all) do + @basedir = setup_test_directory + end + + describe 'applies the manifest twice with no stderr' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/file': warn => true, } concat::fragment { '1': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '1', order => '01', } concat::fragment { '2': - target => '#{basedir}/file', + target => '#{@basedir}/file', content => '2', order => '02', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /# This file is managed by Puppet\. DO NOT EDIT\./ - should match /1/ - should match /2/ - } - end - end - context 'false should not enable default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': + concat { '#{@basedir}/file2': warn => false, } - concat::fragment { '1': - target => '#{basedir}/file', + concat::fragment { 'file2_1': + target => '#{@basedir}/file2', content => '1', order => '01', } - concat::fragment { '2': - target => '#{basedir}/file', + concat::fragment { 'file2_2': + target => '#{@basedir}/file2', content => '2', order => '02', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should_not match /# This file is managed by Puppet\. DO NOT EDIT\./ - should match /1/ - should match /2/ - } - end - end - context '# foo should overide default warning message' do - pp = <<-EOS - concat { '#{basedir}/file': + concat { '#{@basedir}/file3': warn => "# foo\n", } - concat::fragment { '1': - target => '#{basedir}/file', + concat::fragment { 'file3_1': + target => '#{@basedir}/file3', content => '1', order => '01', } - concat::fragment { '2': - target => '#{basedir}/file', + concat::fragment { 'file3_2': + target => '#{@basedir}/file3', content => '2', order => '02', } - EOS - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/file") do - it { should be_file } - its(:content) { - should match /# foo/ - should match /1/ - should match /2/ - } + it 'when true should enable default warning message' do + idempotent_apply(pp) + expect(file("#{@basedir}/file")).to be_file + expect(file("#{@basedir}/file").content).to match %r{# This file is managed by Puppet\. DO NOT EDIT\.} + expect(file("#{@basedir}/file").content).to match %r{1} + expect(file("#{@basedir}/file").content).to match %r{2} + end + + it 'when false should not enable default warning message' do + expect(file("#{@basedir}/file2")).to be_file + expect(file("#{@basedir}/file2").content).not_to match %r{# This file is managed by Puppet\. DO NOT EDIT\.} + expect(file("#{@basedir}/file2").content).to match %r{1} + expect(file("#{@basedir}/file2").content).to match %r{2} + end + + it 'when foo should overide default warning message' do + expect(file("#{@basedir}/file3")).to be_file + expect(file("#{@basedir}/file3").content).to match %r{# foo} + expect(file("#{@basedir}/file3").content).to match %r{1} + expect(file("#{@basedir}/file3").content).to match %r{2} end end end diff --git a/3rdparty/modules/concat/spec/acceptance/warnings_spec.rb b/3rdparty/modules/concat/spec/acceptance/warnings_spec.rb index c3f76bf28..76e69d4bc 100644 --- a/3rdparty/modules/concat/spec/acceptance/warnings_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/warnings_spec.rb @@ -1,29 +1,26 @@ require 'spec_helper_acceptance' describe 'warnings' do - basedir = default.tmpdir('concat') - - shared_examples 'has_warning' do |pp, w| - it 'applies the manifest twice with a stderr regex' do - expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m) - expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m) - end + before(:all) do + @basedir = setup_test_directory end - context 'concat::fragment target not found' do - context 'target not found' do - pp = <<-EOS + context 'when concat::fragment target not found' do + let(:pp) do + <<-MANIFEST concat { 'file': - path => '#{basedir}/file', + path => '#{@basedir}/file', } concat::fragment { 'foo': - target => '#{basedir}/bar', + target => '#{@basedir}/bar', content => 'bar', } - EOS - w = 'not found in the catalog' + MANIFEST + end - it_behaves_like 'has_warning', pp, w + it 'applies manifests, check stderr' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match 'not found in the catalog' + expect(apply_manifest(pp, expect_failures: true).stderr).to match 'not found in the catalog' end end end diff --git a/3rdparty/modules/concat/spec/default_facts.yml b/3rdparty/modules/concat/spec/default_facts.yml new file mode 100644 index 000000000..ea1e4808e --- /dev/null +++ b/3rdparty/modules/concat/spec/default_facts.yml @@ -0,0 +1,7 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +ipaddress: "172.16.254.254" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/3rdparty/modules/concat/spec/defines/concat_fragment_spec.rb b/3rdparty/modules/concat/spec/defines/concat_fragment_spec.rb new file mode 100644 index 000000000..0dea25b4c --- /dev/null +++ b/3rdparty/modules/concat/spec/defines/concat_fragment_spec.rb @@ -0,0 +1,156 @@ +require 'spec_helper' + +describe 'concat::fragment' do + shared_examples 'fragment' do |title, params| + params = {} if params.nil? + + p = { + content: nil, + source: nil, + order: 10, + }.merge(params) + + let(:title) { title } + let(:params) { params } + let(:pre_condition) do + "concat{ '#{p[:target]}': }" + end + + it do + is_expected.to contain_concat(p[:target]) + end + it do + is_expected.to contain_concat_file(p[:target]) + end + it do + is_expected.to contain_concat_fragment(title) + end + end + + context 'when title' do + ['0', '1', 'a', 'z'].each do |title| + it_behaves_like 'fragment', title, target: '/etc/motd', + content: "content for #{title}" + end + end + # title + + context 'when target =>' do + ['./etc/motd', 'etc/motd', 'motd_header'].each do |target| + context target do + it_behaves_like 'fragment', target, target: '/etc/motd', + content: "content for #{target}" + end + end + + context 'when false' do + let(:title) { 'motd_header' } + let(:params) { { target: false } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'target' expects a .*String.*}) + end + end + end + # target => + + context 'when content =>' do + ['', 'ashp is our hero'].each do |content| + context content do + it_behaves_like 'fragment', 'motd_header', content: content, + target: '/etc/motd' + end + end + + context 'when false' do + let(:title) { 'motd_header' } + let(:params) { { content: false, target: '/etc/motd' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'content' expects a .*String.*}) + end + end + end + # content => + + context 'when source =>' do + ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source| + context source do + it_behaves_like 'fragment', 'motd_header', source: source, + target: '/etc/motd' + end + end + + context 'when false' do + let(:title) { 'motd_header' } + let(:params) { { source: false, target: '/etc/motd' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'source' expects a .*String.*Array.*}) + end + end + end + # source => + + context 'when order =>' do + ['', '42', 'a', 'z'].each do |order| + context "'#{order}'" do + it_behaves_like 'fragment', 'motd_header', order: order, + target: '/etc/motd' + end + end + + context 'when false' do + let(:title) { 'motd_header' } + let(:params) { { order: false, target: '/etc/motd' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Evaluation Error.*expects.*Boolean.*}) + end + end + + context 'when 123:456' do + let(:title) { 'motd_header' } + let(:params) { { order: '123:456', target: '/etc/motd' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{cannot contain}) + end + end + context 'when 23/456' do + let(:title) { 'motd_header' } + let(:params) { { order: '123/456', target: '/etc/motd' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{cannot contain}) + end + end + context 'when 123\n456' do + let(:title) { 'motd_header' } + let(:params) { { order: "123\n456", target: '/etc/motd' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{cannot contain}) + end + end + end + # order => + + context 'with more than one content source' do + context 'with source and content' do + let(:title) { 'motd_header' } + let(:params) do + { + target: '/etc/motd', + source: '/foo', + content: 'bar', + } + end + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Can\'t use \'source\' and \'content\' at the same time}m) + end + end + end + # more than one content source +end diff --git a/3rdparty/modules/concat/spec/defines/concat_spec.rb b/3rdparty/modules/concat/spec/defines/concat_spec.rb new file mode 100644 index 000000000..4adcd01f1 --- /dev/null +++ b/3rdparty/modules/concat/spec/defines/concat_spec.rb @@ -0,0 +1,402 @@ +require 'spec_helper' + +describe 'concat' do + shared_examples 'concat' do |title, params, id| + params = {} if params.nil? + id = 'root' if id.nil? + + # default param values + p = { + ensure: 'present', + path: title, + owner: nil, + group: nil, + mode: '0644', + warn: false, + backup: 'puppet', + replace: true, + force: false, + }.merge(params) + + file_defaults = { + backup: p[:backup], + } + + present_expect = { + ensure: 'present', + owner: p[:owner], + group: p[:group], + mode: p[:mode], + path: p[:path], + backup: p[:backup], + replace: p[:replace], + selinux_ignore_defaults: p[:selinux_ignore_defaults], + selrange: p[:selrange], + selrole: p[:selrole], + seltype: p[:seltype], + seluser: p[:seluser], + force: p[:force], + } + + let(:title) { title } + let(:params) { params } + let(:facts) do + { + id: id, + osfamily: 'Debian', + path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + kernel: 'Linux', + is_pe: false, + } + end + + if p[:ensure] == 'present' + it do + is_expected.to contain_concat(title).with(file_defaults.merge(present_expect)) + end + else + it do + is_expected.to contain_concat(title).with(file_defaults.merge(ensure: 'absent', + backup: p[:backup])) + end + end + end + + context 'when title without path param' do + # title/name is the default value for the path param. therefore, the + # title must be an absolute path unless path is specified + ['/foo', '/foo/bar', '/foo/bar/baz'].each do |title| + context title do + it_behaves_like 'concat', '/etc/foo.bar' + end + end + + ['./foo', 'foo', 'foo/bar'].each do |title| + context title do + let(:title) { title } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Stdlib::Unixpath}) + end + end + end + end + + context 'when title with path param' do + ['/foo', 'foo', 'foo/bar'].each do |title| + context title do + it_behaves_like 'concat', title, path: '/etc/foo.bar' + end + end + end + + context 'when title with special characters in title' do + ['foo:bar', 'foo*bar', 'foo(bar)', 'foo@bar'].each do |title| + context title do + it_behaves_like 'concat', title, path: '/etc/foo.bar' + end + end + end + + context 'when as non-root user' do + it_behaves_like 'concat', '/etc/foo.bar', {}, 'bob' + end + + context 'when ensure =>' do + ['present', 'absent'].each do |ens| + context ens do + it_behaves_like 'concat', '/etc/foo.bar', ensure: ens + end + end + + context 'when invalid' do + let(:title) { '/etc/foo.bar' } + let(:params) { { ensure: 'invalid' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{expects a match for Enum\['absent', 'present'\]}) + end + end + end + # ensure => + + context 'when path =>' do + context 'when /foo' do + it_behaves_like 'concat', '/etc/foo.bar', path: '/foo' + end + + context 'when false' do + let(:title) { '/etc/foo.bar' } + let(:params) { { path: false } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Stdlib::Unixpath}) + end + end + + ['./foo', 'foo', 'foo/bar'].each do |path| + context path do + let(:title) { '/etc/foo.bar' } + let(:params) { { path: path } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Stdlib::Unixpath}) + end + end + end + end + # path => + + context 'when owner =>' do + ['apenney', 1000, '1001'].each do |owner| + context owner do + it_behaves_like 'concat', '/etc/foo.bar', owner: owner + end + end + + context 'when false' do + let(:title) { '/etc/foo.bar' } + let(:params) { { owner: false } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Evaluation Error.*expects.*String.*Boolean.*}) + end + end + end + # owner => + + context 'when group =>' do + ['apenney', 1000, '1001'].each do |group| + context group do + it_behaves_like 'concat', '/etc/foo.bar', group: group + end + end + + context 'when false' do + let(:title) { '/etc/foo.bar' } + let(:params) { { group: false } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Evaluation Error.*expects.*String.*Boolean.*}) + end + end + end + # group => + + context 'when mode =>' do + context 'when 1755' do + it_behaves_like 'concat', '/etc/foo.bar', mode: '1755' + end + + context 'when false' do + let(:title) { '/etc/foo.bar' } + let(:params) { { mode: false } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'mode' expects .*String.*}) + end + end + end + # mode => + + context 'when warn =>' do + [true, false, '# foo'].each do |warn| + context warn do + it_behaves_like 'concat', '/etc/foo.bar', warn: warn + end + end + + context 'when (stringified boolean)' do + ['true', 'yes', 'on', 'false', 'no', 'off'].each do |warn| + define warn do + it_behaves_like 'concat', '/etc/foo.bar', warn: warn + + it 'creates a warning' do + skip('rspec-puppet support for testing warning()') + end + end + end + end + + context 'when 123' do + let(:title) { '/etc/foo.bar' } + let(:params) { { warn: 123 } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'warn' expects .*Boolean.*String.*}) + end + end + end + # warn => + + context 'when show_diff =>' do + [true, false].each do |show_diff| + context show_diff do + it_behaves_like 'concat', '/etc/foo.bar', show_diff: show_diff + end + end + + context 'when 123' do + let(:title) { '/etc/foo.bar' } + let(:params) { { show_diff: 123 } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'show_diff' expects .*Boolean.*}) + end + end + end + # show_diff => + + context 'when backup =>' do + ['reverse', false, true].each do |backup| + context backup.to_s do + it_behaves_like 'concat', '/etc/foo.bar', backup: backup + end + end + + context 'when true' do + let(:title) { '/etc/foo.bar' } + let(:params) { { backup: [] } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'backup' expects .*Boolean.*String.*}) + end + end + end + # backup => + + context 'when replace =>' do + [true, false].each do |replace| + context replace do + it_behaves_like 'concat', '/etc/foo.bar', replace: replace + end + end + + context 'when 123' do + let(:title) { '/etc/foo.bar' } + let(:params) { { replace: 123 } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'replace' expects .*Boolean.*}) + end + end + end + # replace => + + context 'when force =>' do + [true, false].each do |force| + context force do + it_behaves_like 'concat', '/etc/foo.bar', force: force + end + end + + context 'when 123' do + let(:title) { '/etc/foo.bar' } + let(:params) { { force: 123 } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'force' expects .*Boolean.*}) + end + end + end + # force => + + context 'when order =>' do + ['alpha', 'numeric'].each do |order| + context order do + it_behaves_like 'concat', '/etc/foo.bar', order: order + end + end + + context 'when invalid' do + let(:title) { '/etc/foo.bar' } + let(:params) { { order: 'invalid' } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{expects a match for Enum\['alpha', 'numeric'\]}) + end + end + end + # order => + + context 'when ensure_newline =>' do + [true, false].each do |ensure_newline| + context 'when true' do + it_behaves_like 'concat', '/etc/foo.bar', ensure_newline: ensure_newline + end + end + + context 'when 123' do + let(:title) { '/etc/foo.bar' } + let(:params) { { ensure_newline: 123 } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'ensure_newline' expects a Boolean value}) + end + end + end + # ensure_newline => + + context 'when validate_cmd =>' do + context 'when /usr/bin/test -e %' do + it_behaves_like 'concat', '/etc/foo.bar', validate_cmd: '/usr/bin/test -e %' + end + + [1234, true].each do |cmd| + context cmd do + let(:title) { '/etc/foo.bar' } + let(:params) { { validate_cmd: cmd } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter 'validate_cmd' expects.*String.*}) + end + end + end + end + # validate_cmd => + + context 'when selinux_ignore_defaults =>' do + let(:title) { '/etc/foo.bar' } + + [true, false].each do |v| + context v do + it_behaves_like 'concat', '/etc/foo.bar', selinux_ignore_defaults: v + end + end + + context 'when 123' do + let(:title) { '/etc/foo.bar' } + let(:params) { { selinux_ignore_defaults: 123 } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{Evaluation Error.*expects.*Boolean.*}) + end + end + end + # selinux_ignore_defaults => + + [ + :selrange, + :selrole, + :seltype, + :seluser, + ].each do |p| + context " #{p} =>" do + let(:title) { '/etc/foo.bar' } + + context 'when foo' do + it_behaves_like 'concat', '/etc/foo.bar', p => 'foo' + end + + context 'when false' do + let(:title) { '/etc/foo.bar' } + let(:params) { { p => false } } + + it 'fails' do + expect { catalogue }.to raise_error(Puppet::Error, %r{parameter '#{p}' expects.*String.*}) + end + end + end + # #{p} => + end +end diff --git a/3rdparty/modules/concat/spec/spec_helper.rb b/3rdparty/modules/concat/spec/spec_helper.rb index 22d5d689f..c09e0024d 100644 --- a/3rdparty/modules/concat/spec/spec_helper.rb +++ b/3rdparty/modules/concat/spec/spec_helper.rb @@ -1,8 +1,59 @@ -#This file is generated by ModuleSync, do not edit. +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) + +include RspecPuppetFacts + +default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version, +} + +default_fact_files = [ + File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), + File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), +] + +default_fact_files.each do |f| + next unless File.exist?(f) && File.readable?(f) && File.size?(f) -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError + begin + default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) + rescue => e + RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" + end end + +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value +end + +RSpec.configure do |c| + c.default_facts = default_facts + c.before :each do + # set to strictest setting for testing + # by default Puppet runs at warning level + Puppet.settings[:strict] = :warning + end + c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) + end +end + +# Ensures that a module is defined +# @param module_name Name of the module +def ensure_module_defined(module_name) + module_name.split('::').reduce(Object) do |last_module, next_module| + last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) + last_module.const_get(next_module, false) + end +end + +# 'spec_overrides' from sync.yml will appear below this line diff --git a/3rdparty/modules/concat/spec/spec_helper_acceptance.rb b/3rdparty/modules/concat/spec/spec_helper_acceptance.rb index f9986ab57..745d46e1b 100644 --- a/3rdparty/modules/concat/spec/spec_helper_acceptance.rb +++ b/3rdparty/modules/concat/spec/spec_helper_acceptance.rb @@ -1,25 +1,59 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' -require 'acceptance/specinfra_stubs' -require 'beaker/puppet_install_helper' -require 'beaker/module_install_helper' +# frozen_string_literal: true -run_puppet_install_helper -install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i -install_module_on(hosts) -install_module_dependencies_on(hosts) +require 'serverspec' +require 'puppet_litmus' +require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) +include PuppetLitmus -RSpec.configure do |c| - # Readable test descriptions - c.formatter = :documentation - - c.before(:all) do - shell('mkdir -p /tmp/concat') - end - c.after(:all) do - shell('rm -rf /tmp/concat /var/lib/puppet/concat') +if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost' + puts 'Running tests against this machine !' + if Gem.win_platform? + set :backend, :cmd + else + set :backend, :exec end +else + # load inventory + inventory_hash = inventory_hash_from_inventory_file + node_config = config_from_node(inventory_hash, ENV['TARGET_HOST']) - c.treat_symbols_as_metadata_keys_with_true_values = true -end + if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes') + host = ENV['TARGET_HOST'] + set :backend, :docker + set :docker_container, host + elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes') + set :backend, :ssh + options = Net::SSH::Config.for(host) + options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil? + options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil? + options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil? + options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil? + options[:verify_host_key] = Net::SSH::Verifiers::Null.new unless node_config.dig('ssh', 'host-key-check').nil? + host = if ENV['TARGET_HOST'].include?(':') + ENV['TARGET_HOST'].split(':').first + else + ENV['TARGET_HOST'] + end + set :host, options[:host_name] || host + set :ssh_options, options + set :request_pty, true + elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes') + require 'winrm' + + set :backend, :winrm + set :os, family: 'windows' + user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil? + pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil? + endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" + opts = { + user: user, + password: pass, + endpoint: endpoint, + operation_timeout: 300, + } + + winrm = WinRM::Connection.new opts + Specinfra.configuration.winrm = winrm + end +end diff --git a/3rdparty/modules/concat/spec/spec_helper_acceptance_local.rb b/3rdparty/modules/concat/spec/spec_helper_acceptance_local.rb new file mode 100644 index 000000000..a59bbcd45 --- /dev/null +++ b/3rdparty/modules/concat/spec/spec_helper_acceptance_local.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +def setup_test_directory + basedir = case os[:family] + when 'windows' + 'c:/concat_test' + else + '/tmp/concat_test' + end + pp = <<-MANIFEST + file { '#{basedir}': + ensure => directory, + force => true, + purge => true, + recurse => true, + } + file { '#{basedir}/file': + content => "file exists\n", + force => true, + } + MANIFEST + apply_manifest(pp) + basedir +end diff --git a/3rdparty/modules/concat/spec/spec_helper_local.rb b/3rdparty/modules/concat/spec/spec_helper_local.rb new file mode 100644 index 000000000..fc2982789 --- /dev/null +++ b/3rdparty/modules/concat/spec/spec_helper_local.rb @@ -0,0 +1,75 @@ +if ENV['COVERAGE'] == 'yes' + require 'simplecov' + require 'simplecov-console' + require 'codecov' + + SimpleCov.formatters = [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::Console, + SimpleCov::Formatter::Codecov, + ] + SimpleCov.start do + track_files 'lib/**/*.rb' + + add_filter '/spec' + + # do not track vendored files + add_filter '/vendor' + add_filter '/.vendor' + + # do not track gitignored files + # this adds about 4 seconds to the coverage check + # this could definitely be optimized + add_filter do |f| + # system returns true if exit status is 0, which with git-check-ignore means file is ignored + system("git check-ignore --quiet #{f.filename}") + end + end +end + +shared_examples 'Puppet::Parameter::Boolean' do |parameter| + [true, :true, 'true', :yes, 'yes'].each do |value| + it "accepts #{value} (#{value.class}) as a value" do + resource[parameter] = value + expect(resource[parameter]).to eq(true) + end + end + + [false, :false, 'false', :no, 'no'].each do |value| + it "accepts #{value} (#{value.class}) as a value" do + resource[parameter] = value + expect(resource[parameter]).to eq(false) + end + end + + it 'does not accept "foo" as a value' do + expect { resource[parameter] = 'foo' }.to raise_error(%r{Invalid value "foo"}) + end +end + +shared_examples 'a parameter that accepts only string values' do |parameter| + it 'accepts a string value' do + resource[parameter] = 'foo' + expect(resource[parameter]).to eq('foo') + end + + it 'does not accept an array value' do + expect { resource[parameter] = ['foo', 'bar'] }.to raise_error(%r{must be a String}) + end + + it 'does not accept a hash value' do + expect { resource[parameter] = { foo: 'bar' } }.to raise_error(%r{must be a String}) + end + + it 'does not accept an integer value' do + expect { resource[parameter] = 9001 }.to raise_error(%r{must be a String}) + end + + it 'does not accept a boolean true value' do + expect { resource[parameter] = true }.to raise_error(%r{must be a String}) + end + + it 'does not accept a boolean false value' do + expect { resource[parameter] = false }.to raise_error(%r{must be a String}) + end +end diff --git a/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb b/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb deleted file mode 100644 index 4815b9384..000000000 --- a/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb +++ /dev/null @@ -1,157 +0,0 @@ -require 'spec_helper' - -describe 'concat::fragment', :type => :define do - - shared_examples 'fragment' do |title, params| - params = {} if params.nil? - - p = { - :content => nil, - :source => nil, - :order => 10, - }.merge(params) - - let(:title) { title } - let(:params) { params } - let(:pre_condition) do - "concat{ '#{p[:target]}': }" - end - - it do - should contain_concat(p[:target]) - should contain_concat_file(p[:target]) - should contain_concat_fragment(title) - end - end - - context 'title' do - ['0', '1', 'a', 'z'].each do |title| - it_behaves_like 'fragment', title, { - :target => '/etc/motd', - :content => "content for #{title}" - } - end - end # title - - context 'target =>' do - ['./etc/motd', 'etc/motd', 'motd_header'].each do |target| - context target do - it_behaves_like 'fragment', target, { - :target => '/etc/motd', - :content => "content for #{target}" - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :target => false }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'target' expects a .*String.*/) - end - end - end # target => - - context 'content =>' do - ['', 'ashp is our hero'].each do |content| - context content do - it_behaves_like 'fragment', 'motd_header', { - :content => content, - :target => '/etc/motd', - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :content => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'content' expects a .*String.*/ ) - end - end - end # content => - - context 'source =>' do - ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source| - context source do - it_behaves_like 'fragment', 'motd_header', { - :source => source, - :target => '/etc/motd', - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :source => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'source' expects a .*String.*Array.*/) - end - end - end # source => - - context 'order =>' do - ['', '42', 'a', 'z'].each do |order| - context '\'\'' do - it_behaves_like 'fragment', 'motd_header', { - :order => order, - :target => '/etc/motd', - } - end - end - - context 'false' do - let(:title) { 'motd_header' } - let(:params) {{ :order => false, :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*Boolean.*/) - end - end - - context '123:456' do - let(:title) { 'motd_header' } - let(:params) {{ :order => '123:456', :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) - end - end - context '123/456' do - let(:title) { 'motd_header' } - let(:params) {{ :order => '123/456', :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) - end - end - context '123\n456' do - let(:title) { 'motd_header' } - let(:params) {{ :order => "123\n456", :target => '/etc/motd' }} - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) - end - end - end # order => - - context 'more than one content source' do - context 'source and content' do - let(:title) { 'motd_header' } - let(:params) do - { - :target => '/etc/motd', - :source => '/foo', - :content => 'bar', - } - end - - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Can\'t use \'source\' and \'content\' at the same time/m) - end - end - end # more than one content source -end diff --git a/3rdparty/modules/concat/spec/unit/defines/concat_spec.rb b/3rdparty/modules/concat/spec/unit/defines/concat_spec.rb deleted file mode 100644 index ca698afde..000000000 --- a/3rdparty/modules/concat/spec/unit/defines/concat_spec.rb +++ /dev/null @@ -1,355 +0,0 @@ -require 'spec_helper' - -describe 'concat', :type => :define do - - shared_examples 'concat' do |title, params, id| - params = {} if params.nil? - id = 'root' if id.nil? - - # default param values - p = { - :ensure => 'present', - :path => title, - :owner => nil, - :group => nil, - :mode => '0644', - :warn => false, - :backup => 'puppet', - :replace => true, - }.merge(params) - - file_defaults = { - :backup => p[:backup], - } - - let(:title) { title } - let(:params) { params } - let(:facts) do - { - :id => id, - :osfamily => 'Debian', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - :kernel => 'Linux', - :is_pe => false, - } - end - - if p[:ensure] == 'present' - it do - should contain_concat(title).with(file_defaults.merge({ - :ensure => 'present', - :owner => p[:owner], - :group => p[:group], - :mode => p[:mode], - :path => p[:path], - :backup => p[:backup], - :replace => p[:replace], - :selinux_ignore_defaults => p[:selinux_ignore_defaults], - :selrange => p[:selrange], - :selrole => p[:selrole], - :seltype => p[:seltype], - :seluser => p[:seluser], - })) - end - else - it do - should contain_concat(title).with(file_defaults.merge({ - :ensure => 'absent', - :backup => p[:backup], - })) - end - end - end - - context 'title' do - context 'without path param' do - # title/name is the default value for the path param. therefore, the - # title must be an absolute path unless path is specified - ['/foo', '/foo/bar', '/foo/bar/baz'].each do |title| - context title do - it_behaves_like 'concat', '/etc/foo.bar' - end - end - - ['./foo', 'foo', 'foo/bar'].each do |title| - context title do - let(:title) { title } - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Stdlib::Unixpath/) - end - end - end - end - - context 'with path param' do - ['/foo', 'foo', 'foo/bar'].each do |title| - context title do - it_behaves_like 'concat', title, { :path => '/etc/foo.bar' } - end - end - end - - context 'with special characters in title' do - ['foo:bar', 'foo*bar', 'foo(bar)', 'foo@bar'].each do |title| - context title do - it_behaves_like 'concat', title, { :path => '/etc/foo.bar' } - end - end - end - end # title => - - context 'as non-root user' do - it_behaves_like 'concat', '/etc/foo.bar', {}, 'bob' - end - - context 'ensure =>' do - ['present', 'absent'].each do |ens| - context ens do - it_behaves_like 'concat', '/etc/foo.bar', { :ensure => ens } - end - end - - context 'invalid' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :ensure => 'invalid' }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /expects a match for Enum\['absent', 'present'\]/) - end - end - end # ensure => - - context 'path =>' do - context '/foo' do - it_behaves_like 'concat', '/etc/foo.bar', { :path => '/foo' } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :path => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Stdlib::Unixpath/) - end - end - - ['./foo', 'foo', 'foo/bar'].each do |path| - context path do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :path => path }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Stdlib::Unixpath/) - end - end - end - end # path => - - context 'owner =>' do - ['apenney',1000,'1001'].each do |owner| - context owner do - it_behaves_like 'concat', '/etc/foo.bar', { :owner => owner } - end - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :owner => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*String.*Boolean.*/) - end - end - end # owner => - - context 'group =>' do - ['apenney',1000,'1001'].each do |group| - context group do - it_behaves_like 'concat', '/etc/foo.bar', { :group => group } - end - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :group => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*String.*Boolean.*/) - end - end - end # group => - - context 'mode =>' do - context '1755' do - it_behaves_like 'concat', '/etc/foo.bar', { :mode => '1755' } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :mode => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'mode' expects .*String.*/) - end - end - end # mode => - - context 'warn =>' do - [true, false, '# foo'].each do |warn| - context warn do - it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } - end - end - - context '(stringified boolean)' do - ['true', 'yes', 'on', 'false', 'no', 'off'].each do |warn| - context warn do - it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } - - it 'should create a warning' do - skip('rspec-puppet support for testing warning()') - end - end - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :warn => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'warn' expects .*Boolean.*String.*/) - end - end - end # warn => - - context 'show_diff =>' do - [true, false].each do |show_diff| - context show_diff do - it_behaves_like 'concat', '/etc/foo.bar', { :show_diff => show_diff } - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :show_diff => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'show_diff' expects .*Boolean.*/) - end - end - end # show_diff => - - context 'backup =>' do - ['reverse',false,true].each do |backup| - context "#{backup}" do - it_behaves_like 'concat', '/etc/foo.bar', { :backup => backup } - end - end - - context 'true' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :backup => [] }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'backup' expects .*Boolean.*String.*/) - end - end - end # backup => - - context 'replace =>' do - [true, false].each do |replace| - context replace do - it_behaves_like 'concat', '/etc/foo.bar', { :replace => replace } - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :replace => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'replace' expects .*Boolean.*/) - end - end - end # replace => - - context 'order =>' do - ['alpha', 'numeric'].each do |order| - context order do - it_behaves_like 'concat', '/etc/foo.bar', { :order => order } - end - end - - context 'invalid' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :order => 'invalid' }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /expects a match for Enum\['alpha', 'numeric'\]/) - end - end - end # order => - - context 'ensure_newline =>' do - [true, false].each do |ensure_newline| - context 'true' do - it_behaves_like 'concat', '/etc/foo.bar', { :ensure_newline => ensure_newline} - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :ensure_newline => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'ensure_newline' expects a Boolean value/) - end - end - end # ensure_newline => - - context 'validate_cmd =>' do - context '/usr/bin/test -e %' do - it_behaves_like 'concat', '/etc/foo.bar', { :validate_cmd => '/usr/bin/test -e %' } - end - - [ 1234, true ].each do |cmd| - context cmd do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :validate_cmd => cmd }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter 'validate_cmd' expects.*String.*/) - end - end - end - end # validate_cmd => - - context 'selinux_ignore_defaults =>' do - let(:title) { '/etc/foo.bar' } - - [true, false].each do |v| - context v do - it_behaves_like 'concat', '/etc/foo.bar', { :selinux_ignore_defaults => v } - end - end - - context '123' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ :selinux_ignore_defaults => 123 }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*Boolean.*/) - end - end - end # selinux_ignore_defaults => - - [ - :selrange, - :selrole, - :seltype, - :seluser, - ].each do |p| - context " #{p} =>" do - let(:title) { '/etc/foo.bar' } - - context 'foo' do - it_behaves_like 'concat', '/etc/foo.bar', { p => 'foo' } - end - - context 'false' do - let(:title) { '/etc/foo.bar' } - let(:params) {{ p => false }} - it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /parameter '#{p}' expects.*String.*/) - end - end - end # #{p} => - end -end diff --git a/3rdparty/modules/concat/spec/unit/type/concat_file_spec.rb b/3rdparty/modules/concat/spec/unit/type/concat_file_spec.rb index ee6992be3..892ff4f3b 100644 --- a/3rdparty/modules/concat/spec/unit/type/concat_file_spec.rb +++ b/3rdparty/modules/concat/spec/unit/type/concat_file_spec.rb @@ -1,25 +1,5 @@ require 'spec_helper' -shared_examples 'Puppet::Parameter::Boolean' do |parameter| - [true, :true, 'true', :yes, 'yes'].each do |value| - it "accepts #{value} (#{value.class}) as a value" do - resource[parameter] = value - expect(resource[parameter]).to eq(true) - end - end - - [false, :false, 'false', :no, 'no'].each do |value| - it "accepts #{value} (#{value.class}) as a value" do - resource[parameter] = value - expect(resource[parameter]).to eq(false) - end - end - - it 'does not accept "foo" as a value' do - expect { resource[parameter] = 'foo' }.to raise_error(%r{Invalid value "foo"}) - end -end - describe Puppet::Type.type(:concat_file) do let(:resource) { described_class.new(name: '/foo/bar') } @@ -34,11 +14,35 @@ describe Puppet::Type.type(:concat_file) do describe 'parameter :path' do it 'does not accept unqualified paths' do expect { resource[:path] = 'foo' }.to raise_error( - %r{File paths must be fully qualified} + %r{File paths must be fully qualified}, ) end end + describe 'parameter :owner' do + subject { described_class.attrclass(:owner) } + + it 'inherits Puppet::Type::File::Owner' do + is_expected.to be < Puppet::Type::File::Owner + end + end + + describe 'parameter :group' do + subject { described_class.attrclass(:group) } + + it 'inherits Puppet::Type::File::Group' do + is_expected.to be < Puppet::Type::File::Group + end + end + + describe 'parameter :mode' do + subject { described_class.attrclass(:mode) } + + it 'inherits Puppet::Type::File::Mode' do + is_expected.to be < Puppet::Type::File::Mode + end + end + describe 'parameter :order' do it 'accepts "alpha" as a value' do resource[:order] = 'alpha' @@ -55,6 +59,39 @@ describe Puppet::Type.type(:concat_file) do end end + describe 'parameter :backup' do + it 'accepts true (TrueClass) as a value' do + resource[:backup] = true + expect(resource[:backup]).to eq(true) + end + + it 'accepts false (FalseClass) as a value' do + resource[:backup] = false + expect(resource[:backup]).to eq(false) + end + + it 'accepts "foo" as a value' do + resource[:backup] = 'foo' + expect(resource[:backup]).to eq('foo') + end + end + + describe 'parameter :selrange' do + it_behaves_like 'a parameter that accepts only string values', :selrange + end + + describe 'parameter :selrole' do + it_behaves_like 'a parameter that accepts only string values', :selrole + end + + describe 'parameter :seltype' do + it_behaves_like 'a parameter that accepts only string values', :seltype + end + + describe 'parameter :seluser' do + it_behaves_like 'a parameter that accepts only string values', :seluser + end + describe 'parameter :replace' do it_behaves_like 'Puppet::Parameter::Boolean', :replace end @@ -62,4 +99,52 @@ describe Puppet::Type.type(:concat_file) do describe 'parameter :ensure_newline' do it_behaves_like 'Puppet::Parameter::Boolean', :ensure_newline end + + describe 'parameter :show_diff' do + it_behaves_like 'Puppet::Parameter::Boolean', :show_diff + end + + describe 'parameter :selinux_ignore_defaults' do + it_behaves_like 'Puppet::Parameter::Boolean', :selinux_ignore_defaults + end + + describe 'parameter :force' do + it_behaves_like 'Puppet::Parameter::Boolean', :force + end + + describe 'parameter :format' do + it 'accepts "plain" as a value' do + resource[:format] = 'plain' + expect(resource[:format]).to eq(:plain) + end + + it 'accepts "yaml" as a value' do + resource[:format] = 'yaml' + expect(resource[:format]).to eq(:yaml) + end + + it 'accepts "json" as a value' do + resource[:format] = 'json' + expect(resource[:format]).to eq(:json) + end + + it 'accepts "json-array" as a value' do + resource[:format] = 'json-array' + expect(resource[:format]).to eq(:'json-array') + end + + it 'accepts "json-pretty" as a value' do + resource[:format] = 'json-pretty' + expect(resource[:format]).to eq(:'json-pretty') + end + + it 'accepts "json-array-pretty" as a value' do + resource[:format] = 'json-array-pretty' + expect(resource[:format]).to eq(:'json-array-pretty') + end + + it 'does not accept "bar" as a value' do + expect { resource[:format] = 'bar' }.to raise_error(%r{Invalid value "bar"}) + end + end end diff --git a/3rdparty/modules/concat/spec/unit/type/concat_fragment_spec.rb b/3rdparty/modules/concat/spec/unit/type/concat_fragment_spec.rb new file mode 100644 index 000000000..5a2700c29 --- /dev/null +++ b/3rdparty/modules/concat/spec/unit/type/concat_fragment_spec.rb @@ -0,0 +1,111 @@ +require 'spec_helper' + +describe Puppet::Type.type(:concat_fragment) do + let(:resource) do + described_class.new(name: 'foo', target: 'bar', content: 'baz') + end + + describe 'key attributes' do + let(:subject) { described_class.key_attributes } + + it 'contain only :name' do + is_expected.to eq([:name]) + end + end + + describe 'parameter :target' do + it_behaves_like 'a parameter that accepts only string values', :target + end + + describe 'parameter :content' do + it_behaves_like 'a parameter that accepts only string values', :content + end + + describe 'parameter :source' do + it 'accepts a string value' do + resource[:source] = 'foo' + expect(resource[:source]).to eq('foo') + end + + it 'accepts an array value' do + resource[:source] = ['foo', 'bar'] + expect(resource[:source]).to eq(['foo', 'bar']) + end + + it 'does not accept a hash value' do + expect { resource[:source] = { foo: 'bar' } }.to raise_error(%r{must be a String or Array}) + end + + it 'does not accept an integer value' do + expect { resource[:source] = 9001 }.to raise_error(%r{must be a String or Array}) + end + + it 'does not accept a boolean true value' do + expect { resource[:source] = true }.to raise_error(%r{must be a String or Array}) + end + + it 'does not accept a boolean false value' do + expect { resource[:source] = false }.to raise_error(%r{must be a String or Array}) + end + end + + describe 'parameter :order' do + it 'accepts a string value' do + resource[:order] = 'foo' + expect(resource[:order]).to eq('foo') + end + + it 'accepts an integer value' do + resource[:order] = 9001 + expect(resource[:order]).to eq(9001) + end + + it 'does not accept an array value' do + expect { resource[:order] = ['foo', 'bar'] }.to raise_error(%r{is not a string or integer}) + end + + it 'does not accept a hash value' do + expect { resource[:order] = { foo: 'bar' } }.to raise_error(%r{is not a string or integer}) + end + + it 'does not accept a boolean true value' do + expect { resource[:order] = true }.to raise_error(%r{is not a string or integer}) + end + + it 'does not accept a boolean false value' do + expect { resource[:order] = false }.to raise_error(%r{is not a string or integer}) + end + + it 'does not accept a string with ":" in it/' do + expect { resource[:order] = ':foo' }.to raise_error(%r{Order cannot contain}) + end + + it 'does not accept a string with "\n" in it/' do + expect { resource[:order] = "\nfoo" }.to raise_error(%r{Order cannot contain}) + end + + it 'does not accept a string with "/" in it/' do + expect { resource[:order] = '/foo' }.to raise_error(%r{Order cannot contain}) + end + end + + context 'without a value set for :target or :tag' do + it 'throws an error' do + expect { described_class.new(name: 'foo', content: 'baz') }.to raise_error(%r{No 'target' or 'tag' set}) + end + end + + context 'without a value set for both :content and :source' do + it 'throws an error' do + expect { described_class.new(name: 'foo', target: 'bar') }.to raise_error(%r{Set either 'source' or 'content'}) + end + end + + context 'with a value set for both :content and :source' do + it 'throws an error' do + expect { + described_class.new(name: 'foo', target: 'bar', content: 'baz', source: 'qux') + }.to raise_error(%r{Can't use 'source' and 'content' at the same time}) + end + end +end diff --git a/3rdparty/modules/stdlib/CHANGELOG.md b/3rdparty/modules/stdlib/CHANGELOG.md index 5842991e0..18c70e775 100644 --- a/3rdparty/modules/stdlib/CHANGELOG.md +++ b/3rdparty/modules/stdlib/CHANGELOG.md @@ -1,39 +1,78 @@ # Change log -All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](http://semver.org). +All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). -## Supported Release 5.2.0 -### Summary -This is a moderate release made in order to roll up various new features. +## [v6.1.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.1.0) (2019-09-19) -#### Fixed -- `ensure-packages()` duplicate checking now works as it should. +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.0.0...v6.1.0) -#### Added -- (MODULES-7024) - Support for 20-octet MAC addresses added. -- `extname()` function added - This function returns the extensionof whatever file it is passed. -- (MODULES-8273) - Unquoted classes can now be used with the `defined_with_params()` function. -- (MODULES-8137) - Support has been added for SLES 15. -- (MODULES-8404) - `Stdlib::Filesource` has been relaxed and now supports custom mount points. -- (MODULES-8322) - IPs values of `0.0.0.0/0` and `::/0` are now considered to be valid. -- New type `Stdlib::IP::Address::V6::CIDR` has been created. - -## Supported Release 5.1.0 -### Summary -This is a moderate release which adds support for Puppet 6. +### Added -#### Fixed -- Handle nil in `delete_undef_values()` function -- Readme error regarding concatenation fixed. -- Fix to the `pick()` function documentation. +- \(MODULES-9915\) Add type aliases for cloud object store uris [\#1048](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1048) ([hooten](https://github.com/hooten)) +- FM-8411 - add support for debian10 [\#1045](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1045) ([lionce](https://github.com/lionce)) +- \(FM-8230\) Convert testing to litmus [\#1031](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1031) ([eimlav](https://github.com/eimlav)) +- \(FM-8160\) Add Windows Server 2019 support [\#1025](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1025) ([eimlav](https://github.com/eimlav)) +- \(FM-8048\) Add RedHat 8 support [\#1022](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1022) ([eimlav](https://github.com/eimlav)) +- \(MODULES-9049\) Add type alias for 'yes' and 'no'. [\#1017](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1017) ([ghoneycutt](https://github.com/ghoneycutt)) +- add Stdlib::Syslogfacility type [\#1005](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1005) ([bastelfreak](https://github.com/bastelfreak)) -#### Added -- Support added for Puppet 6 +### Fixed + +- fix lib/puppet/parser/functions/fqdn\_rand\_string.rb:21: syntax error [\#1029](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1029) ([pulecp](https://github.com/pulecp)) +- Limit the maximum array size produced by range\(\). [\#1023](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1023) ([mbaynton](https://github.com/mbaynton)) + +## [v6.0.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v6.0.0) (2019-05-10) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/5.2.0...v6.0.0) + +### Changed + +- pdksync - \(MODULES-8444\) - Raise lower Puppet bound [\#1011](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1011) ([david22swan](https://github.com/david22swan)) +- \(MODULES-8760\) Add iterative feature to merge\(\) function [\#1008](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1008) ([hlindberg](https://github.com/hlindberg)) + +### Added + +- Add a stdlib::ip\_in\_range\(\) function [\#1003](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1003) ([iglov](https://github.com/iglov)) + +## [5.2.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/5.2.0) (2019-01-17) -## Supported Release 5.0.0 +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/5.1.0...5.2.0) + +### Added + +- \(MODULES-8404\) - Relax `Stdlib::Filesource` type [\#981](https://github.com/puppetlabs/puppetlabs-stdlib/pull/981) ([alexjfisher](https://github.com/alexjfisher)) +- Creates new type Stdlib::IP::Address::V6::CIDR [\#980](https://github.com/puppetlabs/puppetlabs-stdlib/pull/980) ([timhughes](https://github.com/timhughes)) +- \(MODULES-8137\) - Addition of support for SLES 15 [\#978](https://github.com/puppetlabs/puppetlabs-stdlib/pull/978) ([david22swan](https://github.com/david22swan)) +- \(MODULES-8322\) Consider IPs with /0 as valid [\#975](https://github.com/puppetlabs/puppetlabs-stdlib/pull/975) ([simondeziel](https://github.com/simondeziel)) +- Add a function to compare the OS version [\#972](https://github.com/puppetlabs/puppetlabs-stdlib/pull/972) ([ekohl](https://github.com/ekohl)) +- \(MODULES-8273\) - Make unquoted classes useable [\#971](https://github.com/puppetlabs/puppetlabs-stdlib/pull/971) ([baurmatt](https://github.com/baurmatt)) +- add Function extname\(\) [\#949](https://github.com/puppetlabs/puppetlabs-stdlib/pull/949) ([cocker-cc](https://github.com/cocker-cc)) +- \(MODULES-7024\) Add 20-octet MAC addresses [\#905](https://github.com/puppetlabs/puppetlabs-stdlib/pull/905) ([ananace](https://github.com/ananace)) + +### Fixed + +- pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#979](https://github.com/puppetlabs/puppetlabs-stdlib/pull/979) ([tphoney](https://github.com/tphoney)) +- fix ensure\_packages duplicate checking [\#969](https://github.com/puppetlabs/puppetlabs-stdlib/pull/969) ([netzvieh](https://github.com/netzvieh)) + +## [5.1.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/5.1.0) (2018-09-28) + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/5.0.0...5.1.0) + +### Added + +- pdksync - \(MODULES-6805\) metadata.json shows support for puppet 6 [\#958](https://github.com/puppetlabs/puppetlabs-stdlib/pull/958) ([tphoney](https://github.com/tphoney)) +- \(maint\) Convert from mocking with mocha to rspec-mocks [\#948](https://github.com/puppetlabs/puppetlabs-stdlib/pull/948) ([rodjek](https://github.com/rodjek)) + +### Fixed + +- \(FM-7388\) - Fixing unit tests for puppet 4, 5 and 6 [\#962](https://github.com/puppetlabs/puppetlabs-stdlib/pull/962) ([tphoney](https://github.com/tphoney)) +- Fix `pick` function docs [\#955](https://github.com/puppetlabs/puppetlabs-stdlib/pull/955) ([alexjfisher](https://github.com/alexjfisher)) +- \(MODULES-7768\) Handle nil in delete\_undef\_values\(\) function [\#954](https://github.com/puppetlabs/puppetlabs-stdlib/pull/954) ([hlindberg](https://github.com/hlindberg)) +- Update docs for 'concat' to be correct [\#950](https://github.com/puppetlabs/puppetlabs-stdlib/pull/950) ([rhowe-gds](https://github.com/rhowe-gds)) + +## 5.0.0 ### Summary -This is a major release which removes support for the Scientific 5 and Debian 7 OS, as well as a removal of the `Stdlib::(Ipv4|IPv6|Ip_address)` data types in favour of `Stdlib::IP::*`. +This is a major release which removes support for the Scientific 5 and Debian 7 OS, as well as a removal of the `Stdlib::(Ipv4|IPv6|Ip_address)` data types in favour of `Stdlib::IP::*`. **In addition it contains a substantial piece of work centered around updating functions that have now been migrated into Puppet itself. Please note that this will be the last major release to support Puppet 2 and Puppet 3 and that they will soon be removed.** @@ -497,7 +536,7 @@ Includes the addition of several new functions and considerable improvements to #### Bugfixes - Fix backwards compatibility from an improvement to the parseyaml function -- Renaming of load_module_metadata test to include _spec.rb +- Renaming of load_module_metadata test to include \_spec.rb - Fix root_home fact on AIX 5.x, now '-c' rather than '-C' - Fixed Gemfile to work with ruby 1.8.7 @@ -1098,3 +1137,6 @@ This is a supported release ##### 0.1.1 2011-05-24 Jeff McCune * Add stdlib::stages class with a standard set of stages + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/3rdparty/modules/stdlib/Gemfile b/3rdparty/modules/stdlib/Gemfile index b7d80c3e5..0e395e7ec 100644 --- a/3rdparty/modules/stdlib/Gemfile +++ b/3rdparty/modules/stdlib/Gemfile @@ -17,21 +17,18 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') -end -group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') + gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') + gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/3rdparty/modules/stdlib/README.md b/3rdparty/modules/stdlib/README.md index e2e9ee668..f21f34f44 100644 --- a/3rdparty/modules/stdlib/README.md +++ b/3rdparty/modules/stdlib/README.md @@ -2,23 +2,24 @@ #### Table of Contents -1. [Module Description - What the module does and why it is useful](#module-description) -1. [Setup - The basics of getting started with stdlib](#setup) -1. [Usage - Configuration options and additional functionality](#usage) -1. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - 1. [Classes](#classes) - 1. [Defined Types](#defined-types) +1. [Overview](#overview) +1. [Module Description](#module-description) +1. [Setup](#setup) +1. [Usage](#usage) +1. [Reference](#reference) 1. [Data Types](#data-types) 1. [Facts](#facts) - 1. [Functions](#functions) -1. [Limitations - OS compatibility, etc.](#limitations) -1. [Development - Guide for contributing to the module](#development) +1. [Limitations](#limitations) +1. [Development](#development) 1. [Contributors](#contributors) - +## Overview + +This module provides a standard library of resources for Puppet modules. + ## Module Description -This module provides a standard library of resources for Puppet modules. Puppet modules make heavy use of this standard library. The stdlib module adds the following resources to Puppet: +Puppet modules make heavy use of this standard library. The stdlib module adds the following resources to Puppet: * Stages * Facts @@ -29,14 +30,12 @@ This module provides a standard library of resources for Puppet modules. Puppet > *Note:* As of version 3.7, Puppet Enterprise no longer includes the stdlib module. If you're running Puppet Enterprise, you should install the most recent release of stdlib for compatibility with Puppet modules. - ## Setup [Install](https://puppet.com/docs/puppet/latest/modules_installing.html) the stdlib module to add the functions, facts, and resources of this standard library to Puppet. -If you are authoring a module that depends on stdlib, be sure to [specify dependencies](https://puppet.com/docs/puppet/latest/modules_metadata.html#specifying-dependencies-in-modules) in your metadata.json. +If you are authoring a module that depends on stdlib, be sure to [specify dependencies](https://puppet.com/docs/puppet/latest/modules_installing.html) in your metadata.json. - ## Usage Most of stdlib's features are automatically loaded by Puppet. To use standardized run stages in Puppet, declare this class in your manifest with `include stdlib`. @@ -63,220 +62,9 @@ node default { } ``` - ## Reference -* [Public classes](#public-classes) -* [Private classes](#private-classes) -* [Defined types](#defined-types) -* [Data types](#data-types) -* [Facts](#facts) -* [Functions](#functions) - - -### Classes - - -#### Public classes - -The `stdlib` class has no parameters. - - -#### Private classes - -* `stdlib::stages`: Manages a standard set of run stages for Puppet. - - -### Defined types - -#### `file_line` - -Ensures that a given line is contained within a file. The implementation matches the full line, including whitespace at the beginning and end. If the line is not contained in the given file, Puppet appends the line to the end of the file to ensure the desired state. Multiple resources can be declared to manage multiple lines in the same file. - -Example: - -```puppet -file_line { 'sudo_rule': - path => '/etc/sudoers', - line => '%sudo ALL=(ALL) ALL', -} - -file_line { 'sudo_rule_nopw': - path => '/etc/sudoers', - line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', -} -``` - -In the example above, Puppet ensures that both of the specified lines are contained in the file `/etc/sudoers`. - -Match Example: - -```puppet -file_line { 'bashrc_proxy': - ensure => present, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', -} -``` - -In the example above, `match` looks for a line beginning with 'export' followed by 'HTTP_PROXY' and replaces it with the value in line. - -Match Example: - -```puppet -file_line { 'bashrc_proxy': - ensure => present, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', - append_on_no_match => false, -} -``` - -In this code example, `match` looks for a line beginning with export followed by 'HTTP_PROXY' and replaces it with the value in line. If a match is not found, then no changes are made to the file. - -Examples of `ensure => absent`: - -This type has two behaviors when `ensure => absent` is set. - -The first is to set `match => ...` and `match_for_absence => true`. Match looks for a line beginning with 'export', followed by 'HTTP_PROXY', and then deletes it. If multiple lines match, an error is raised unless the `multiple => true` parameter is set. - -The `line => ...` parameter in this example would be accepted but ignored. - -For example: - -```puppet -file_line { 'bashrc_proxy': - ensure => absent, - path => '/etc/bashrc', - match => '^export\ HTTP_PROXY\=', - match_for_absence => true, -} -``` - -The second way of using `ensure => absent` is to specify a `line => ...` and no match. When ensuring lines are absent, the default behavior is to remove all lines matching. This behavior can't be disabled. - -For example: - -```puppet -file_line { 'bashrc_proxy': - ensure => absent, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', -} -``` - - -Encoding example: - -```puppet -file_line { "XScreenSaver": - ensure => present, - path => '/root/XScreenSaver' - line => "*lock: 10:00:00", - match => '^*lock:', - encoding => "iso-8859-1", -} -``` - -Files with special characters that are not valid UTF-8 give the error message "Invalid byte sequence in UTF-8". In this case, determine the correct file encoding and specify it with the `encoding` attribute. - -**Autorequires:** If Puppet is managing the file that contains the line being managed, the `file_line` resource autorequires that file. - -**Parameters** - -All parameters are optional, unless otherwise noted. - -##### `after` - -Specifies the line after which Puppet adds any new lines using a regular expression. (Existing lines are added in place.) - -Values: String containing a regex. - -Default value: `undef`. - -##### `encoding` - -Specifies the correct file encoding. - -Values: String specifying a valid Ruby character encoding. - -Default: 'UTF-8'. - -##### `ensure` - -Specifies whether the resource is present. - -Values: 'present', 'absent'. - -Default value: 'present'. - -##### `line` - -**Required.** - -Sets the line to be added to the file located by the `path` parameter. - -Values: String. - -##### `match` - -Specifies a regular expression to compare against existing lines in the file; if a match is found, it is replaced rather than adding a new line. - -Values: String containing a regex. - -Default value: `undef`. - - -##### `match_for_absence` - -Specifies whether a match should be applied when `ensure => absent`. If set to `true` and match is set, the line that matches is deleted. If set to `false` (the default), match is ignored when `ensure => absent` and the value of `line` is used instead. Ignored when `ensure => present`. - -Boolean. - -Default value: `false`. - -##### `multiple` - -Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file_line to replace one or more lines. - -Values: `true`, `false`. - -Default value: `false`. - - -##### `name` - -Specifies the name to use as the identity of the resource. If you want the resource namevar to differ from the supplied `title` of the resource, specify it with `name`. - -Values: String. - -Default value: The value of the title. - -##### `path` - -**Required.** - -Specifies the file in which Puppet ensures the line specified by `line`. - -Value: String specifying an absolute path to the file. - -##### `replace` - -Specifies whether the resource overwrites an existing line that matches the `match` parameter when `line` does not otherwise exist. - -If set to `false` and a line is found matching the `match` parameter, the line is not placed in the file. - -Boolean. - -Default value: `true`. - -##### `replace_all_matches_not_matching_line` - -Replaces all lines matched by `match` parameter, even if `line` already exists in the file. - -Default value: `false`. +For information on the classes and types, see the [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/REFERENCE.md). ### Data types @@ -323,7 +111,7 @@ true false ``` -#### `Stdlib::Httpsurl` +#### `Stdlib::HTTPSUrl` Matches HTTPS URLs. It is a case insensitive match. @@ -341,7 +129,7 @@ Unacceptable input example: httds://notquiteright.org` ``` -#### `Stdlib::Httpurl` +#### `Stdlib::HTTPUrl` Matches both HTTPS and HTTP URLs. It is a case insensitive match. @@ -670,2475 +458,117 @@ Match an IPv6 address which may contain `::` used to compress zeros as documente Match an IPv6 address in the CIDR format. It will only match if the address contains an address prefix (for example, it will match 'FF01:0:0:0:0:0:0:101/32', 'FF01::101/60', '::/0', but not 'FF01:0:0:0:0:0:0:101', 'FF01::101', '::'). - -### Facts - -#### `package_provider` - -Returns the default provider Puppet uses to manage packages on this system. - -#### `is_pe` - -Returns whether Puppet Enterprise is installed. Does not report anything on platforms newer than PE 3.x. - -#### `pe_version` - -Returns the version of Puppet Enterprise installed. Does not report anything on platforms newer than PE 3.x. - -#### `pe_major_version` - -Returns the major version Puppet Enterprise that is installed. Does not report anything on platforms newer than PE 3.x. - -#### `pe_minor_version` - -Returns the minor version of Puppet Enterprise that is installed. Does not report anything on platforms newer than PE 3.x. - -#### `pe_patch_version` - -Returns the patch version of Puppet Enterprise that is installed. - -#### `puppet_vardir` - -Returns the value of the Puppet vardir setting for the node running Puppet or Puppet agent. - -#### `puppet_environmentpath` - -Returns the value of the Puppet environment path settings for the node running Puppet or Puppet agent. - -#### `puppet_server` - -Returns the Puppet agent's `server` value, which is the hostname of the Puppet master with which the agent should communicate. - -#### `root_home` - -Determines the root home directory. - -Determines the root home directory, which depends on your operating system. Generally this is '/root'. - -#### `service_provider` - -Returns the default provider Puppet uses to manage services on this system - - -### Functions - -#### `abs` - -**Deprecated:** This function has been replaced with a built-in [`abs`](https://puppet.com/docs/puppet/latest/function.html#abs) function as of Puppet 6.0.0. - -Returns the absolute value of a number. For example, '-34.56' becomes '34.56'. - -Argument: A single argument of either an integer or float value. - -*Type*: rvalue. - -#### `any2array` - -Converts any object to an array containing that object. Converts empty argument lists are to empty arrays. Hashes are converted to arrays of alternating keys and values. Arrays are not touched. - -Since Puppet 5.0.0, you can create new values of almost any datatype using the type system — you can use the built-in [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) function to create a new array: - - $hsh = {'key' => 42, 'another-key' => 100} - notice(Array($hsh)) - -Would notice `[['key', 42], ['another-key', 100]]` +#### `Stdlib::ObjectStore` -The array data type also has a special mode to "create an array if not already an array": +Matches cloud object store uris. - notice(Array({'key' => 42, 'another-key' => 100}, true)) - -Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being transformed into an array. - -*Type*: rvalue. - -#### `any2bool` - -Converts any object to a Boolean: - -* Strings such as 'Y', 'y', '1', 'T', 't', 'TRUE', 'yes', 'true' return `true`. -* Strings such as '0', 'F', 'f', 'N', 'n', 'FALSE', 'no', 'false' return `false`. -* Booleans return their original value. -* A number (or a string representation of a number) greater than 0 returns `true`, otherwise `false`. -* An undef value returns `false`. -* Anything else returns `true`. - -See the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) - -*Type*: rvalue. - -#### `assert_private` - -Sets the current class or definition as private. Calling the class or defined type from outside the current module fails. +Acceptable input example: -For example, `assert_private()` called in class `foo::bar` outputs the following message if class is called from outside module `foo`: `Class foo::bar is private.` +```shell +s3://mybucket/path/to/file -To specify the error message you want to use: +gs://bucket/file -```puppet -assert_private("You're not supposed to do that!") ``` +Valid values: cloud object store uris. -*Type*: statement. - -#### `base64` - -Converts a string to and from base64 encoding. Requires an `action` ('encode', 'decode') and either a plain or base64-encoded `string`, and an optional `method` ('default', 'strict', 'urlsafe'). - -For backward compatibility, `method` is set as `default` if not specified. - -> **Note**: This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. -Since Puppet 4.8.0, the `Binary` data type can be used to produce base 64 encoded strings. +#### `Stdlib::ObjectStore::GSUri` -See the built-in [`String.new`](https://puppet.com/docs/puppet/latest/function.html#binary-value-to-string) and [`Binary.new`](https://puppet.com/docs/puppet/latest/function.html#creating-a-binary) functions. +Matches Google Cloud object store uris. -See the built-in [`binary_file`](https://puppet.com/docs/puppet/latest/function.html#binary_file) function for reading a file with binary (non UTF-8) content. - - # encode a string as if it was binary - $encodestring = String(Binary('thestring', '%s')) - # decode a Binary assuming it is an UTF-8 String - $decodestring = String(Binary("dGhlc3RyaW5n"), "%s") - -**Examples:** - -```puppet -base64('encode', 'hello') -base64('encode', 'hello', 'default') -# return: "aGVsbG8=\n" - -base64('encode', 'hello', 'strict') -# return: "aGVsbG8=" - -base64('decode', 'aGVsbG8=') -base64('decode', 'aGVsbG8=\n') -base64('decode', 'aGVsbG8=', 'default') -base64('decode', 'aGVsbG8=\n', 'default') -base64('decode', 'aGVsbG8=', 'strict') -# return: "hello" - -base64('encode', 'https://puppetlabs.com', 'urlsafe') -# return: "aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==" - -base64('decode', 'aHR0cHM6Ly9wdXBwZXRsYWJzLmNvbQ==', 'urlsafe') -# return: "https://puppetlabs.com" -``` +Acceptable input example: -*Type*: rvalue. +```shell -#### `basename` +gs://bucket/file -Returns the `basename` of a path. An optional argument strips the extension. For example: +gs://bucket/path/to/file -```puppet -basename('/path/to/a/file.ext') => 'file.ext' -basename('relative/path/file.ext') => 'file.ext' -basename('/path/to/a/file.ext', '.ext') => 'file' ``` +Valid values: Google Cloud object store uris. -*Type*: rvalue. - -#### `bool2num` - -Converts a Boolean to a number. Converts values: - -* `false`, 'f', '0', 'n', and 'no' to 0. -* `true`, 't', '1', 'y', and 'yes' to 1. - -Argument: a single Boolean or string as an input. -Since Puppet 5.0.0, you can create values for almost any data type using the type system — you can use the built-in [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric), [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float) -functions to convert to numeric values: +#### `Stdlib::ObjectStore::S3Uri` - notice(Integer(false)) # Notices 0 - notice(Float(true)) # Notices 1.0 +Matches Amazon Web Services S3 object store uris. -*Type*: rvalue. - -#### `bool2str` +Acceptable input example: -Converts a Boolean to a string using optionally supplied arguments. The optional second and third arguments represent what true and false are converted to respectively. If only one argument is given, it is converted from a Boolean to a string containing `true` or `false`. +```shell +s3://bucket/file -*Examples:* +s3://bucket/path/to/file -```puppet -bool2str(true) => `true` -bool2str(true, 'yes', 'no') => 'yes' -bool2str(false, 't', 'f') => 'f' ``` +Valid values: Amazon Web Services S3 object store uris. -Arguments: Boolean. - -Since Puppet 5.0.0, you can create new values for almost any -data type using the type system — you can use the built-in -[`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string) -function to convert to String, with many different format options: - - notice(String(false)) # Notices 'false' - notice(String(true)) # Notices 'true' - notice(String(false, '%y')) # Notices 'yes' - notice(String(true, '%y')) # Notices 'no' - -*Type*: rvalue. - -#### `camelcase` - -**Deprecated:** This function has been replaced with a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) function as of Puppet 6.0.0. - -Converts the case of a string or all strings in an array to CamelCase (mixed case). - -Arguments: Either an array or string. Returns the same type of argument as it received, but in CamelCase form. - -*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - - *Type*: rvalue. - -#### `capitalize` - -**Deprecated:** This function has been replaced with a built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize) function as of Puppet 6.0.0. - -Capitalizes the first character of a string or array of strings and lowercases the remaining characters of each string. - -Arguments: either a single string or an array as an input. *Type*: rvalue. - -*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `ceiling` - -**Deprecated:** This function has been replaced with a built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function as of Puppet 6.0.0. - -Returns the smallest integer greater than or equal to the argument. - -Arguments: A single numeric value. - -*Type*: rvalue. - -#### `chomp` - -**Deprecated:** This function has been replaced with a built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function as of Puppet 6.0.0. - -Removes the record separator from the end of a string or an array of strings; for example, 'hello\n' becomes 'hello'. - -Arguments: a single string or array. - -*Type*: rvalue. - -#### `chop` - -**Deprecated:** This function has been replaced with a built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function as of Puppet 6.0.0. - -Returns a new string with the last character removed. If the string ends with '\r\n', both characters are removed. Applying `chop` to an empty string returns an empty string. To only remove record separators, use the `chomp` function. - -Arguments: A string or an array of strings as input. +#### `Stdlib::Syslogfacility` -*Type*: rvalue. +An enum that defines all syslog facilities defined in [RFC5424](https://tools.ietf.org/html/rfc5424). This is based on work in the [voxpupuli/nrpe](https://github.com/voxpupuli/puppet-nrpe/commit/5700fd4f5bfc3e237195c8833039f9ed1045cd6b) module. -#### `clamp` - -Keeps value within the range [Min, X, Max] by sort based on integer value (parameter order doesn't matter). Strings are converted and compared numerically. Arrays of values are flattened into a list for further handling. For example: - - * `clamp('24', [575, 187])` returns 187. - * `clamp(16, 88, 661)` returns 88. - * `clamp([4, 3, '99'])` returns 4. - -Arguments: strings, arrays, or numerics. - -Since Puppet 6.0.0, you can use built-in functions to get the same result: - - [$minval, $maxval, $value_to_clamp].sort[1] - -*Type*: rvalue. + +### Facts -#### `concat` +#### `package_provider` -Appends the contents of multiple arrays onto the first array given. For example: +Returns the default provider Puppet uses to manage packages on this system. - * `concat(['1','2','3'],'4')` returns ['1','2','3','4']. - * `concat(['1','2','3'],'4',['5','6','7'])` returns ['1','2','3','4','5','6','7']. +#### `is_pe` -Since Puppet 4.0, you can use the `+` operator for concatenation of arrays and merge of hashes, and the `<<` operator for appending: +Returns whether Puppet Enterprise is installed. Does not report anything on platforms newer than PE 3.x. - ['1','2','3'] + ['4','5','6'] + ['7','8','9'] # returns ['1','2','3','4','5','6','7','8','9'] - [1, 2, 3] << 4 # returns [1, 2, 3, 4] - [1, 2, 3] << [4, 5] # returns [1, 2, 3, [4, 5]] +#### `pe_version` -*Type*: rvalue. +Returns the version of Puppet Enterprise installed. Does not report anything on platforms newer than PE 3.x. -#### `convert_base` +#### `pe_major_version` -Converts a given integer or base 10 string representing an integer to a specified base, as a string. For example: +Returns the major version Puppet Enterprise that is installed. Does not report anything on platforms newer than PE 3.x. - * `convert_base(5, 2)` results in: '101' - * `convert_base('254', '16')` results in: 'fe' +#### `pe_minor_version` -Since Puppet 4.5.0, you can do this with the built-in [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string) function, with various formatting options: +Returns the minor version of Puppet Enterprise that is installed. Does not report anything on platforms newer than PE 3.x. - $binary_repr = String(5, '%b') # results in "101" - $hex_repr = String(254, '%x') # results in "fe" - $hex_repr = String(254, '%#x') # results in "0xfe" +#### `pe_patch_version` -#### `count` +Returns the patch version of Puppet Enterprise that is installed. -Takes an array as the first argument and an optional second argument. -It counts the number of elements in an array that is equal to the second argument. -If called with only an array, it counts the number of elements that are not nil/undef/empty-string. +#### `puppet_vardir` -> **Note**: Equality is tested with a Ruby method. It is subject to what Ruby considers -to be equal. For strings, equality is case sensitive. +Returns the value of the Puppet vardir setting for the node running Puppet or Puppet agent. -In Puppet core, counting is done using a combination of the built-in functions -[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) (since Puppet 4.0.0) and -[`length`](https://puppet.com/docs/puppet/latest/function.html#length) (since Puppet 5.5.0, before that in stdlib). +#### `puppet_environmentpath` -This example shows counting values that are not `undef`: +Returns the value of the Puppet environment path settings for the node running Puppet or Puppet agent. - notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length) +#### `puppet_server` -Would notice 2. +Returns the Puppet agent's `server` value, which is the hostname of the Puppet master with which the agent should communicate. -*Type*: rvalue. +#### `root_home` -#### `deep_merge` +Determines the root home directory. -Recursively merges two or more hashes together and returns the resulting hash. +Determines the root home directory, which depends on your operating system. Generally this is '/root'. -```puppet -$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } -$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } -$merged_hash = deep_merge($hash1, $hash2) -``` +#### `service_provider` -The resulting hash is equivalent to: - -```puppet -$merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } -``` - -If there is a duplicate key that is a hash, they are recursively merged. If there is a duplicate key that is not a hash, the key in the rightmost hash takes precedence. - -*Type*: rvalue. - -#### `defined_with_params` - -Takes a resource reference and an optional hash of attributes. Returns `true` if a resource with the specified attributes has already been added to the catalog. Returns `false` otherwise. - -```puppet -user { 'dan': - ensure => present, -} - -if ! defined_with_params(User[dan], {'ensure' => 'present' }) { - user { 'dan': ensure => present, } -} -``` - -*Type*: rvalue. - -#### `delete` - -Deletes all instances of a given element from an array, substring from a string, or key from a hash. - -For example: - -* `delete(['a','b','c','b'], 'b')` returns ['a','c']. -* `delete('abracadabra', 'bra')` returns 'acada'. -* `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}. -* `delete(['ab', 'b'], 'b')` returns ['ab']. - -Since Puppet 4.0.0, the minus (`-`) operator deletes values from arrays and deletes keys from a hash: - - ['a', 'b', 'c', 'b'] - 'b' - # would return ['a', 'c'] - - {'a'=>1,'b'=>2,'c'=>3} - ['b','c']) - # would return {'a' => '1'} - -You can perform a global delete from a string with the built-in -[`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function. - - 'abracadabra'.regsubst(/bra/, '', 'G') - # would return 'acada' - -In general, the built-in -[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function -can filter out entries from arrays and hashes based on a combination of keys and values. - -*Type*: rvalue. - -#### `delete_at` - -Deletes a determined indexed value from an array. - -For example: `delete_at(['a','b','c'], 1)` returns ['a','c']. - -Since Puppet 4, this can be done with the built-in -[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: - - ['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 } # returns ['a', 'c'] - ['a', 'b', 'c', 'd'].filter |$pos, $val | { $pos % 2 != 0 } # returns ['b', 'd'] - -Or, if you want to delete from the beginning or the end of the array — or from both ends at the same time — use the slice operator `[ ]`: - - $array[0, -1] # the same as all the values - $array[2, -1] # all but the first 2 elements - $array[0, -3] # all but the last 2 elements - $array[1, -2] # all but the first and last element - -*Type*: rvalue. - -#### `delete_regex` - -Deletes all instances of a given element from an array or hash that match a provided regular expression. A string is treated as a one-item array. - -*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -For example: - -* `delete_regex(['a','b','c','b'], 'b')` returns ['a','c']. -* `delete_regex({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1}. -* `delete_regex(['abf', 'ab', 'ac'], '^ab.*')` returns ['ac']. -* `delete_regex(['ab', 'b'], 'b')` returns ['ab']. - -Since Puppet 4.0.0, do the equivalent with the built-in -[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: - - ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ } - # Would return: ['aaa', 'aca'] - -*Type*: rvalue. - -#### `delete_values` - -Deletes all instances of a given value from a hash. - -For example: - -* `delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')` returns {'a'=>'A','c'=>'C','B'=>'D'} - -Since Puppet 4.0.0, do the equivalent with the built-in -[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: - - $array.filter |$val| { $val != 'B' } - $hash.filter |$key, $val| { $val != 'B' } - -*Type*: rvalue. - -#### `delete_undef_values` - -Deletes all instances of the `undef` value from an array or hash. - -For example: - -* `$hash = delete_undef_values({a=>'A', b=>'', c=>`undef`, d => false})` returns {a => 'A', b => '', d => false}. - -Since Puppet 4.0.0, do the equivalent with the built-in -[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: - - $array.filter |$val| { $val =~ NotUndef } - $hash.filter |$key, $val| { $val =~ NotUndef } - -*Type*: rvalue. - -#### `deprecation` - -Prints deprecation warnings and logs a warning once for a given key: - -```puppet -deprecation(key, message) -``` - -Arguments: - -* A string specifying the key: To keep the number of messages low during the lifetime of a Puppet process, only one message per key is logged. -* A string specifying the message: the text to be logged. - -*Type*: Statement. - -**Settings that affect `deprecation`** - -Other settings in Puppet affect the stdlib `deprecation` function: - -* [`disable_warnings`](https://puppet.com/docs/puppet/latest/configuration.html#disablewarnings) -* [`max_deprecations`](https://puppet.com/docs/puppet/latest/configuration.html#maxdeprecations) -* [`strict`](https://puppet.com/docs/puppet/latest/configuration.html#strict): - - * `error`: Fails immediately with the deprecation message - * `off`: Output emits no messages. - * `warning`: Logs all warnings. This is the default setting. - -* The environment variable `STDLIB_LOG_DEPRECATIONS` - - Specifies whether or not to log deprecation warnings. This is especially useful for automated tests to avoid flooding your logs before you are ready to migrate. - - This variable is Boolean, with the following effects: - - * `true`: Functions log a warning. - * `false`: No warnings are logged. - * No value set: Puppet 4 emits warnings, but Puppet 3 does not. - -#### `difference` - -Returns the difference between two arrays. The returned array is a copy of the original array, removing any items that also appear in the second array. - -For example: - -* `difference(["a","b","c"],["b","c","d"])` returns ["a"]. - -Since Puppet 4, the minus (`-`) operator in the Puppet language does the same: - - ['a', 'b', 'c'] - ['b', 'c', 'd'] - # would return ['a'] - -*Type*: rvalue. - -#### `dig` - -**Deprecated:** This function has been replaced with a built-in [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version. - -Retrieves a value within multiple layers of hashes and arrays via an array of keys containing a path. The function goes through the structure by each path component and tries to return the value at the end of the path. - -In addition to the required path argument, the function accepts the default argument. It is returned if the path is not correct, if no value was found, or if any other error has occurred. - -```ruby -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3', - ] - } -} - -$value = dig($data, ['a', 'b', 2]) -# $value = 'b3' - -# with all possible options -$value = dig($data, ['a', 'b', 2], 'not_found') -# $value = 'b3' - -# using the default value -$value = dig($data, ['a', 'b', 'c', 'd'], 'not_found') -# $value = 'not_found' -``` - -1. **$data** The data structure we are working with. -2. **['a', 'b', 2]** The path array. -3. **'not_found'** The default value. It is returned if nothing is found. - -Default value: `undef`. - -*Type*: rvalue. - -#### `dig44` - -Retrieves a value within multiple layers of hashes and arrays via an array of keys containing a path. The function goes through the structure by each path component and tries to return the value at the end of the path. - -In addition to the required path argument, the function accepts the default argument. It is returned if the path is incorrect, if no value was found, or if any other error has occurred. - -```ruby -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3', - ] - } -} - -$value = dig44($data, ['a', 'b', 2]) -# $value = 'b3' - -# with all possible options -$value = dig44($data, ['a', 'b', 2], 'not_found') -# $value = 'b3' - -# using the default value -$value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found') -# $value = 'not_found' -``` - -*Type*: rvalue. - -1. **$data** The data structure we are working with. -2. **['a', 'b', 2]** The path array. -3. **'not_found'** The default value. It will be returned if nothing is found. - (optional, defaults to `undef`) - -#### `dirname` - -Returns the `dirname` of a path. For example, `dirname('/path/to/a/file.ext')` returns '/path/to/a'. - -*Type*: rvalue. - -#### `dos2unix` - -Returns the Unix version of the given string. Very useful when using a File resource with a cross-platform template. - -```puppet -file { $config_file: - ensure => file, - content => dos2unix(template('my_module/settings.conf.erb')), -} -``` - -See also [unix2dos](#unix2dos). - -*Type*: rvalue. - -#### `downcase` - -**Deprecated:** This function has been replaced with a built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function as of Puppet 6.0.0. - -Converts the case of a string or of all strings in an array to lowercase. - -*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -*Type*: rvalue. - -#### `empty` - -**Deprecated:** This function has been replaced with a built-in [`empty`](https://puppet.com/docs/puppet/latest/function.html#empty) function as of Puppet 5.5.0. - -Returns `true` if the argument is an array or hash that contains no elements, or an empty string. Returns `false` when the argument is a numerical value. - -*Type*: rvalue. - -#### `enclose_ipv6` - -Takes an array of IP addresses and encloses the ipv6 addresses with square brackets. - -*Type*: rvalue. - -#### `ensure_packages` - -Takes a list of packages in an array or hash and installs them only if they don't already exist. Optionally takes a hash as a second parameter to be passed as the third argument to the `ensure_resource()` or `ensure_resources()` function. - -*Type*: statement. - -For an array: - -```puppet -ensure_packages(['ksh','openssl'], {'ensure' => 'present'}) -``` - -For a hash: - -```puppet -ensure_packages({'ksh' => { ensure => '20120801-1' } , 'mypackage' => { source => '/tmp/myrpm-1.0.0.x86_64.rpm', provider => "rpm" }}, {'ensure' => 'present'}) -``` - -#### `ensure_resource` - -Takes a resource type, title, and a hash of attributes that describe the resource(s). - -``` -user { 'dan': - ensure => present, -} -``` - -This example only creates the resource if it does not already exist: - - `ensure_resource('user', 'dan', {'ensure' => 'present' })` - -If the resource already exists, but does not match the specified parameters, this function attempts to recreate the resource, leading to a duplicate resource definition error. - -An array of resources can also be passed in, and each will be created with the type and parameters specified if it doesn't already exist. - -`ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})` - -*Type*: statement. - -#### `ensure_resources` - -Creates resource declarations from a hash, but doesn't conflict with resources that are already declared. - -Specify a resource type and title and a hash of attributes that describe the resource(s). - -```puppet -user { 'dan': - gid => 'mygroup', - ensure => present, -} - -ensure_resources($user) -``` - -Pass in a hash of resources. Any listed resources that don't already exist will be created with the type and parameters specified: - - ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } , 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) - -From Hiera backend: - -```yaml -userlist: - dan: - gid: 'mygroup' - uid: '600' - alex: - gid: 'mygroup' -``` - -```puppet -ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) -``` - -#### `stdlib::extname` - -Returns the Extension (the Portion of Filename in Path starting from the last Period). - -Example usage: - -```puppet -stdlib::extname('test.rb') => '.rb' -stdlib::extname('a/b/d/test.rb') => '.rb' -stdlib::extname('test') => '' -stdlib::extname('.profile') => '' -``` - -*Type*: rvalue. - -#### `fact` - -Return the value of a given fact. Supports the use of dot-notation for referring to structured facts. If a fact requested does not exist, returns Undef. - -Example usage: - -```puppet -fact('kernel') -fact('osfamily') -fact('os.architecture') -``` - -Array indexing: - -```puppet -$first_processor = fact('processors.models.0') -$second_processor = fact('processors.models.1') -``` - -Fact containing a "." in the fact name: - -```puppet -fact('vmware."VRA.version"') -``` - -#### `flatten` - -**Deprecated:** This function has been replaced with a built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function as of Puppet 5.5.0. - -Flattens deeply nested arrays and returns a single flat array as a result. - -For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c']. - -*Type*: rvalue. - -#### `floor` - -**Deprecated:** This function has been replaced with a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function as of Puppet 6.0.0. - -Returns the largest integer less than or equal to the argument. - -Arguments: A single numeric value. - -*Type*: rvalue. - -#### `fqdn_rand_string` - -Generates a random alphanumeric string, combining the `$fqdn` fact and an optional seed for repeatable randomness. Optionally, you can specify a character set for the function (defaults to alphanumeric). - -*Usage:* - -```puppet -fqdn_rand_string(LENGTH, [CHARSET], [SEED]) -``` - -*Examples:* - -```puppet -fqdn_rand_string(10) -fqdn_rand_string(10, 'ABCDEF!@#$%^') -fqdn_rand_string(10, '', 'custom seed') -``` - -Arguments: - -* An integer, specifying the length of the resulting string. -* Optionally, a string specifying the character set. -* Optionally, a string specifying the seed for repeatable randomness. - -*Type*: rvalue. - -#### `fqdn_rotate` - -Rotates an array or string a random number of times, combining the `$fqdn` fact and an optional seed for repeatable randomness. - -*Usage:* - -```puppet -fqdn_rotate(VALUE, [SEED]) -``` - -*Examples:* - -```puppet -fqdn_rotate(['a', 'b', 'c', 'd']) -fqdn_rotate('abcd') -fqdn_rotate([1, 2, 3], 'custom seed') -``` - -*Type*: rvalue. - -#### `fqdn_uuid` - -Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based on an FQDN string under the DNS namespace: - - * fqdn_uuid('puppetlabs.com') returns '9c70320f-6815-5fc5-ab0f-debe68bf764c' - * fqdn_uuid('google.com') returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09c8' - -*Type*: rvalue. - -#### `get_module_path` - -Returns the absolute path of the specified module for the current environment. - -```puppet -$module_path = get_module_path('stdlib') -``` - -Since Puppet 5.4.0, the built-in [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory) function does the same thing and will return the path to the first module found, if given multiple values or an array. - -*Type*: rvalue. - -#### `getparam` -Returns the value of a resource's parameter. - -Arguments: A resource reference and the name of the parameter. - -> Note: User defined resource types are evaluated lazily. - -*Examples:* - -```puppet -# define a resource type with a parameter -define example_resource($param) { -} - -# declare an instance of that type -example_resource { "example_resource_instance": - param => "'the value we are getting in this example''" -} - -# Because of order of evaluation, a second definition is needed -# that will be evaluated after the first resource has been declared -# -define example_get_param { - # This will notice the value of the parameter - notice(getparam(Example_resource["example_resource_instance"], "param")) -} - -# Declare an instance of the second resource type - this will call notice -example_get_param { 'show_notify': } -``` - -Would notice: 'the value we are getting in this example' - -Since Puppet 4.0.0, you can get a parameter value by using its data type -and the [ ] operator. The example below is equivalent to a call to getparam(): - -```puppet -Example_resource['example_resource_instance']['param'] -``` - -#### `getvar` -**Deprecated:** This function has been replaced with a built-in [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) -function as of Puppet 6.0.0. The new version also supports digging into a structured value. - -Looks up a variable in a remote namespace. - -For example: - -```puppet -$foo = getvar('site::data::foo') -# Equivalent to $foo = $site::data::foo -``` - -This is useful if the namespace itself is stored in a string: - -```puppet -$datalocation = 'site::data' -$bar = getvar("${datalocation}::bar") -# Equivalent to $bar = $site::data::bar -``` - -*Type*: rvalue. - -#### `glob` - -Returns an array of strings of paths matching path patterns. - -Arguments: A string or an array of strings specifying path patterns. - -```puppet -$confs = glob(['/etc/**/*.conf', '/opt/**/*.conf']) -``` - -*Type*: rvalue. - -#### `grep` - -Searches through an array and returns any elements that match the provided regular expression. - -For example, `grep(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['aaa','aaaddd']. - -Since Puppet 4.0.0, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does the "same" — as any logic can be used to filter, as opposed to just regular expressions: - - ['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' } - -*Type*: rvalue. - -#### `has_interface_with` - -Returns a Boolean based on kind and value: - - * macaddress - * netmask - * ipaddress - * network - -*Examples:* - -```puppet -has_interface_with("macaddress", "x:x:x:x:x:x") -has_interface_with("ipaddress", "127.0.0.1") => true -``` - -If no kind is given, then the presence of the interface is checked: - -```puppet -has_interface_with("lo") => true -``` - -*Type*: rvalue. - -#### `has_ip_address` - -Returns `true` if the client has the requested IP address on some interface. This function iterates through the `interfaces` fact and checks the `ipaddress_IFACE` facts, performing a simple string comparison. - -Arguments: A string specifying an IP address. - -*Type*: rvalue. - -#### `has_ip_network` - -Returns `true` if the client has an IP address within the requested network. This function iterates through the `interfaces` fact and checks the `network_IFACE` facts, performing a simple string comparision. - -Arguments: A string specifying an IP address. - -*Type*: rvalue. - -#### `has_key` -**Deprecated:** This function has been replaced with the built-in operator `in`. - -Determines if a hash has a certain key value. - -*Example*: - -``` -$my_hash = {'key_one' => 'value_one'} -if has_key($my_hash, 'key_two') { - notice('we will not reach here') -} -if has_key($my_hash, 'key_one') { - notice('this will be printed') -} -``` - -Since Puppet 4.0.0, this can be achieved in the Puppet language with the following equivalent expression: - - $my_hash = {'key_one' => 'value_one'} - if 'key_one' in $my_hash { - notice('this will be printed') - } - -*Type*: rvalue. - -#### `hash` - -**Deprecated:** This function has been replaced with the built-in ability to create a new value of almost any -data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function -in Puppet. - -Converts an array into a hash. - -For example (deprecated), `hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}. - -For example (built-in), `Hash(['a',1,'b',2,'c',3])` returns {'a'=>1,'b'=>2,'c'=>3}. - -*Type*: rvalue. - -#### `intersection` - -Returns an array an intersection of two. - -For example, `intersection(["a","b","c"],["b","c","d"])` returns ["b","c"]. - -*Type*: rvalue. - -#### `is_a` - -Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. This function is available only in Puppet 4, or in Puppet 3 with the "future" parser. - -``` -foo = 3 -$bar = [1,2,3] -$baz = 'A string!' - -if $foo.is_a(Integer) { - notify { 'foo!': } -} -if $bar.is_a(Array) { - notify { 'bar!': } -} -if $baz.is_a(String) { - notify { 'baz!': } -} -``` - -* See the [the Puppet type system](https://puppet.com/docs/puppet/latest/lang_data.html) for more information about types. -* See the [`assert_type()`](https://puppet.com/docs/puppet/latest/function.html#asserttype) function for flexible ways to assert the type of a value. - -#### `is_absolute_path` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the given path is absolute. - -*Type*: rvalue. - -#### `is_array` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable passed to this function is an array. - -*Type*: rvalue. - -#### `is_bool` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable passed to this function is a Boolean. - -*Type*: rvalue. - -#### `is_domain_name` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the string passed to this function is a syntactically correct domain name. - -*Type*: rvalue. - -#### `is_email_address` - -Returns true if the string passed to this function is a valid email address. - -*Type*: rvalue. - - -#### `is_float` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable passed to this function is a float. - -*Type*: rvalue. - -#### `is_function_available` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Accepts a string as an argument and determines whether the Puppet runtime has access to a function by that name. It returns `true` if the function exists, `false` if not. - -*Type*: rvalue. - -#### `is_hash` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable passed to this function is a hash. - -*Type*: rvalue. - -#### `is_integer` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable returned to this string is an integer. - -*Type*: rvalue. - -#### `is_ip_address` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the string passed to this function is a valid IP address. - -*Type*: rvalue. - -#### `is_ipv6_address` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the string passed to this function is a valid IPv6 address. - -*Type*: rvalue. - -#### `is_ipv4_address` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the string passed to this function is a valid IPv4 address. - -*Type*: rvalue. - -#### `is_mac_address` - -Returns `true` if the string passed to this function is a valid MAC address. - -*Type*: rvalue. - -#### `is_numeric` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable passed to this function is a number. - -*Type*: rvalue. - -#### `is_string` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Returns `true` if the variable passed to this function is a string. - -*Type*: rvalue. - -#### `join` - -**Deprecated:** This function has been replaced with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function as of Puppet 5.5.0. - -Joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c". - -*Type*: rvalue. - -#### `join_keys_to_values` - -Joins each key of a hash to that key's corresponding value with a separator, returning the result as strings. - -If a value is an array, the key is prefixed to each element. The return value is a flattened array. - -For example, `join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")` results in ["a is 1","b is 2","b is 3"]. - -Since Puppet 5.0.0, there is more control over the formatting (including indentations and line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual -formatting of values in the array) - see the -built-in [`String.new`](https://docs.puppet.com/puppet/latest/function.html#conversion-to-string) function and its formatting options for `Array` and `Hash`. - -*Type*: rvalue. - -#### `keys` - -**Deprecated:** This function has been replaced with a built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys) function as of Puppet 5.5.0. - -Returns the keys of a hash as an array. - -*Type*: rvalue. - -#### `length` - -**Deprecated:** This function has been replaced with a built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function as of Puppet 5.5.0. - -Returns the length of a given string, array or hash. Replaces the deprecated `size()` function. - -*Type*: rvalue. - -#### `loadyaml` - -Loads a YAML file containing an array, string, or hash, and returns the data in the corresponding native data type. - -For example: - -```puppet -$myhash = loadyaml('/etc/puppet/data/myhash.yaml') -``` - -The second parameter is returned if the file was not found or could not be parsed. - -For example: - -```puppet -$myhash = loadyaml('no-file.yaml', {'default'=>'value'}) -``` - -*Type*: rvalue. - -#### `loadjson` - -Loads a JSON file containing an array, string, or hash, and returns the data in the corresponding native data type. - -For example: - -The first parameter can be an absolute file path, or a URL. - -```puppet -$myhash = loadjson('/etc/puppet/data/myhash.json') -``` - -The second parameter is returned if the file was not found or could not be parsed. - -For example: - -```puppet - $myhash = loadjson('no-file.json', {'default'=>'value'}) - ``` - -*Type*: rvalue. - -#### `load_module_metadata` - -Loads the metadata.json of a target module. Can be used to determine module version and authorship for dynamic support of modules. - -```puppet -$metadata = load_module_metadata('archive') -notify { $metadata['author']: } -``` - -When a module's metadata file is absent, the catalog compilation fails. To avoid this failure, do the following: - -``` -$metadata = load_module_metadata('mysql', true) -if empty($metadata) { - notify { "This module does not have a metadata.json file.": } -} -``` - -*Type*: rvalue. - -#### `lstrip` - -**Deprecated:** This function has been replaced with a built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function as of Puppet 6.0.0. - -Strips spaces to the left of a string. - -*Type*: rvalue. - -#### `max` - -**Deprecated:** This function has been replaced with a built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function as of Puppet 6.0.0. - -Returns the highest value of all arguments. Requires at least one argument. - -Arguments: A numeric or a string representing a number. - -*Type*: rvalue. - -#### `member` - -This function determines if a variable is a member of an array. The variable can be a string, an array, or a fixnum. - -For example, `member(['a','b'], 'b')` and `member(['a','b','c'], ['b','c'])` return `true`, while `member(['a','b'], 'c')` and `member(['a','b','c'], ['c','d'])` return `false`. - -*Note*: This function does not support nested arrays. If the first argument contains nested arrays, it will not recurse through them. - -Since Puppet 4.0.0, you can perform the same in the Puppet language. For single values, -use the operator `in`: - - 'a' in ['a', 'b'] # true - -And for arrays, use the operator `-` to compute a diff: - - ['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted - ['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted - -Also note that since Puppet 5.2.0, the general form to test the content of an array or hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any) and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions. - -*Type*: rvalue. - -#### `merge` - -Merges two or more hashes together and returns the resulting hash. - -*Example*: - -```puppet -$hash1 = {'one' => 1, 'two' => 2} -$hash2 = {'two' => 'dos', 'three' => 'tres'} -$merged_hash = merge($hash1, $hash2) -# The resulting hash is equivalent to: -# $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} -``` - -When there is a duplicate key, the key in the rightmost hash takes precedence. - -Since Puppet 4.0.0, you can use the + operator to achieve the same merge. - - $merged_hash = $hash1 + $hash2 - -*Type*: rvalue. - -#### `min` - -**Deprecated:** This function has been replaced with a built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function as of Puppet 6.0.0. - -Returns the lowest value of all arguments. Requires at least one argument. - -Arguments: A numeric or a string representing a number. - -*Type*: rvalue. - -#### `num2bool` - -Converts a number, or a string representation of a number, into a true Boolean. -Zero or anything non-numeric becomes `false`. -Numbers greater than zero become `true`. - -Since Puppet 5.0.0, the same can be achieved with the Puppet type system. -See the [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) -function in Puppet for the many available type conversions. - - Boolean(0) # false - Boolean(1) # true - -*Type*: rvalue. - -#### `os_version_gte` - -Checks to see if the OS version is at least a certain version. Note that only the major version is taken into account. - -Example usage: -``` - if os_version_gte('Debian', '9') { } - if os_version_gte('Ubuntu', '18.04') { } -``` - -Returns: - - Boolean(0) # When OS is below the given version. - - Boolean(1) # When OS is equal to or greater than the given version. - -#### `parsejson` - -Converts a string of JSON into the correct Puppet structure (as a hash, array, string, integer, or a combination of such). - -Arguments: -* The JSON string to convert, as a first argument. -* Optionally, the result to return if conversion fails, as a second error. - -*Type*: rvalue. - -#### `parseyaml` - -Converts a string of YAML into the correct Puppet structure. - -Arguments: -* The YAML string to convert, as a first argument. -* Optionally, the result to return if conversion fails, as a second error. - -*Type*: rvalue. - -#### `pick` - -From a list of values, returns the first value that is not undefined or an empty string. Takes any number of arguments, and raises an error if all values are undefined or empty. - -```puppet -$real_jenkins_version = pick($::jenkins_version, '1.449') -``` - -*Type*: rvalue. - -#### `pick_default` - -Returns the first value in a list of values. Unlike the `pick()` function, `pick_default()` does not fail if all arguments are empty. This allows it to use an empty value as default. - -*Type*: rvalue. - -#### `prefix` - -Applies a prefix to all elements in an array, or to the keys in a hash. - -For example: - -* `prefix(['a','b','c'], 'p')` returns ['pa','pb','pc']. -* `prefix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'pa'=>'b','pb'=>'c','pc'=>'d'}. - -Since Puppet 4.0.0, modify values in array by using the built-in [`map`](https://docs.puppet.com/puppet/latest/function.html#map) function. -This example does the same as the first example above: - - ['a', 'b', 'c'].map |$x| { "p${x}" } - -*Type*: rvalue. - -#### `pry` - -Invokes a pry debugging session in the current scope object. Useful for debugging manifest code at specific points during a compilation. Should be used only when running `puppet apply` or running a Puppet master in the foreground. Requires the `pry` gem to be installed in Puppet's rubygems. - -*Examples:* - -```puppet -pry() -``` - -In a pry session, useful commands include: - -* Run `catalog` to see the contents currently compiling catalog. -* Run `cd catalog` and `ls` to see catalog methods and instance variables. -* Run `@resource_table` to see the current catalog resource table. - -#### `pw_hash` - -Hashes a password using the crypt function. Provides a hash usable on most POSIX systems. - -The first argument to this function is the password to hash. If it is `undef` or an empty string, this function returns `undef`. - -The second argument to this function is which type of hash to use. It will be converted into the appropriate crypt(3) hash specifier. Valid hash types are: - -|Hash type |Specifier| -|---------------------|---------| -|MD5 |1 | -|SHA-256 |5 | -|SHA-512 (recommended)|6 | - -The third argument to this function is the salt to use. - -This function uses the Puppet master's implementation of crypt(3). If your environment contains several different operating systems, ensure that they are compatible before using this function. - -*Type*: rvalue. - -*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `range` - -Extrapolates a range as an array when given in the form of '(start, stop)'. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9]. - -Non-integer strings are accepted: - -* `range("a", "c")` returns ["a","b","c"]. -* `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"]. - -You must explicitly include trailing zeros, or the underlying Ruby function fails. - -Passing a third argument causes the generated range to step by that interval. For example: - -* `range("0", "9", "2")` returns ["0","2","4","6","8"]. - -> Note: The Puppet language supports `Integer` and `Float` ranges by using the type system. They are suitable for iterating a given number of times. - -See the built-in [`step`](https://docs.puppet.com/puppet/latest/function.html#step) function in Puppet for skipping values. - - Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9 - -*Type*: rvalue. - -#### `regexpescape` - -Regexp escape a string or array of strings. Requires either a single string or an array as an input. - -*Type*: rvalue. - -#### `reject` - -Searches through an array and rejects all elements that match the provided regular expression. - -For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc']. - -Since Puppet 4.0.0, the same is true with the built-in [`filter`](https://docs.puppet.com/puppet/latest/function.html#filter) function in Puppet. -The equivalent of the stdlib `reject` function: - - ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ } - -*Type*: rvalue. - -#### `reverse` - -Reverses the order of a string or array. - -> *Note*: The same can be done with the built-in [`reverse_each`](https://docs.puppet.com/puppet/latest/function.html#reverse_each) function in Puppet. - - -#### `round` - -**Deprecated:** This function has been replaced with a built-in [`round`](https://puppet.com/docs/puppet/latest/function.html#round) function as of Puppet 6.0.0. - -Rounds a number to the nearest integer. - -*Type*: rvalue. - -#### `rstrip` - -**Deprecated:** This function has been replaced with a built-in [`rstrip`](https://puppet.com/docs/puppet/latest/function.html#rstrip) function as of Puppet 6.0.0. - -Strips spaces to the right of the string. - -*Type*: rvalue. - -#### `seeded_rand` - -Takes an integer max value and a string seed value and returns a repeatable random integer smaller than max. Similar to `fqdn_rand`, but does not add node specific data to the seed. - -*Type*: rvalue. - -#### `seeded_rand_string` - -Generates a consistent (based on seed value) random string. Useful for generating matching passwords for different hosts. - -#### `shell_escape` - -Escapes a string so that it can be safely used in a Bourne shell command line. Note that the resulting string should be used unquoted and is not intended for use in either double or single quotes. This function behaves the same as Ruby's `Shellwords.shellescape()` function; see the [Ruby documentation](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellescape). - -For example: - -```puppet -shell_escape('foo b"ar') => 'foo\ b\"ar' -``` - -*Type*: rvalue. - -#### `shell_join` - -Builds a command line string from a given array of strings. Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between. This function behaves the same as Ruby's `Shellwords.shelljoin()` function; see the [Ruby documentation](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shelljoin). - -For example: - -```puppet -shell_join(['foo bar', 'ba"z']) => 'foo\ bar ba\"z' -``` - -*Type*: rvalue. - -#### `shell_split` - -Splits a string into an array of tokens. This function behaves the same as Ruby's `Shellwords.shellsplit()` function; see the [ruby documentation](http://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html#method-c-shellsplit). - -*Example:* - -```puppet -shell_split('foo\ bar ba\"z') => ['foo bar', 'ba"z'] -``` - -*Type*: rvalue. - -#### `shuffle` - -Randomizes the order of a string or array elements. - -*Type*: rvalue. - -#### `size` - -**Deprecated:** This function has been replaced with a built-in [`size`](https://puppet.com/docs/puppet/latest/function.html#size) function as of Puppet 6.0.0 (`size` is now an alias for `length`). - -Returns the number of elements in a string, an array or a hash. This function will be deprecated in a future release. For Puppet 4, use the `length` function. - -*Type*: rvalue. - -#### `sprintf_hash` - -**Deprecated:** The same functionality can be achieved with the built-in [`sprintf`](https://docs.puppet.com/puppet/latest/function.html#sprintf) function as of Puppet 4.10.10 and 5.3.4. This function will be removed in a future release. - -Performs printf-style formatting with named references of text. - -The first parameter is a format string describing how to format the rest of the parameters in the hash. See Ruby documentation for [`Kernel::sprintf`](https://ruby-doc.org/core-2.4.2/Kernel.html#method-i-sprintf) for details about this function. - -For example: - -```puppet -$output = sprintf_hash('String: %s / number converted to binary: %b', - { 'foo' => 'a string', 'number' => 5 }) -# $output = 'String: a string / number converted to binary: 101' -``` - -*Type*: rvalue - -#### `sort` - -**Deprecated:** This function has been replaced with a built-in [`sort`](https://puppet.com/docs/puppet/latest/function.html#sort) function as of Puppet 6.0.0. - -Sorts strings and arrays lexically. - -*Type*: rvalue. - -> *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `squeeze` - -Replaces consecutive repeats (such as 'aaaa') in a string with a single character. Returns a new string. - -*Type*: rvalue. - -#### `str2bool` - -Converts certain strings to a Boolean. This attempts to convert strings that contain the values '1', 'true', 't', 'y', or 'yes' to `true`. Strings that contain values '0', 'false', 'f', 'n', or 'no', or that are an empty string or undefined are converted to `false`. Any other value causes an error. These checks are case insensitive. - -Since Puppet 5.0.0, the same can be achieved with the Puppet type system. -See the [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) -function in Puppet for the many available type conversions. - - Boolean('false'), Boolean('n'), Boolean('no') # all false - Boolean('true'), Boolean('y'), Boolean('yes') # all true - -*Type*: rvalue. - -#### `str2saltedsha512` - -Converts a string to a salted-SHA512 password hash, used for OS X versions 10.7 or greater. Returns a hex version of a salted-SHA512 password hash, which can be inserted into Puppet manifests as a valid password attribute. - -*Type*: rvalue. - -> *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `strftime` - -**Deprecated:** This function has been replaced with a built-in [`strftime`](https://puppet.com/docs/puppet/latest/function.html#strftime) function as of Puppet 4.8.0. - -Returns formatted time. - -For example, `strftime("%s")` returns the time since Unix epoch, and `strftime("%Y-%m-%d")` returns the date. - -Arguments: A string specifying the time in `strftime` format. See the Ruby [strftime](https://ruby-doc.org/core-2.1.9/Time.html#method-i-strftime) documentation for details. - -*Type*: rvalue. - -> *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -*Format:* - -* `%a`: The abbreviated weekday name ('Sun') -* `%A`: The full weekday name ('Sunday') -* `%b`: The abbreviated month name ('Jan') -* `%B`: The full month name ('January') -* `%c`: The preferred local date and time representation -* `%C`: Century (20 in 2009) -* `%d`: Day of the month (01..31) -* `%D`: Date (%m/%d/%y) -* `%e`: Day of the month, blank-padded ( 1..31) -* `%F`: Equivalent to %Y-%m-%d (the ISO 8601 date format) -* `%h`: Equivalent to %b -* `%H`: Hour of the day, 24-hour clock (00..23) -* `%I`: Hour of the day, 12-hour clock (01..12) -* `%j`: Day of the year (001..366) -* `%k`: Hour, 24-hour clock, blank-padded ( 0..23) -* `%l`: Hour, 12-hour clock, blank-padded ( 0..12) -* `%L`: Millisecond of the second (000..999) -* `%m`: Month of the year (01..12) -* `%M`: Minute of the hour (00..59) -* `%n`: Newline (\n) -* `%N`: Fractional seconds digits, default is 9 digits (nanosecond) - * `%3N`: Millisecond (3 digits) - * `%6N`: Microsecond (6 digits) - * `%9N`: Nanosecond (9 digits) -* `%p`: Meridian indicator ('AM' or 'PM') -* `%P`: Meridian indicator ('am' or 'pm') -* `%r`: Time, 12-hour (same as %I:%M:%S %p) -* `%R`: Time, 24-hour (%H:%M) -* `%s`: Number of seconds since the Unix epoch, 1970-01-01 00:00:00 UTC. -* `%S`: Second of the minute (00..60) -* `%t`: Tab character ( ) -* `%T`: Time, 24-hour (%H:%M:%S) -* `%u`: Day of the week as a decimal, Monday being 1. (1..7) -* `%U`: Week number of the current year, starting with the first Sunday as the first day of the first week (00..53) -* `%v`: VMS date (%e-%b-%Y) -* `%V`: Week number of year according to ISO 8601 (01..53) -* `%W`: Week number of the current year, starting with the first Monday as the first day of the first week (00..53) -* `%w`: Day of the week (Sunday is 0, 0..6) -* `%x`: Preferred representation for the date alone, no time -* `%X`: Preferred representation for the time alone, no date -* `%y`: Year without a century (00..99) -* `%Y`: Year with century -* `%z`: Time zone as hour offset from UTC (for example +0900) -* `%Z`: Time zone name -* `%%`: Literal '%' character - -#### `strip` - -**Deprecated:** This function has been replaced with a built-in [`strip`](https://puppet.com/docs/puppet/latest/function.html#strip) function as of Puppet 6.0.0. - -Removes leading and trailing whitespace from a string or from every string inside an array. For example, `strip(" aaa ")` results in "aaa". - -*Type*: rvalue. - -#### `suffix` - -Applies a suffix to all elements in an array or to all keys in a hash. - -For example: - -* `suffix(['a','b','c'], 'p')` returns ['ap','bp','cp']. -* `suffix({'a'=>'b','b'=>'c','c'=>'d'}, 'p')` returns {'ap'=>'b','bp'=>'c','cp'=>'d'}. - -Note that since Puppet 4.0.0, you can modify values in an array using the built-in [`map`](https://docs.puppet.com/puppet/latest/function.html#map) function. This example does the same as the first example above: - - ['a', 'b', 'c'].map |$x| { "${x}p" } - -*Type*: rvalue. - -#### `swapcase` - -Swaps the existing case of a string. For example, `swapcase("aBcD")` results in "AbCd". - -*Type*: rvalue. - -> *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `time` - -Returns the current Unix epoch time as an integer. - -For example, `time()` returns something like '1311972653'. - -Since Puppet 4.8.0, the Puppet language has the data types `Timestamp` (a point in time) and `Timespan` (a duration). The following example is equivalent to calling `time()` without any arguments: - - Timestamp() - -*Type*: rvalue. - -#### `to_bytes` - -Converts the argument into bytes. - -For example, "4 kB" becomes "4096". - -Arguments: A single string. - -*Type*: rvalue. - -#### `to_json` - -Converts input into a JSON String. - -For example, `{ "key" => "value" }` becomes `{"key":"value"}`. - -*Type*: rvalue. - -#### `to_json_pretty` - -Converts input into a pretty JSON String. - -For example, `{ "key" => "value" }` becomes `{\n \"key\": \"value\"\n}`. - -*Type*: rvalue. - -#### `to_yaml` - -Converts input into a YAML String. - -For example, `{ "key" => "value" }` becomes `"---\nkey: value\n"`. - -*Type*: rvalue. - -#### `try_get_value` - -**Deprecated:** Replaced by `dig()`. - -Retrieves a value within multiple layers of hashes and arrays. - -Arguments: - -* A string containing a path, as the first argument. Provide this argument as a string of hash keys or array indexes starting with zero and separated by the path separator character (default "/"). This function goes through the structure by each path component and tries to return the value at the end of the path. - -* A default argument as a second argument. This argument is returned if the path is not correct, if no value was found, or if any other error has occurred. -* The path separator character as a last argument. - -```ruby -$data = { - 'a' => { - 'b' => [ - 'b1', - 'b2', - 'b3', - ] - } -} - -$value = try_get_value($data, 'a/b/2') -# $value = 'b3' - -# with all possible options -$value = try_get_value($data, 'a/b/2', 'not_found', '/') -# $value = 'b3' - -# using the default value -$value = try_get_value($data, 'a/b/c/d', 'not_found') -# $value = 'not_found' - -# using custom separator -$value = try_get_value($data, 'a|b', [], '|') -# $value = ['b1','b2','b3'] -``` - -1. **$data** The data structure we are working with. -2. **'a/b/2'** The path string. -3. **'not_found'** The default value. It will be returned if nothing is found. - (optional, defaults to *`undef`*) -4. **'/'** The path separator character. - (optional, defaults to *'/'*) - -*Type*: rvalue. - -#### `type3x` - -**Deprecated:** This function will be removed in a future release. - -Returns a string description of the type of a given value. The type can be a string, array, hash, float, integer, or Boolean. For Puppet 4, use the new type system instead. - -Arguments: - -* string -* array -* hash -* float -* integer -* Boolean - -*Type*: rvalue. - -#### `type_of` - -This function is provided for backwards compatibility, but the built-in [type() function](https://puppet.com/docs/puppet/latest/function.html#type) provided by Puppet is preferred. - -Returns the literal type of a given value. Requires Puppet 4. Useful for comparison of types with `<=` such as in `if type_of($some_value) <= Array[String] { ... }` (which is equivalent to `if $some_value =~ Array[String] { ... }`). - -*Type*: rvalue. - -#### `union` - -Returns a union of two or more arrays, without duplicates. - -For example, `union(["a","b","c"],["b","c","d"])` returns ["a","b","c","d"]. - -*Type*: rvalue. - -#### `unique` - -Removes duplicates from strings and arrays. - -For example, `unique("aabbcc")` returns 'abc', and `unique(["a","a","b","b","c","c"])` returns ["a","b","c"]. - -*Type*: rvalue. - -#### `unix2dos` - -Returns the DOS version of a given string. Useful when using a File resource with a cross-platform template. - -*Type*: rvalue. - -```puppet -file { $config_file: - ensure => file, - content => unix2dos(template('my_module/settings.conf.erb')), -} -``` - -See also [dos2unix](#dos2unix). - -#### `upcase` - -**Deprecated:** This function has been replaced with a built-in [`upcase`](https://puppet.com/docs/puppet/latest/function.html#upcase) function as of Puppet 6.0.0. - -Converts an object, array, or hash of objects to uppercase. Objects to be converted must respond to upcase. - -For example, `upcase('abcd')` returns 'ABCD'. - -*Type*: rvalue. - -*Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `uriescape` - -URLEncodes a string or array of strings. - -Arguments: Either a single string or an array of strings. - -*Type*: rvalue. - -> *Note:* This function is an implementation of a Ruby class and might not be UTF8 compatible. To ensure compatibility, use this function with Ruby 2.4.0 or greater. - -#### `validate_absolute_path` - -Validates that a given string represents an absolute path in the filesystem. Works for Windows and Unix style paths. - -The following values pass: - -```puppet -$my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' -validate_absolute_path($my_path) -$my_path2 = '/var/lib/puppet' -validate_absolute_path($my_path2) -$my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] -validate_absolute_path($my_path3) -$my_path4 = ['/var/lib/puppet','/usr/share/puppet'] -validate_absolute_path($my_path4) -``` - -The following values fail, causing compilation to terminate: - -```puppet -validate_absolute_path(true) -validate_absolute_path('../var/lib/puppet') -validate_absolute_path('var/lib/puppet') -validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) -validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) -$undefined = `undef` -validate_absolute_path($undefined) -``` - -*Type*: statement. - -#### `validate_array` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates that all passed values are array data structures. Terminates catalog compilation if any value fails this check. - -The following values pass: - -```puppet -$my_array = [ 'one', 'two' ] -validate_array($my_array) -``` - -The following values fail, causing compilation to terminate: - -```puppet -validate_array(true) -validate_array('some_string') -$undefined = `undef` -validate_array($undefined) -``` - -*Type*: statement. - -#### `validate_augeas` - -Validates a string using an Augeas lens. - -Arguments: - -* The string to test, as the first argument. -* The name of the Augeas lens to use, as the second argument. -* Optionally, a list of paths which should **not** be found in the file, as a third argument. -* Optionally, an error message to raise and show to the user, as a fourth argument. - -If Augeas fails to parse the string with the lens, the compilation terminates with a parse error. - -The `$file` variable points to the location of the temporary file being tested in the Augeas tree. - -For example, to make sure your $passwdcontent never contains user `foo`, include the third argument: - -```puppet -validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) -``` - -To raise and display an error message, include the fourth argument: - -```puppet -validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') -``` - -*Type*: statement. - -#### `validate_bool` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates that all passed values are either `true` or `false`. -Terminates catalog compilation if any value fails this check. - -The following values pass: - -```puppet -$iamtrue = true -validate_bool(true) -validate_bool(true, true, false, $iamtrue) -``` - -The following values fail, causing compilation to terminate: - -```puppet -$some_array = [ true ] -validate_bool("false") -validate_bool("true") -validate_bool($some_array) -``` - -*Type*: statement. - -#### `validate_cmd` - -Validates a string with an external command. - -Arguments: -* The string to test, as the first argument. -* The path to a test command, as the second argument. This argument takes a % as a placeholder for the file path (if no % placeholder is given, defaults to the end of the command). If the command is launched against a tempfile containing the passed string, or returns a non-null value, compilation will terminate with a parse error. -* Optionally, an error message to raise and show to the user, as a third argument. - -```puppet -# Defaults to end of path -validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') -``` - -```puppet -# % as file location -validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') -``` - -*Type*: statement. - -#### `validate_domain_name` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validate that all values passed are syntactically correct domain names. Aborts catalog compilation if any value fails this check. - -The following values pass: - -~~~ -$my_domain_name = 'server.domain.tld' -validate_domain_name($my_domain_name) -validate_domain_name('domain.tld', 'puppet.com', $my_domain_name) -~~~ - -The following values fail, causing compilation to abort: - -~~~ -validate_domain_name(1) -validate_domain_name(true) -validate_domain_name('invalid domain') -validate_domain_name('-foo.example.com') -validate_domain_name('www.example.2com') -~~~ - -*Type*: statement. - -#### `validate_email_address` - -Validate that all values passed are valid email addresses. Fail compilation if any value fails this check. - -The following values will pass: - -~~~ -$my_email = "waldo@gmail.com" -validate_email_address($my_email) -validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) -~~~ - -The following values will fail, causing compilation to abort: - -~~~ -$some_array = [ 'bad_email@/d/efdf.com' ] -validate_email_address($some_array) -~~~ - -*Type*: statement. - -#### `validate_hash` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates that all passed values are hash data structures. Terminates catalog compilation if any value fails this check. - -The following values will pass: - -```puppet -$my_hash = { 'one' => 'two' } -validate_hash($my_hash) -``` - -The following values will fail, causing compilation to terminate: - -```puppet -validate_hash(true) -validate_hash('some_string') -$undefined = `undef` -validate_hash($undefined) -``` - -*Type*: statement. - -#### `validate_integer` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates an integer or an array of integers. Terminates catalog compilation if any of the checks fail. - -Arguments: - -* An integer or an array of integers, as the first argument. -* Optionally, a maximum, as the second argument. (All elements of) the first argument must be equal to or less than this maximum. -* Optionally, a minimum, as the third argument. (All elements of) the first argument must be equal to or greater than than this maximum. - -This function fails if the first argument is not an integer or array of integers, or if the second or third arguments are not convertable to an integer. However, if (and only if) a minimum is given, the second argument may be an empty string or `undef`, which serves as a placeholder to ensure the minimum check. - -The following values pass: - -```puppet -validate_integer(1) -validate_integer(1, 2) -validate_integer(1, 1) -validate_integer(1, 2, 0) -validate_integer(2, 2, 2) -validate_integer(2, '', 0) -validate_integer(2, `undef`, 0) -$foo = `undef` -validate_integer(2, $foo, 0) -validate_integer([1,2,3,4,5], 6) -validate_integer([1,2,3,4,5], 6, 0) -``` - -* Plus all of the above, but any combination of values passed as strings ('1' or "1"). -* Plus all of the above, but with (correct) combinations of negative integer values. - -The following values fail, causing compilation to terminate: - -```puppet -validate_integer(true) -validate_integer(false) -validate_integer(7.0) -validate_integer({ 1 => 2 }) -$foo = `undef` -validate_integer($foo) -validate_integer($foobaridontexist) - -validate_integer(1, 0) -validate_integer(1, true) -validate_integer(1, '') -validate_integer(1, `undef`) -validate_integer(1, , 0) -validate_integer(1, 2, 3) -validate_integer(1, 3, 2) -validate_integer(1, 3, true) -``` - -* Plus all of the above, but any combination of values passed as strings (`false` or "false"). -* Plus all of the above, but with incorrect combinations of negative integer values. -* Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. - -*Type*: statement. - -#### `validate_ip_address` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates that the argument is an IP address, regardless of whether it is an IPv4 or an IPv6 address. It also validates IP address with netmask. - -Arguments: A string specifying an IP address. - -The following values will pass: - -```puppet -validate_ip_address('0.0.0.0') -validate_ip_address('8.8.8.8') -validate_ip_address('127.0.0.1') -validate_ip_address('194.232.104.150') -validate_ip_address('3ffe:0505:0002::') -validate_ip_address('::1/64') -validate_ip_address('fe80::a00:27ff:fe94:44d6/64') -validate_ip_address('8.8.8.8/32') -``` - -The following values will fail, causing compilation to terminate: - -```puppet -validate_ip_address(1) -validate_ip_address(true) -validate_ip_address(0.0.0.256) -validate_ip_address('::1', {}) -validate_ip_address('0.0.0.0.0') -validate_ip_address('3.3.3') -validate_ip_address('23.43.9.22/64') -validate_ip_address('260.2.32.43') -``` - - -#### `validate_legacy` - -Validates a value against both a specified type and a deprecated validation function. Silently passes if both pass, errors if only one validation passes, and fails if both validations return false. - -Arguments: - -* The type to check the value against, -* The full name of the previous validation function, -* The value to be checked, -* An unspecified number of arguments needed for the previous validation function. - -Example: - -```puppet -validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."]) -``` - -This function supports updating modules from Puppet 3-style argument validation (using the stdlib `validate_*` functions) to Puppet 4 data types, without breaking functionality for those depending on Puppet 3-style validation. - -> Note: This function is compatible only with Puppet 4.4.0 (PE 2016.1) and later. - -##### For module users - -If you are running Puppet 4, the `validate_legacy` function can help you find and resolve deprecated Puppet 3 `validate_*` functions. These functions are deprecated as of stdlib version 4.13 and will be removed in a future version of stdlib. - -Puppet 4 allows improved defined type checking using [data types](https://puppet.com/docs/puppet/latest/lang_data.html). Data types avoid some of the problems with Puppet 3's `validate_*` functions, which were sometimes inconsistent. For example, [validate_numeric](#validate_numeric) unintentionally allowed not only numbers, but also arrays of numbers or strings that looked like numbers. - -If you run Puppet 4 and use modules with deprecated `validate_*` functions, you might encounter deprecation messages. The `validate_legacy` function makes these differences visible and makes it easier to move to the clearer Puppet 4 syntax. - -The deprecation messages you get can vary, depending on the modules and data that you use. These deprecation messages appear by default only in Puppet 4: - -* `Notice: Accepting previously invalid value for target type ''`: This message is informational only. You're using values that are allowed by the new type, but would have been invalid by the old validation function. -* `Warning: This method is deprecated, please use the stdlib validate_legacy function`: The module has not yet upgraded to `validate_legacy`. Use the [deprecation](#deprecation) options to silence warnings for now, or submit a fix with the module's developer. See the information [for module developers](#for-module-developers) below for how to fix the issue. -* `Warning: validate_legacy() expected value, got _`: Your code passes a value that was accepted by the Puppet 3-style validation, but will not be accepted by the next version of the module. Most often, you can fix this by removing quotes from numbers or booleans. -* `Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, validate_legacy() expected value, got `: Your code passes a value that is not acceptable to either the new or the old style validation. - -##### For module developers - -The `validate_legacy` function helps you move from Puppet 3 style validation to Puppet 4 validation without breaking functionality your module's users depend on. - -Moving to Puppet 4 type validation allows much better defined type checking using [data types](https://puppet.com/docs/puppet/latest/lang_data.html). Many of Puppet 3's `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics. - -For each parameter of your classes and defined types, choose a new Puppet 4 data type to use. In most cases, the new data type allows a different set of values than the original `validate_*` function. The situation then looks like this: - -| | `validate_` pass | `validate_` fail | -| ------------ | ---------------- | ---------------- | -| matches type | pass | pass, notice | -| fails type | pass, deprecated | fail | - -The code after the validation still has to handle all possible values for now, but users of your code can change their manifests to pass only values that match the new type. - -For each `validate_*` function in stdlib, there is a matching `Stdlib::Compat::*` type that allows the appropriate set of values. See the documentation in the `types/` directory in the stdlib source code for caveats. - -For example, given a class that should accept only numbers, like this: - -```puppet -class example($value) { - validate_numeric($value) -``` - -the resulting validation code looks like this: - -```puppet -class example( - Variant[Stdlib::Compat::Numeric, Numeric] $value -) { - validate_legacy(Numeric, 'validate_numeric', $value) -``` - -Here, the type of `$value` is defined as `Variant[Stdlib::Compat::Numeric, Numeric]`, which allows any `Numeric` (the new type), as well as all values previously accepted by `validate_numeric` (through `Stdlib::Compat::Numeric`). - -The call to `validate_legacy` takes care of triggering the correct log or fail message for you. It requires the new type, the previous validation function name, and all arguments to that function. - -If your module still supported Puppet 3, this is a breaking change. Update your `metadata.json` requirements section to indicate that your module no longer supports Puppet 3, and bump the major version of your module. With this change, all existing tests for your module should still pass. Create additional tests for the new possible values. - -As a breaking change, this is also a good time to call [`deprecation`](#deprecation) for any parameters you want to get rid of, or to add additional constraints on your parameters. - -After releasing this version, you can release another breaking change release where you remove all compat types and all calls to `validate_legacy`. At that time, you can also go through your code and remove any leftovers dealing with the previously possible values. - -Always note such changes in your CHANGELOG and README. - -#### `validate_numeric` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates a numeric value, or an array or string of numeric values. Terminates catalog compilation if any of the checks fail. - -Arguments: - -* A numeric value, or an array or string of numeric values. -* Optionally, a maximum value. (All elements of) the first argument has to be less or equal to this max. -* Optionally, a minimum value. (All elements of) the first argument has to be greater or equal to this min. - -This function fails if the first argument is not a numeric (Integer or Float) or an array or string of numerics, or if the second and third arguments are not convertable to a numeric. If, and only if, a minimum is given, the second argument can be an empty string or `undef`, which serves as a placeholder to ensure the minimum check. - -For passing and failing usage, see [`validate_integer`](#validate-integer). The same values pass and fail, except that `validate_numeric` also allows floating point values. - -*Type*: statement. - -#### `validate_re` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Performs simple validation of a string against one or more regular expressions. - -Arguments: - -* The string to test, as the first argument. If this argument is not a string, compilation terminates. Use quotes to force stringification. -* A stringified regular expression (without the // delimiters) or an array of regular expressions, as the second argument. -* Optionally, the error message raised and shown to the user, as a third argument. - -If none of the regular expressions in the second argument match the string passed in the first argument, compilation terminates with a parse error. - -The following strings validate against the regular expressions: - -```puppet -validate_re('one', '^one$') -validate_re('one', [ '^one', '^two' ]) -``` - -The following string fails to validate, causing compilation to terminate: - -```puppet -validate_re('one', [ '^two', '^three' ]) -``` - -To set the error message: - -```puppet -validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') -``` - -To force stringification, use quotes: - - ``` - validate_re("${::operatingsystemmajrelease}", '^[57]$') - ``` - -*Type*: statement. - -#### `validate_slength` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates that a string (or an array of strings) is less than or equal to a specified length - -Arguments: - -* A string or an array of strings, as a first argument. -* A numeric value for maximum length, as a second argument. -* Optionally, a numeric value for minimum length, as a third argument. - - The following values pass: - -```puppet -validate_slength("discombobulate",17) -validate_slength(["discombobulate","moo"],17) -validate_slength(["discombobulate","moo"],17,3) -``` - -The following values fail: - -```puppet -validate_slength("discombobulate",1) -validate_slength(["discombobulate","thermometer"],5) -validate_slength(["discombobulate","moo"],17,10) -``` - -*Type*: statement. - -#### `validate_string` - -**Deprecated:** Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy). - -Validates that all passed values are string data structures. Aborts catalog compilation if any value fails this check. - -The following values pass: - -```puppet -$my_string = "one two" -validate_string($my_string, 'three') -``` - -The following values fail, causing compilation to terminate: - -```puppet -validate_string(true) -validate_string([ 'some', 'array' ]) -``` - -> *Note:* validate_string(`undef`) will not fail in this version of the functions API. - -Instead, use: - - ``` - if $var == `undef` { - fail('...') - } - ``` - -*Type*: statement. - -#### `validate_x509_rsa_key_pair` - -Validates a PEM-formatted X.509 certificate and private key using OpenSSL. -Verifies that the certificate's signature was created from the supplied key. - -Fails catalog compilation if any value fails this check. - -Arguments: - -* An X.509 certificate as the first argument. -* An RSA private key, as the second argument. - -```puppet -validate_x509_rsa_key_pair($cert, $key) -``` - -*Type*: statement. - -#### `values` - -**Deprecated:** This function has been replaced with a built-in [`values`](https://puppet.com/docs/puppet/latest/function.html#values) function as of Puppet 5.5.0. - -Returns the values of a given hash. - -For example, given `$hash = {'a'=1, 'b'=2, 'c'=3} values($hash)` returns [1,2,3]. - -*Type*: rvalue. - -#### `values_at` - -Finds values inside an array based on location. - -Arguments: - -* The array you want to analyze, as the first argument. -* Any combination of the following values, as the second argument: - * A single numeric index - * A range in the form of 'start-stop' (eg. 4-9) - * An array combining the above - -For example: - -* `values_at(['a','b','c'], 2)` returns ['c']. -* `values_at(['a','b','c'], ["0-1"])` returns ['a','b']. -* `values_at(['a','b','c','d','e'], [0, "2-3"])` returns ['a','c','d']. - -Since Puppet 4.0.0, you can slice an array with index and count directly in the language. -A negative value is taken to be "from the end" of the array, for example: - -```puppet -['a', 'b', 'c', 'd'][1, 2] # results in ['b', 'c'] -['a', 'b', 'c', 'd'][2, -1] # results in ['c', 'd'] -['a', 'b', 'c', 'd'][1, -2] # results in ['b', 'c'] -``` - -*Type*: rvalue. - -#### `zip` - -Takes one element from first array given and merges corresponding elements from second array given. This generates a sequence of n-element arrays, where *n* is one more than the count of arguments. For example, `zip(['1','2','3'],['4','5','6'])` results in ["1", "4"], ["2", "5"], ["3", "6"]. *Type*: rvalue. +Returns the default provider Puppet uses to manage services on this system - ## Limitations As of Puppet Enterprise 3.7, the stdlib module is no longer included in PE. PE users should install the most recent release of stdlib for compatibility with Puppet modules. For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/metadata.json) - ## Development -Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://docs.puppet.com/forge/contributing.html). +Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/CONTRIBUTING.md). To report or research a bug with any part of this module, please go to [http://tickets.puppetlabs.com/browse/MODULES](http://tickets.puppetlabs.com/browse/MODULES). - ## Contributors The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors](https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors). diff --git a/3rdparty/modules/stdlib/REFERENCE.md b/3rdparty/modules/stdlib/REFERENCE.md new file mode 100644 index 000000000..85d452adf --- /dev/null +++ b/3rdparty/modules/stdlib/REFERENCE.md @@ -0,0 +1,7057 @@ +# Reference + + +## Table of Contents + +**Classes** + +* [`stdlib`](#stdlib): This module manages stdlib. +* [`stdlib::stages`](#stdlibstages): This class manages a standard set of run stages for Puppet. It is managed by +the stdlib class, and should not be declared independently. + +**Resource types** + +* [`anchor`](#anchor): A simple resource type intended to be used as an anchor in a composite class. +* [`file_line`](#file_line): Ensures that a given line is contained within a file. + +**Functions** + +* [`abs`](#abs): **Deprecated:** Returns the absolute value of a number +* [`any2array`](#any2array): This converts any object to an array containing that object. +* [`any2bool`](#any2bool): Converts 'anything' to a boolean. +* [`assert_private`](#assert_private): Sets the current class or definition as private. +* [`base64`](#base64): Base64 encode or decode a string based on the command and the string submitted +* [`basename`](#basename): Strips directory (and optional suffix) from a filename +* [`bool2num`](#bool2num): Converts a boolean to a number. +* [`bool2str`](#bool2str): Converts a boolean to a string using optionally supplied arguments. +* [`camelcase`](#camelcase): **Deprecated** Converts the case of a string or all strings in an array to camel case. +* [`capitalize`](#capitalize): **Deprecated** Capitalizes the first letter of a string or array of strings. +* [`ceiling`](#ceiling): **Deprecated** Returns the smallest integer greater or equal to the argument. +* [`chomp`](#chomp): **Deprecated** Removes the record separator from the end of a string or an array of strings. +* [`chop`](#chop): **Deprecated** Returns a new string with the last character removed. +* [`clamp`](#clamp): Keeps value within the range [Min, X, Max] by sort based on integer value +(parameter order doesn't matter). +* [`concat`](#concat): Appends the contents of multiple arrays into array 1. +* [`convert_base`](#convert_base): Converts a given integer or base 10 string representing an integer to a +specified base, as a string. +* [`count`](#count): Counts the number of elements in array. +* [`deep_merge`](#deep_merge): Recursively merges two or more hashes together and returns the resulting hash. +* [`defined_with_params`](#defined_with_params): Takes a resource reference and an optional hash of attributes. +* [`delete`](#delete): Deletes all instances of a given element from an array, substring from a +string, or key from a hash. +* [`delete_at`](#delete_at): Deletes a determined indexed value from an array. +* [`delete_regex`](#delete_regex): Deletes all instances of a given element that match a regular expression +from an array or key from a hash. +* [`delete_undef_values`](#delete_undef_values): Returns a copy of input hash or array with all undefs deleted. +* [`delete_values`](#delete_values): Deletes all instances of a given value from a hash. +* [`deprecation`](#deprecation): Function to print deprecation warnings (this is the 3.X version of it). +* [`deprecation`](#deprecation): Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message te +* [`difference`](#difference): This function returns the difference between two arrays. +* [`dig`](#dig): **DEPRECATED** Retrieves a value within multiple layers of hashes and arrays via an +array of keys containing a path. +* [`dig44`](#dig44): **DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value +or the default value if nothing was found. +* [`dirname`](#dirname): Returns the dirname of a path. +* [`dos2unix`](#dos2unix): Returns the Unix version of the given string. +* [`downcase`](#downcase): **Deprecated:** Converts the case of a string or all strings in an array to lower case. +* [`empty`](#empty): **Deprecated:** Returns true if the variable is empty. +* [`enclose_ipv6`](#enclose_ipv6): Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. +* [`ensure_packages`](#ensure_packages): Takes a list of packages and only installs them if they don't already exist. +* [`ensure_resource`](#ensure_resource): Takes a resource type, title, and a list of attributes that describe a +resource. +* [`ensure_resources`](#ensure_resources): Takes a resource type, title (only hash), and a list of attributes that describe a +resource. +* [`fact`](#fact): Digs into the facts hash using dot-notation +* [`flatten`](#flatten): This function flattens any deeply nested arrays and returns a single flat array +as a result. +* [`floor`](#floor): Returns the largest integer less or equal to the argument. +* [`fqdn_rand_string`](#fqdn_rand_string): Generates a random alphanumeric string. Combining the `$fqdn` fact and an +optional seed for repeatable randomness. +* [`fqdn_rotate`](#fqdn_rotate): Rotates an array or string a random number of times, combining the `$fqdn` fact +and an optional seed for repeatable randomness. +* [`fqdn_uuid`](#fqdn_uuid): Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based +on an FQDN string under the DNS namespace +* [`get_module_path`](#get_module_path): Returns the absolute path of the specified module for the current +environment. +* [`getparam`](#getparam): Returns the value of a resource's parameter. +* [`getvar`](#getvar): Lookup a variable in a given namespace. +* [`glob`](#glob): Uses same patterns as Dir#glob. +* [`grep`](#grep): This function searches through an array and returns any elements that match +the provided regular expression. +* [`has_interface_with`](#has_interface_with): Returns boolean based on kind and value. +* [`has_ip_address`](#has_ip_address): Returns true if the client has the requested IP address on some interface. +* [`has_ip_network`](#has_ip_network): Returns true if the client has an IP address within the requested network. +* [`has_key`](#has_key): **Deprecated:** Determine if a hash has a certain key value. +* [`hash`](#hash): **Deprecated:** This function converts an array into a hash. +* [`intersection`](#intersection): This function returns an array of the intersection of two. +* [`is_a`](#is_a): Boolean check to determine whether a variable is of a given data type. +This is equivalent to the `=~` type checks. +* [`is_absolute_path`](#is_absolute_path): **Deprecated:** Returns boolean true if the string represents an absolute path in the filesystem. +* [`is_absolute_path`](#is_absolute_path): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_array`](#is_array): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_array`](#is_array): **Deprecated:** Returns true if the variable passed to this function is an array. +* [`is_bool`](#is_bool): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_bool`](#is_bool): **Deprecated:** Returns true if the variable passed to this function is a boolean. +* [`is_domain_name`](#is_domain_name): **Deprecated:** Returns true if the string passed to this function is +a syntactically correct domain name. +* [`is_email_address`](#is_email_address): **Deprecated:** Returns true if the string passed to this function is a valid email address. +* [`is_float`](#is_float): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_float`](#is_float): **Deprecated:** Returns true if the variable passed to this function is a float. +* [`is_function_available`](#is_function_available): **Deprecated:** Determines whether the Puppet runtime has access to a function by that name. +* [`is_hash`](#is_hash): **Deprecated:** Returns true if the variable passed to this function is a hash. +* [`is_integer`](#is_integer): **Deprecated:** Returns true if the variable passed to this function is an Integer or +a decimal (base 10) integer in String form. +* [`is_ip_address`](#is_ip_address): **Deprecated:** Returns true if the string passed to this function is a valid IP address. +* [`is_ip_address`](#is_ip_address): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_ipv4_address`](#is_ipv4_address): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_ipv4_address`](#is_ipv4_address): **Deprecated:** Returns true if the string passed to this function is a valid IPv4 address. +* [`is_ipv6_address`](#is_ipv6_address): **Deprecated:** Returns true if the string passed to this function is a valid IPv6 address. +* [`is_ipv6_address`](#is_ipv6_address): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_mac_address`](#is_mac_address): **Deprecated:** Returns true if the string passed to this function is a valid mac address. +* [`is_numeric`](#is_numeric): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`is_numeric`](#is_numeric): **Deprecated:** Returns true if the given value is numeric. +* [`is_string`](#is_string): **Deprecated:** Returns true if the variable passed to this function is a string. +* [`is_string`](#is_string): Wrapper that calls the Puppet 3.x funtion of the same name. +* [`join`](#join): **Deprecated:** This function joins an array into a string using a separator. +* [`join_keys_to_values`](#join_keys_to_values): This function joins each key of a hash to that key's corresponding value with a +separator. +* [`keys`](#keys): **Deprecated:** Returns the keys of a hash as an array. +* [`length`](#length): **Deprecated:** A function to eventually replace the old size() function for stdlib +* [`load_module_metadata`](#load_module_metadata): This function loads the metadata of a given module. +* [`loadjson`](#loadjson): Load a JSON file containing an array, string, or hash, and return the data +in the corresponding native data type. +* [`loadyaml`](#loadyaml): Load a YAML file containing an array, string, or hash, and return the data +in the corresponding native data type. +* [`lstrip`](#lstrip): **Deprecated:** Strips leading spaces to the left of a string. +* [`max`](#max): **Deprecated:** Returns the highest value of all arguments. +* [`member`](#member): This function determines if a variable is a member of an array. +* [`merge`](#merge): Merges two or more hashes together and returns the resulting hash. +* [`merge`](#merge): Merges two or more hashes together or hashes resulting from iteration, and returns +the resulting hash. +* [`min`](#min): **Deprecated:** Returns the lowest value of all arguments. +* [`num2bool`](#num2bool): This function converts a number or a string representation of a number into a +true boolean. +* [`os_version_gte`](#os_version_gte): Checks if the OS version is at least a certain version. +* [`parsejson`](#parsejson): This function accepts JSON as a string and converts it into the correct +Puppet structure. +* [`parseyaml`](#parseyaml): This function accepts YAML as a string and converts it into the correct +Puppet structure. +* [`pick`](#pick): This function is similar to a coalesce function in SQL in that it will return +the first value in a list of values that is not undefined or an empty string. +* [`pick_default`](#pick_default): This function will return the first value in a list of values that is not undefined or an empty string. +* [`prefix`](#prefix): This function applies a prefix to all elements in an array or a hash. +* [`private`](#private): **Deprecated:** Sets the current class or definition as private. +Calling the class or definition from outside the current module will fail. +* [`pry`](#pry): This function invokes a pry debugging session in the current scope object. +* [`pw_hash`](#pw_hash): Hashes a password using the crypt function. Provides a hash usable +on most POSIX systems. +* [`range`](#range): When given range in the form of (start, stop) it will extrapolate a range as +an array. +* [`regexpescape`](#regexpescape): Regexp escape a string or array of strings. +Requires either a single string or an array as an input. +* [`reject`](#reject): This function searches through an array and rejects all elements that match +the provided regular expression. +* [`reverse`](#reverse): Reverses the order of a string or array. +* [`round`](#round): Rounds a number to the nearest integer +* [`rstrip`](#rstrip): Strips leading spaces to the right of the string. +* [`seeded_rand`](#seeded_rand): Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness. +* [`seeded_rand_string`](#seeded_rand_string): Generates a consistent random string of specific length based on provided seed. +* [`shell_escape`](#shell_escape): Escapes a string so that it can be safely used in a Bourne shell command line. +* [`shell_join`](#shell_join): Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are then joined together +* [`shell_split`](#shell_split): Splits a string into an array of tokens in the same way the Bourne shell does. +* [`shuffle`](#shuffle): @summary Randomizes the order of a string or array elements. +* [`size`](#size): Returns the number of elements in a string, an array or a hash +* [`sort`](#sort): Sorts strings and arrays lexically. +* [`sprintf_hash`](#sprintf_hash): Uses sprintf with named references. +* [`squeeze`](#squeeze): Returns a new string where runs of the same character that occur in this set are replaced by a single character. +* [`stdlib::extname`](#stdlibextname): Returns the Extension (the Portion of Filename in Path starting from the +last Period). +* [`stdlib::ip_in_range`](#stdlibip_in_range): Returns true if the ipaddress is within the given CIDRs +* [`str2bool`](#str2bool): This converts a string to a boolean. +* [`str2saltedsha512`](#str2saltedsha512): This converts a string to a salted-SHA512 password hash (which is used for +OS X versions >= 10.7). +* [`strftime`](#strftime): This function returns formatted time. +* [`strip`](#strip): This function removes leading and trailing whitespace from a string or from +every string inside an array. +* [`suffix`](#suffix): This function applies a suffix to all elements in an array, or to the keys +in a hash. +* [`swapcase`](#swapcase): This function will swap the existing case of a string. +* [`time`](#time): This function will return the current time since epoch as an integer. +* [`to_bytes`](#to_bytes): Converts the argument into bytes, for example 4 kB becomes 4096. +* [`to_json`](#to_json): Convert a data structure and output to JSON +* [`to_json_pretty`](#to_json_pretty): Convert data structure and output to pretty JSON +* [`to_yaml`](#to_yaml): Convert a data structure and output it as YAML +* [`try_get_value`](#try_get_value): **DEPRECATED:** this function is deprecated, please use dig() instead. +* [`type`](#type): **DEPRECATED:** This function will cease to function on Puppet 4; +* [`type3x`](#type3x): **DEPRECATED:** This function will be removed when Puppet 3 support is dropped; please migrate to the new parser's typing system. +* [`type_of`](#type_of): Returns the type of the passed value. +* [`union`](#union): This function returns a union of two or more arrays. +* [`unique`](#unique): This function will remove duplicates from strings and arrays. +* [`unix2dos`](#unix2dos): Returns the DOS version of the given string. +* [`upcase`](#upcase): Converts a string or an array of strings to uppercase. +* [`uriescape`](#uriescape): Urlencodes a string or array of strings. +Requires either a single string or an array as an input. +* [`validate_absolute_path`](#validate_absolute_path): Validate the string represents an absolute path in the filesystem. This function works +for windows and unix style paths. +* [`validate_absolute_path`](#validate_absolute_path): Validate the string represents an absolute path in the filesystem. +* [`validate_array`](#validate_array): Validate the passed value represents an array. +* [`validate_array`](#validate_array): Validate that all passed values are array data structures. Abort catalog +compilation if any value fails this check. +* [`validate_augeas`](#validate_augeas): Perform validation of a string using an Augeas lens +* [`validate_bool`](#validate_bool): Validate that all passed values are either true or false. Abort catalog +compilation if any value fails this check. +* [`validate_bool`](#validate_bool): Validate the passed value represents a boolean. +* [`validate_cmd`](#validate_cmd): Perform validation of a string with an external command. +* [`validate_domain_name`](#validate_domain_name): Validate that all values passed are syntactically correct domain names. +Fail compilation if any value fails this check. +* [`validate_email_address`](#validate_email_address): Validate that all values passed are valid email addresses. +Fail compilation if any value fails this check. +* [`validate_hash`](#validate_hash): Validate the passed value represents a hash. +* [`validate_hash`](#validate_hash): Validate that all passed values are hash data structures. Abort catalog +compilation if any value fails this check. +* [`validate_integer`](#validate_integer): Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail. +* [`validate_integer`](#validate_integer): Validate the passed value represents an integer. +* [`validate_ip_address`](#validate_ip_address): Validate the passed value represents an ip_address. +* [`validate_ip_address`](#validate_ip_address): Validate that all values passed are valid IP addresses, +regardless they are IPv4 or IPv6 +Fail compilation if any value fails this check. +* [`validate_ipv4_address`](#validate_ipv4_address): Validate the passed value represents an ipv4_address. +* [`validate_ipv4_address`](#validate_ipv4_address): Validate that all values passed are valid IPv4 addresses. +Fail compilation if any value fails this check. +* [`validate_ipv6_address`](#validate_ipv6_address): Validate the passed value represents an ipv6_address. +* [`validate_ipv6_address`](#validate_ipv6_address): Validate that all values passed are valid IPv6 addresses. +Fail compilation if any value fails this check. +* [`validate_legacy`](#validate_legacy): Validate a value against both the target_type (new) and the previous_validation function (old). +* [`validate_numeric`](#validate_numeric): Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail. +* [`validate_numeric`](#validate_numeric): Validate the passed value represents a numeric value. +* [`validate_re`](#validate_re): Perform simple validation of a string against one or more regular +expressions. +* [`validate_re`](#validate_re): Perform validation of a string against one or more regular +expressions. +* [`validate_slength`](#validate_slength): Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. +An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings, +and if arg 2 and arg 3 are not convertable to a number. +* [`validate_slength`](#validate_slength): Validate that a passed string has length less/equal with the passed value +* [`validate_string`](#validate_string): Validate that all passed values are string data structures. +* [`validate_string`](#validate_string): Validate that all passed values are string data structures +* [`validate_x509_rsa_key_pair`](#validate_x509_rsa_key_pair): Validates a PEM-formatted X.509 certificate and RSA private key using +OpenSSL. Verifies that the certficate's signature was created from the +supplied key. +* [`values`](#values): When given a hash this function will return the values of that hash. +* [`values_at`](#values_at): Finds value inside an array based on location. +* [`zip`](#zip): Takes one element from first array and merges corresponding elements from second array. + +**Data types** + +* [`Stdlib::Absolutepath`](#stdlibabsolutepath): A strict absolutepath type +* [`Stdlib::Base32`](#stdlibbase32): Type to match base32 String +* [`Stdlib::Base64`](#stdlibbase64): Type to match base64 String +* [`Stdlib::Compat::Absolute_path`](#stdlibcompatabsolute_path): Emulate the is_absolute_path and validate_absolute_path functions The first pattern is originally from is_absolute_path, which had it from 2 +* [`Stdlib::Compat::Array`](#stdlibcompatarray): Emulate the is_array and validate_array functions +* [`Stdlib::Compat::Bool`](#stdlibcompatbool): Emulate the is_bool and validate_bool functions +* [`Stdlib::Compat::Float`](#stdlibcompatfloat): Emulate the is_float function The regex is what's currently used in is_float To keep your development moving forward, you can also add a depr +* [`Stdlib::Compat::Hash`](#stdlibcompathash): Emulate the is_hash and validate_hash functions +* [`Stdlib::Compat::Integer`](#stdlibcompatinteger): Emulate the is_integer and validate_integer functions The regex is what's currently used in is_integer validate_numeric also allows range che +* [`Stdlib::Compat::Ip_address`](#stdlibcompatip_address): +* [`Stdlib::Compat::Ipv4`](#stdlibcompatipv4): Emulate the validate_ipv4_address and is_ipv4_address functions +* [`Stdlib::Compat::Ipv6`](#stdlibcompatipv6): +* [`Stdlib::Compat::Numeric`](#stdlibcompatnumeric): Emulate the is_numeric and validate_numeric functions The regex is what's currently used in is_numeric validate_numeric also allows range che +* [`Stdlib::Compat::String`](#stdlibcompatstring): Emulate the is_string and validate_string functions +* [`Stdlib::Ensure::Service`](#stdlibensureservice): +* [`Stdlib::Filemode`](#stdlibfilemode): See `man chmod.1` for the regular expression for symbolic mode +* [`Stdlib::Filesource`](#stdlibfilesource): Validate the source parameter on file types +* [`Stdlib::Fqdn`](#stdlibfqdn): +* [`Stdlib::HTTPSUrl`](#stdlibhttpsurl): +* [`Stdlib::HTTPUrl`](#stdlibhttpurl): +* [`Stdlib::Host`](#stdlibhost): +* [`Stdlib::IP::Address`](#stdlibipaddress): +* [`Stdlib::IP::Address::Nosubnet`](#stdlibipaddressnosubnet): +* [`Stdlib::IP::Address::V4`](#stdlibipaddressv4): +* [`Stdlib::IP::Address::V4::CIDR`](#stdlibipaddressv4cidr): +* [`Stdlib::IP::Address::V4::Nosubnet`](#stdlibipaddressv4nosubnet): +* [`Stdlib::IP::Address::V6`](#stdlibipaddressv6): +* [`Stdlib::IP::Address::V6::Alternative`](#stdlibipaddressv6alternative): +* [`Stdlib::IP::Address::V6::CIDR`](#stdlibipaddressv6cidr): +* [`Stdlib::IP::Address::V6::Compressed`](#stdlibipaddressv6compressed): +* [`Stdlib::IP::Address::V6::Full`](#stdlibipaddressv6full): +* [`Stdlib::IP::Address::V6::Nosubnet`](#stdlibipaddressv6nosubnet): +* [`Stdlib::IP::Address::V6::Nosubnet::Alternative`](#stdlibipaddressv6nosubnetalternative): +* [`Stdlib::IP::Address::V6::Nosubnet::Compressed`](#stdlibipaddressv6nosubnetcompressed): +* [`Stdlib::IP::Address::V6::Nosubnet::Full`](#stdlibipaddressv6nosubnetfull): +* [`Stdlib::MAC`](#stdlibmac): A type for a MAC address +* [`Stdlib::ObjectStore`](#stdlibobjectstore): +* [`Stdlib::ObjectStore::GSUri`](#stdlibobjectstoregsuri): +* [`Stdlib::ObjectStore::S3Uri`](#stdlibobjectstores3uri): +* [`Stdlib::Port`](#stdlibport): +* [`Stdlib::Port::Privileged`](#stdlibportprivileged): +* [`Stdlib::Port::Unprivileged`](#stdlibportunprivileged): +* [`Stdlib::Syslogfacility`](#stdlibsyslogfacility): +* [`Stdlib::Unixpath`](#stdlibunixpath): this regex rejects any path component that does not start with "/" or is NUL +* [`Stdlib::Windowspath`](#stdlibwindowspath): +* [`Stdlib::Yes_no`](#stdlibyes_no): + +## Classes + +### stdlib + +Most of stdlib's features are automatically loaded by Puppet, but this class should be +declared in order to use the standardized run stages. + +Declares all other classes in the stdlib module. Currently, this consists +of stdlib::stages. + +### stdlib::stages + +Declares various run-stages for deploying infrastructure, +language runtimes, and application layers. + +The high level stages are (in order): + * setup + * main + * runtime + * setup_infra + * deploy_infra + * setup_app + * deploy_app + * deploy + +#### Examples + +##### + +```puppet +node default { + include ::stdlib + class { java: stage => 'runtime' } +} +``` + +## Resource types + +### anchor + +In Puppet 2.6, when a class declares another class, the resources in the +interior class are not contained by the exterior class. This interacts badly +with the pattern of composing complex modules from smaller classes, as it +makes it impossible for end users to specify order relationships between the +exterior class and other modules. + +The anchor type lets you work around this. By sandwiching any interior +classes between two no-op resources that _are_ contained by the exterior +class, you can ensure that all resources in the module are contained. + +``` +class ntp { + # These classes will have the correct order relationship with each + # other. However, without anchors, they won't have any order + # relationship to Class['ntp']. + class { 'ntp::package': } + -> class { 'ntp::config': } + -> class { 'ntp::service': } + + # These two resources "anchor" the composed classes within the ntp + # class. + anchor { 'ntp::begin': } -> Class['ntp::package'] + Class['ntp::service'] -> anchor { 'ntp::end': } +} +``` + +This allows the end user of the ntp module to establish require and before +relationships with Class['ntp']: + +``` +class { 'ntp': } -> class { 'mcollective': } +class { 'mcollective': } -> class { 'ntp': } +``` + +#### Parameters + +The following parameters are available in the `anchor` type. + +##### `name` + +namevar + +The name of the anchor resource. + +### file_line + +The implementation matches the full line, including whitespace at the +beginning and end. If the line is not contained in the given file, Puppet +will append the line to the end of the file to ensure the desired state. +Multiple resources may be declared to manage multiple lines in the same file. + +* Ensure Example +``` +file_line { 'sudo_rule': + path => '/etc/sudoers', + line => '%sudo ALL=(ALL) ALL', +} + +file_line { 'sudo_rule_nopw': + path => '/etc/sudoers', + line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', +} +``` +In this example, Puppet will ensure both of the specified lines are +contained in the file /etc/sudoers. + +* Match Example + +``` +file_line { 'bashrc_proxy': + ensure => present, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + match => '^export\ HTTP_PROXY\=', +} +``` + +In this code example match will look for a line beginning with export +followed by HTTP_PROXY and replace it with the value in line. + +* Examples With `ensure => absent`: + +This type has two behaviors when `ensure => absent` is set. + +One possibility is to set `match => ...` and `match_for_absence => true`, +as in the following example: + +``` +file_line { 'bashrc_proxy': + ensure => absent, + path => '/etc/bashrc', + match => '^export\ HTTP_PROXY\=', + match_for_absence => true, +} +``` + +In this code example match will look for a line beginning with export +followed by HTTP_PROXY and delete it. If multiple lines match, an +error will be raised unless the `multiple => true` parameter is set. + +Note that the `line => ...` parameter would be accepted BUT IGNORED in +the above example. + +The second way of using `ensure => absent` is to specify a `line => ...`, +and no match: + +``` +file_line { 'bashrc_proxy': + ensure => absent, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', +} +``` + +> *Note:* +When ensuring lines are absent this way, the default behavior +this time is to always remove all lines matching, and this behavior +can't be disabled. + +* Encoding example: + +``` +file_line { "XScreenSaver": + ensure => present, + path => '/root/XScreenSaver', + line => "*lock: 10:00:00", + match => '^*lock:', + encoding => "iso-8859-1", +} +``` + +Files with special characters that are not valid UTF-8 will give the +error message "invalid byte sequence in UTF-8". In this case, determine +the correct file encoding and specify the correct encoding using the +encoding attribute, the value of which needs to be a valid Ruby character +encoding. + +**Autorequires:** If Puppet is managing the file that will contain the line +being managed, the file_line resource will autorequire that file. + +#### Properties + +The following properties are available in the `file_line` type. + +##### `ensure` + +Valid values: present, absent + +Manage the state of this type. + +Default value: present + +##### `line` + +The line to be appended to the file or used to replace matches found by the match attribute. + +#### Parameters + +The following parameters are available in the `file_line` type. + +##### `name` + +namevar + +An arbitrary name used as the identity of the resource. + +##### `match` + +An optional ruby regular expression to run against existing lines in the file. +If a match is found, we replace that line rather than adding a new line. +A regex comparison is performed against the line value and if it does not +match an exception will be raised. + +##### `match_for_absence` + +Valid values: `true`, `false` + +An optional value to determine if match should be applied when ensure => absent. +If set to true and match is set, the line that matches match will be deleted. +If set to false (the default), match is ignored when ensure => absent. +When `ensure => present`, match_for_absence is ignored. + +Default value: `false` + +##### `multiple` + +Valid values: `true`, `false` + +An optional value to determine if match can change multiple lines. +If set to false, an exception will be raised if more than one line matches + +##### `after` + +An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place) +This is also takes a regex. + +##### `path` + +The file Puppet will ensure contains the line specified by the line parameter. + +##### `replace` + +Valid values: `true`, `false` + +If true, replace line that matches. If false, do not write line if a match is found + +Default value: `true` + +##### `replace_all_matches_not_matching_line` + +Valid values: `true`, `false` + +Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, regardless of whether the specified line is already present in the file. + +Default value: `false` + +##### `encoding` + +For files that are not UTF-8 encoded, specify encoding such as iso-8859-1 + +Default value: UTF-8 + +##### `append_on_no_match` + +Valid values: `true`, `false` + +If true, append line if match is not found. If false, do not append line if a match is not found + +Default value: `true` + +## Functions + +### abs + +Type: Ruby 3.x API + +For example -34.56 becomes 34.56. +Takes a single integer or float value as an argument. + +> *Note:* + **Deprected** from Puppet 6.0.0, the built-in + ['abs'](https://puppet.com/docs/puppet/6.4/function.html#abs)function will be used instead. + +#### `abs()` + +For example -34.56 becomes 34.56. +Takes a single integer or float value as an argument. + +> *Note:* + **Deprected** from Puppet 6.0.0, the built-in + ['abs'](https://puppet.com/docs/puppet/6.4/function.html#abs)function will be used instead. + +Returns: `Any` The absolute value of the given number if it was an Integer + +### any2array + +Type: Ruby 3.x API + +Empty argument lists are converted to an empty array. Arrays are left +untouched. Hashes are converted to arrays of alternating keys and values. + +> *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) + function is used to create a new Array.. + + ``` + $hsh = {'key' => 42, 'another-key' => 100} + notice(Array($hsh)) + ``` + +Would notice `[['key', 42], ['another-key', 100]]` + +The Array data type also has a special mode to "create an array if not already an array" + + ``` + notice(Array({'key' => 42, 'another-key' => 100}, true)) + ``` + +Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being +transformed into an array. + +#### `any2array()` + +Empty argument lists are converted to an empty array. Arrays are left +untouched. Hashes are converted to arrays of alternating keys and values. + +> *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) + function is used to create a new Array.. + + ``` + $hsh = {'key' => 42, 'another-key' => 100} + notice(Array($hsh)) + ``` + +Would notice `[['key', 42], ['another-key', 100]]` + +The Array data type also has a special mode to "create an array if not already an array" + + ``` + notice(Array({'key' => 42, 'another-key' => 100}, true)) + ``` + +Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being +transformed into an array. + +Returns: `Array` The new array containing the given object + +### any2bool + +Type: Ruby 3.x API + +In practise it does the following: +* Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true +* Strings such as 0,F,f,N,n,FALSE,no,'false' will return false +* Booleans will just return their original value +* Number (or a string representation of a number) > 0 will return true, otherwise false +* undef will return false +* Anything else will return true + +Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) +function. + +#### `any2bool()` + +In practise it does the following: +* Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true +* Strings such as 0,F,f,N,n,FALSE,no,'false' will return false +* Booleans will just return their original value +* Number (or a string representation of a number) > 0 will return true, otherwise false +* undef will return false +* Anything else will return true + +Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) +function. + +Returns: `Boolean` The boolean value of the object that was given + +### assert_private + +Type: Ruby 3.x API + +Calling the class or definition from outside the current module will fail. + +#### `assert_private()` + +Calling the class or definition from outside the current module will fail. + +Returns: `Any` set the current class or definition as private. + +### base64 + +Type: Ruby 3.x API + +> **Note:* + Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings. + See the `new()` function for the Binary and String types for documentation. Also see `binary_file()` + function for reading a file with binary (non UTF-8) content. + +#### Examples + +##### Example usage + +```puppet + +Encode and decode a string + + $encodestring = base64('encode', 'thestring') + $decodestring = base64('decode', 'dGhlc3RyaW5n') + +Explicitly define encode/decode method: default, strict, urlsafe + + $method = 'default' + $encodestring = base64('encode', 'thestring', $method) + $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) + +Encode a string as if it was binary + + $encodestring = String(Binary('thestring', '%s')) + +Decode a Binary assuming it is an UTF-8 String + + $decodestring = String(Binary("dGhlc3RyaW5n"), "%s") +``` + +#### `base64()` + +> **Note:* + Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings. + See the `new()` function for the Binary and String types for documentation. Also see `binary_file()` + function for reading a file with binary (non UTF-8) content. + +Returns: `String` The encoded/decoded va + +##### Examples + +###### Example usage + +```puppet + +Encode and decode a string + + $encodestring = base64('encode', 'thestring') + $decodestring = base64('decode', 'dGhlc3RyaW5n') + +Explicitly define encode/decode method: default, strict, urlsafe + + $method = 'default' + $encodestring = base64('encode', 'thestring', $method) + $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) + +Encode a string as if it was binary + + $encodestring = String(Binary('thestring', '%s')) + +Decode a Binary assuming it is an UTF-8 String + + $decodestring = String(Binary("dGhlc3RyaW5n"), "%s") +``` + +### basename + +Type: Ruby 3.x API + +Strips directory (and optional suffix) from a filename + +#### `basename()` + +The basename function. + +Returns: `String` The stripped filename + +### bool2num + +Type: Ruby 3.x API + +Converts the values: + ``` + false, f, 0, n, and no to 0 + true, t, 1, y, and yes to 1 + ``` +Requires a single boolean or string as an input. + +> *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric), + [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and + [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float) + function are used to convert to numeric values. + ``` + notice(Integer(false)) # Notices 0 + notice(Float(true)) # Notices 1.0 + ``` + +#### `bool2num()` + +Converts the values: + ``` + false, f, 0, n, and no to 0 + true, t, 1, y, and yes to 1 + ``` +Requires a single boolean or string as an input. + +> *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric), + [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and + [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float) + function are used to convert to numeric values. + ``` + notice(Integer(false)) # Notices 0 + notice(Float(true)) # Notices 1.0 + ``` + +Returns: `Integer` The converted value as a number + +### bool2str + +Type: Ruby 3.x API + +The optional second and third arguments represent what true and false will be +converted to respectively. If only one argument is given, it will be +converted from a boolean to a string containing 'true' or 'false'. + +**Examples of usage** + + ``` + bool2str(true) => 'true' + bool2str(true, 'yes', 'no') => 'yes' + bool2str(false, 't', 'f') => 'f' + ``` + +Requires a single boolean as an input. + +> *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string) + function is used to convert to String with many different format options. + + ``` + notice(String(false)) # Notices 'false' + notice(String(true)) # Notices 'true' + notice(String(false, '%y')) # Notices 'yes' + notice(String(true, '%y')) # Notices 'no' + ``` + +#### `bool2str()` + +The optional second and third arguments represent what true and false will be +converted to respectively. If only one argument is given, it will be +converted from a boolean to a string containing 'true' or 'false'. + +**Examples of usage** + + ``` + bool2str(true) => 'true' + bool2str(true, 'yes', 'no') => 'yes' + bool2str(false, 't', 'f') => 'f' + ``` + +Requires a single boolean as an input. + +> *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string) + function is used to convert to String with many different format options. + + ``` + notice(String(false)) # Notices 'false' + notice(String(true)) # Notices 'true' + notice(String(false, '%y')) # Notices 'yes' + notice(String(true, '%y')) # Notices 'no' + ``` + +Returns: `Any` The converted value to string of the given Boolean + +### camelcase + +Type: Ruby 3.x API + +> *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with + a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) + function. + +#### `camelcase()` + +> *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with + a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) + function. + +Returns: `String` The converted String, if it was a String that was given + +### capitalize + +Type: Ruby 3.x API + +Requires either a single string or an array as an input. + +> *Note:* + **Deprecated** from Puppet 6.0.0, yhis function has been replaced with a + built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize) + function. + +#### `capitalize()` + +Requires either a single string or an array as an input. + +> *Note:* + **Deprecated** from Puppet 6.0.0, yhis function has been replaced with a + built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize) + function. + +Returns: `String` The converted String, if it was a String that was given + +### ceiling + +Type: Ruby 3.x API + +Takes a single numeric value as an argument. + +> *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function. + +#### `ceiling()` + +Takes a single numeric value as an argument. + +> *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function. + +Returns: `Integer` The rounded value + +### chomp + +Type: Ruby 3.x API + +For example `hello\n` becomes `hello`. +Requires a single string or array as an input. + +> *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function. + +#### `chomp()` + +For example `hello\n` becomes `hello`. +Requires a single string or array as an input. + +> *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function. + +Returns: `String` The converted String, if it was a String that was given + +### chop + +Type: Ruby 3.x API + +If the string ends with `\r\n`, both characters are removed. Applying +chop to an empty string returns an empty string. If you wish to merely +remove record separators then you should use the `chomp` function. +Requires a string or array of strings as input. + +> *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function. + +#### `chop()` + +If the string ends with `\r\n`, both characters are removed. Applying +chop to an empty string returns an empty string. If you wish to merely +remove record separators then you should use the `chomp` function. +Requires a string or array of strings as input. + +> *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function. + +Returns: `String` The given String, sans the last character. + +### clamp + +Type: Ruby 3.x API + +Strings are converted and compared numerically. Arrays of values are flattened +into a list for further handling. + +> *Note:* + From Puppet 6.0.0 this can be done with only core Puppet like this: + `[$minval, $maxval, $value_to_clamp].sort[1]` + +#### Examples + +##### Example usage + +```puppet + +clamp('24', [575, 187])` returns 187. +clamp(16, 88, 661)` returns 88. +clamp([4, 3, '99'])` returns 4. +``` + +#### `clamp()` + +Strings are converted and compared numerically. Arrays of values are flattened +into a list for further handling. + +> *Note:* + From Puppet 6.0.0 this can be done with only core Puppet like this: + `[$minval, $maxval, $value_to_clamp].sort[1]` + +Returns: `Array[Integer]` The sorted Array + +##### Examples + +###### Example usage + +```puppet + +clamp('24', [575, 187])` returns 187. +clamp(16, 88, 661)` returns 88. +clamp([4, 3, '99'])` returns 4. +``` + +### concat + +Type: Ruby 3.x API + +> *Note:* + Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and + merge of hashes, and the `<<`` operator for appending: + +`['1','2','3'] + ['4','5','6'] + ['7','8','9']` returns `['1','2','3','4','5','6','7','8','9']` +`[1, 2, 3] << 4` returns `[1, 2, 3, 4]` +`[1, 2, 3] << [4, 5]` returns `[1, 2, 3, [4, 5]]` + +#### Examples + +##### Example usage + +```puppet + +concat(['1','2','3'],'4') returns ['1','2','3','4'] +concat(['1','2','3'],'4',['5','6','7']) returns ['1','2','3','4','5','6','7'] +``` + +#### `concat()` + +> *Note:* + Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and + merge of hashes, and the `<<`` operator for appending: + +`['1','2','3'] + ['4','5','6'] + ['7','8','9']` returns `['1','2','3','4','5','6','7','8','9']` +`[1, 2, 3] << 4` returns `[1, 2, 3, 4]` +`[1, 2, 3] << [4, 5]` returns `[1, 2, 3, [4, 5]]` + +Returns: `Array` The single concatenated array + +##### Examples + +###### Example usage + +```puppet + +concat(['1','2','3'],'4') returns ['1','2','3','4'] +concat(['1','2','3'],'4',['5','6','7']) returns ['1','2','3','4','5','6','7'] +``` + +### convert_base + +Type: Ruby 3.x API + +convert_base(5, 2)` results in: `'101'` +convert_base('254', '16')` results in: `'fe'` + +> *Note:* + Since Puppet 4.5.0 this can be done with the built-in + [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string) + function and its many formatting options: + + `$binary_repr = String(5, '%b')` return `"101"` + `$hex_repr = String(254, "%x")` return `"fe"` + `$hex_repr = String(254, "%#x")` return `"0xfe"` + + @return [String] The converted value as a Str + +#### Examples + +##### Example usage + +```puppet + +``` + +#### `convert_base()` + +convert_base(5, 2)` results in: `'101'` +convert_base('254', '16')` results in: `'fe'` + +> *Note:* + Since Puppet 4.5.0 this can be done with the built-in + [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string) + function and its many formatting options: + + `$binary_repr = String(5, '%b')` return `"101"` + `$hex_repr = String(254, "%x")` return `"fe"` + `$hex_repr = String(254, "%#x")` return `"0xfe"` + + @return [String] The converted value as a Str + +Returns: `Any` converted value as a string + +##### Examples + +###### Example usage + +```puppet + +``` + +### count + +Type: Ruby 3.x API + +Takes an array as first argument and an optional second argument. Counts the number of elements in array that is equal to the second argument. +If called with only an array, it counts the number of elements that are not nil/undef/empty-string. + +> *Note:* + equality is tested with a Ruby method and it is therefore subject to what Ruby considers + to be equal. For strings this means that equality is case sensitive. + +In Puppet core, counting can be done in general by using a combination of the core functions +filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib). + +Example below shows counting values that are not undef. + + ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)``` + +Would notice the value 2. + +#### `count()` + +Takes an array as first argument and an optional second argument. Counts the number of elements in array that is equal to the second argument. +If called with only an array, it counts the number of elements that are not nil/undef/empty-string. + +> *Note:* + equality is tested with a Ruby method and it is therefore subject to what Ruby considers + to be equal. For strings this means that equality is case sensitive. + +In Puppet core, counting can be done in general by using a combination of the core functions +filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib). + +Example below shows counting values that are not undef. + + ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)``` + +Would notice the value 2. + +Returns: `Integer` The amount of elements counted within the array + +### deep_merge + +Type: Ruby 3.x API + +Recursively merges two or more hashes together and returns the resulting hash. + +#### Examples + +##### Example usage + +```puppet + +$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } +$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } +$merged_hash = deep_merge($hash1, $hash2) + +The resulting hash is equivalent to: + +$merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } + +When there is a duplicate key that is a hash, they are recursively merged. +When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." +``` + +#### `deep_merge()` + +The deep_merge function. + +Returns: `Hash` The merged h + +##### Examples + +###### Example usage + +```puppet + +$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } +$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } +$merged_hash = deep_merge($hash1, $hash2) + +The resulting hash is equivalent to: + +$merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } + +When there is a duplicate key that is a hash, they are recursively merged. +When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." +``` + +### defined_with_params + +Type: Ruby 3.x API + +Returns `true` if a resource with the specified attributes has already been added +to the catalog, and `false` otherwise. + + ``` + user { 'dan': + ensure => present, + } + + if ! defined_with_params(User[dan], {'ensure' => 'present' }) { + user { 'dan': ensure => present, } + } + ``` + +#### `defined_with_params()` + +Returns `true` if a resource with the specified attributes has already been added +to the catalog, and `false` otherwise. + + ``` + user { 'dan': + ensure => present, + } + + if ! defined_with_params(User[dan], {'ensure' => 'present' }) { + user { 'dan': ensure => present, } + } + ``` + +Returns: `Boolean` returns `true` or `false` + +### delete + +Type: Ruby 3.x API + +> *Note:* +From Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash +`{'a'=>1,'b'=>2,'c'=>3} - ['b','c'])` +> +A global delete from a string can be performed with the +[`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function: +`'abracadabra'.regsubst(/bra/, '', 'G')` + +In general, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) +function can filter out entries from arrays and hashes based on keys and/or values. + +#### Examples + +##### Example usage + +```puppet + +delete(['a','b','c','b'], 'b') +Would return: ['a','c'] + +delete({'a'=>1,'b'=>2,'c'=>3}, 'b') +Would return: {'a'=>1,'c'=>3} + +delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c']) +Would return: {'a'=>1} + +delete('abracadabra', 'bra') +Would return: 'acada' + +['a', 'b', 'c', 'b'] - 'b' +Would return: ['a', 'c'] + +{'a'=>1,'b'=>2,'c'=>3} - ['b','c']) +Would return: {'a' => '1'} + +'abracadabra'.regsubst(/bra/, '', 'G') +Would return: 'acada' +``` + +#### `delete()` + +> *Note:* +From Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash +`{'a'=>1,'b'=>2,'c'=>3} - ['b','c'])` +> +A global delete from a string can be performed with the +[`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function: +`'abracadabra'.regsubst(/bra/, '', 'G')` + +In general, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) +function can filter out entries from arrays and hashes based on keys and/or values. + +Returns: `String` The filtered String, if one was given. + +##### Examples + +###### Example usage + +```puppet + +delete(['a','b','c','b'], 'b') +Would return: ['a','c'] + +delete({'a'=>1,'b'=>2,'c'=>3}, 'b') +Would return: {'a'=>1,'c'=>3} + +delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c']) +Would return: {'a'=>1} + +delete('abracadabra', 'bra') +Would return: 'acada' + +['a', 'b', 'c', 'b'] - 'b' +Would return: ['a', 'c'] + +{'a'=>1,'b'=>2,'c'=>3} - ['b','c']) +Would return: {'a' => '1'} + +'abracadabra'.regsubst(/bra/, '', 'G') +Would return: 'acada' +``` + +### delete_at + +Type: Ruby 3.x API + +For example + ```delete_at(['a','b','c'], 1)``` + +Would return: `['a','c']` + +> *Note:* + Since Puppet 4 this can be done in general with the built-in + [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: + + ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }``` + +Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]: + ``` + $array[0, -1] # the same as all the values + $array[2, -1] # all but the first 2 elements + $array[0, -3] # all but the last 2 elements + $array[1, -2] # all but the first and last element + ``` + +#### `delete_at()` + +For example + ```delete_at(['a','b','c'], 1)``` + +Would return: `['a','c']` + +> *Note:* + Since Puppet 4 this can be done in general with the built-in + [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: + + ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }``` + +Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]: + ``` + $array[0, -1] # the same as all the values + $array[2, -1] # all but the first 2 elements + $array[0, -3] # all but the last 2 elements + $array[1, -2] # all but the first and last element + ``` + +Returns: `Array` The given array, now missing the tar + +### delete_regex + +Type: Ruby 3.x API + +Multiple regular expressions are assumed to be matched as an OR. + +> *Note:* +Since Puppet 4 this can be done in general with the built-in +[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: +["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ } +Would return: ['aaa', 'aca'] + +#### Examples + +##### Example usage + +```puppet + +delete_regex(['a','b','c','b'], 'b') +Would return: ['a','c'] + +delete_regex(['a','b','c','b'], ['b', 'c']) +Would return: ['a'] + +delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b') +Would return: {'a'=>1,'c'=>3} + +delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$') +Would return: {'b'=>2,'c'=>3} +``` + +#### `delete_regex()` + +Multiple regular expressions are assumed to be matched as an OR. + +> *Note:* +Since Puppet 4 this can be done in general with the built-in +[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: +["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ } +Would return: ['aaa', 'aca'] + +Returns: `Array` The given array now missing all targeted values. + +##### Examples + +###### Example usage + +```puppet + +delete_regex(['a','b','c','b'], 'b') +Would return: ['a','c'] + +delete_regex(['a','b','c','b'], ['b', 'c']) +Would return: ['a'] + +delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b') +Would return: {'a'=>1,'c'=>3} + +delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$') +Would return: {'b'=>2,'c'=>3} +``` + +### delete_undef_values + +Type: Ruby 3.x API + +> *Note:* +Since Puppet 4.0.0 the equivalent can be performed with the built-in +[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: +$array.filter |$val| { $val =~ NotUndef } +$hash.filter |$key, $val| { $val =~ NotUndef } + +#### Examples + +##### Example usage + +```puppet + +$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) +Would return: {a => 'A', b => '', d => false} + +While: +$array = delete_undef_values(['A','',undef,false]) +Would return: ['A','',false] +``` + +#### `delete_undef_values()` + +> *Note:* +Since Puppet 4.0.0 the equivalent can be performed with the built-in +[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: +$array.filter |$val| { $val =~ NotUndef } +$hash.filter |$key, $val| { $val =~ NotUndef } + +Returns: `Array` The given array now issing of undefined values. + +##### Examples + +###### Example usage + +```puppet + +$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) +Would return: {a => 'A', b => '', d => false} + +While: +$array = delete_undef_values(['A','',undef,false]) +Would return: ['A','',false] +``` + +### delete_values + +Type: Ruby 3.x API + +> *Note:* +Since Puppet 4.0.0 the equivalent can be performed with the +built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: +$array.filter |$val| { $val != 'B' } +$hash.filter |$key, $val| { $val != 'B' } + +#### Examples + +##### Example usage + +```puppet + +delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B') +Would return: {'a'=>'A','c'=>'C','B'=>'D'} +``` + +#### `delete_values()` + +> *Note:* +Since Puppet 4.0.0 the equivalent can be performed with the +built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: +$array.filter |$val| { $val != 'B' } +$hash.filter |$key, $val| { $val != 'B' } + +Returns: `Hash` The given hash now missing all instances of the targeted value + +##### Examples + +###### Example usage + +```puppet + +delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B') +Would return: {'a'=>'A','c'=>'C','B'=>'D'} +``` + +### deprecation + +Type: Ruby 3.x API + +The uniqueness key - can appear once. The msg is the message text including any positional +information that is formatted by the user/caller of the method.). + +#### `deprecation()` + +The uniqueness key - can appear once. The msg is the message text including any positional +information that is formatted by the user/caller of the method.). + +Returns: `String` return deprecation warnings + +### deprecation + +Type: Ruby 4.x API + +Function to print deprecation warnings, Logs a warning once for a given key. + +The uniqueness key - can appear once. +The msg is the message text including any positional information that is formatted by the +user/caller of the method. +It is affected by the puppet setting 'strict', which can be set to :error +(outputs as an error message), :off (no message / error is displayed) and :warning +(default, outputs a warning) *Type*: String, String. + +#### `deprecation(String $key, String $message)` + +Function to print deprecation warnings, Logs a warning once for a given key. + +The uniqueness key - can appear once. +The msg is the message text including any positional information that is formatted by the +user/caller of the method. +It is affected by the puppet setting 'strict', which can be set to :error +(outputs as an error message), :off (no message / error is displayed) and :warning +(default, outputs a warning) *Type*: String, String. + +Returns: `Any` deprecated warnings + +##### `key` + +Data type: `String` + + + +##### `message` + +Data type: `String` + + + +### difference + +Type: Ruby 3.x API + +The returned array is a copy of the original array, removing any items that +also appear in the second array. + +> *Note:* +Since Puppet 4 the minus (-) operator in the Puppet language does the same thing: +['a', 'b', 'c'] - ['b', 'c', 'd'] +Would return: `['a']` + +#### Examples + +##### Example usage + +```puppet + +difference(["a","b","c"],["b","c","d"]) +Would return: `["a"]` +``` + +#### `difference()` + +The returned array is a copy of the original array, removing any items that +also appear in the second array. + +> *Note:* +Since Puppet 4 the minus (-) operator in the Puppet language does the same thing: +['a', 'b', 'c'] - ['b', 'c', 'd'] +Would return: `['a']` + +Returns: `Array` The difference between the two given arrays + +##### Examples + +###### Example usage + +```puppet + +difference(["a","b","c"],["b","c","d"]) +Would return: `["a"]` +``` + +### dig + +Type: Ruby 3.x API + +In addition to the required path argument, the function accepts the default argument. +It is returned if the path is not correct, if no value was found, or if any other error +has occurred. + + ```ruby + $data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } + } + + $value = dig($data, ['a', 'b', 2]) + # $value = 'b3' + + # with all possible options + $value = dig($data, ['a', 'b', 2], 'not_found') + # $value = 'b3' + + # using the default value + $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found') + # $value = 'not_found' + ``` + + 1. `$data` The data structure we are working with. + 2. `['a', 'b', 2]` The path array. + 3. `not_found` The default value. It is returned if nothing is found. + +> **Note:* + **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version. + +#### `dig()` + +In addition to the required path argument, the function accepts the default argument. +It is returned if the path is not correct, if no value was found, or if any other error +has occurred. + + ```ruby + $data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } + } + + $value = dig($data, ['a', 'b', 2]) + # $value = 'b3' + + # with all possible options + $value = dig($data, ['a', 'b', 2], 'not_found') + # $value = 'b3' + + # using the default value + $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found') + # $value = 'not_found' + ``` + + 1. `$data` The data structure we are working with. + 2. `['a', 'b', 2]` The path array. + 3. `not_found` The default value. It is returned if nothing is found. + +> **Note:* + **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version. + +Returns: `Any` The function goes through the structure by each path component and tries to return +the value at the end of the path. + +### dig44 + +Type: Ruby 3.x API + +Key can contain slashes to describe path components. The function will go down +the structure and try to extract the required value. + +``` +$data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } +} + +$value = dig44($data, ['a', 'b', 2]) +# $value = 'b3' + +# with all possible options +$value = dig44($data, ['a', 'b', 2], 'not_found') +# $value = 'b3' + +# using the default value +$value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found') +# $value = 'not_found' +``` + +> **Note:* **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. + +#### `dig44()` + +Key can contain slashes to describe path components. The function will go down +the structure and try to extract the required value. + +``` +$data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } +} + +$value = dig44($data, ['a', 'b', 2]) +# $value = 'b3' + +# with all possible options +$value = dig44($data, ['a', 'b', 2], 'not_found') +# $value = 'b3' + +# using the default value +$value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found') +# $value = 'not_found' +``` + +> **Note:* **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. + +Returns: `String` 'not_found' will be returned if nothing is found + +### dirname + +Type: Ruby 3.x API + +Returns the dirname of a path. + +#### `dirname()` + +The dirname function. + +Returns: `String` the given path's dirname + +### dos2unix + +Type: Ruby 3.x API + +Takes a single string argument. + +#### `dos2unix()` + +Takes a single string argument. + +Returns: `Any` The retrieved version + +### downcase + +Type: Ruby 3.x API + +> *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function. +> +This function is an implementation of a Ruby class and might not be UTF8 compatible. +To ensure compatibility, use this function with Ruby 2.4.0 or greater. + +#### `downcase()` + +> *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function. +> +This function is an implementation of a Ruby class and might not be UTF8 compatible. +To ensure compatibility, use this function with Ruby 2.4.0 or greater. + +Returns: `String` The converted String, if it was a String that was given + +### empty + +Type: Ruby 3.x API + +> *Note*: **Deprecated** from Puppet 5.5.0, the built-in +[`empty`](https://puppet.com/docs/puppet/6.4/function.html#empty) function will be used instead. + +#### `empty()` + +> *Note*: **Deprecated** from Puppet 5.5.0, the built-in +[`empty`](https://puppet.com/docs/puppet/6.4/function.html#empty) function will be used instead. + +Returns: `Any` Returns `true` if the argument is an array or hash that contains no elements, +or an empty string. Returns `false` when the argument is a numerical value. + +### enclose_ipv6 + +Type: Ruby 3.x API + +Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. + +#### `enclose_ipv6()` + +The enclose_ipv6 function. + +Returns: `Any` encloses the ipv6 addresses with square brackets. + +### ensure_packages + +Type: Ruby 3.x API + +It optionally takes a hash as a second parameter that will be passed as the +third argument to the ensure_resource() function. + +#### `ensure_packages()` + +It optionally takes a hash as a second parameter that will be passed as the +third argument to the ensure_resource() function. + +Returns: `Any` install the passed packages + +### ensure_resource + +Type: Ruby 3.x API + +user { 'dan': + ensure => present, +} + +#### Examples + +##### Example usage + +```puppet + +Creates the resource if it does not already exist: + + ensure_resource('user', 'dan', {'ensure' => 'present' }) + +If the resource already exists but does not match the specified parameters, +this function will attempt to recreate the resource leading to a duplicate +resource definition error. + +An array of resources can also be passed in and each will be created with +the type and parameters specified if it doesn't already exist. + + ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) +``` + +#### `ensure_resource()` + +user { 'dan': + ensure => present, +} + +Returns: `Any` created or recreated the passed resource with the passed type and attributes + +##### Examples + +###### Example usage + +```puppet + +Creates the resource if it does not already exist: + + ensure_resource('user', 'dan', {'ensure' => 'present' }) + +If the resource already exists but does not match the specified parameters, +this function will attempt to recreate the resource leading to a duplicate +resource definition error. + +An array of resources can also be passed in and each will be created with +the type and parameters specified if it doesn't already exist. + + ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) +``` + +### ensure_resources + +Type: Ruby 3.x API + +An hash of resources should be passed in and each will be created with + the type and parameters specified if it doesn't already exist. + + ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) + + From Hiera Backend: + + userlist: + dan: + gid: 'mygroup' + uid: '600' + alex: + gid: 'mygroup' + + Call: + ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) + +#### Examples + +##### Example usage + +```puppet + +user { 'dan': + gid => 'mygroup', + ensure => present, +} +``` + +#### `ensure_resources()` + +An hash of resources should be passed in and each will be created with + the type and parameters specified if it doesn't already exist. + + ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) + + From Hiera Backend: + + userlist: + dan: + gid: 'mygroup' + uid: '600' + alex: + gid: 'mygroup' + + Call: + ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) + +Returns: `Any` created resources with the passed type and attributes + +##### Examples + +###### Example usage + +```puppet + +user { 'dan': + gid => 'mygroup', + ensure => present, +} +``` + +### fact + +Type: Ruby 4.x API + +Supports the use of dot-notation for referring to structured facts. If a fact requested +does not exist, returns Undef. + +#### Examples + +##### Example usage: + +```puppet +fact('osfamily') +fact('os.architecture') +``` + +##### Array indexing: + +```puppet +fact('mountpoints."/dev".options.1') +``` + +##### Fact containing a "." in the name: + +```puppet +fact('vmware."VRA.version"') +``` + +#### `fact(String $fact_name)` + +Supports the use of dot-notation for referring to structured facts. If a fact requested +does not exist, returns Undef. + +Returns: `Any` All information retrieved on the given fact_name + +##### Examples + +###### Example usage: + +```puppet +fact('osfamily') +fact('os.architecture') +``` + +###### Array indexing: + +```puppet +fact('mountpoints."/dev".options.1') +``` + +###### Fact containing a "." in the name: + +```puppet +fact('vmware."VRA.version"') +``` + +##### `fact_name` + +Data type: `String` + +The name of the fact to check + +### flatten + +Type: Ruby 3.x API + +> **Note:** **Deprecated** from Puppet 5.5.0, this function has been replaced with a +built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function. + +#### Examples + +##### Example usage + +```puppet + +flatten(['a', ['b', ['c']]])` returns: `['a','b','c'] +``` + +#### `flatten()` + +> **Note:** **Deprecated** from Puppet 5.5.0, this function has been replaced with a +built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function. + +Returns: `Any` convert nested arrays into a single flat array + +##### Examples + +###### Example usage + +```puppet + +flatten(['a', ['b', ['c']]])` returns: `['a','b','c'] +``` + +### floor + +Type: Ruby 3.x API + +Takes a single numeric value as an argument. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with +a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function. + +#### `floor()` + +Takes a single numeric value as an argument. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with +a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function. + +Returns: `Any` the largest integer less or equal to the argument. + +### fqdn_rand_string + +Type: Ruby 3.x API + +Optionally, you can specify a character set for the function (defaults to alphanumeric). + +Arguments +* An integer, specifying the length of the resulting string. +* Optionally, a string specifying the character set. +* Optionally, a string specifying the seed for repeatable randomness. + +#### Examples + +##### Example Usage: + +```puppet +fqdn_rand_string(10) +fqdn_rand_string(10, 'ABCDEF!@$%^') +fqdn_rand_string(10, '', 'custom seed') +``` + +#### `fqdn_rand_string()` + +Optionally, you can specify a character set for the function (defaults to alphanumeric). + +Arguments +* An integer, specifying the length of the resulting string. +* Optionally, a string specifying the character set. +* Optionally, a string specifying the seed for repeatable randomness. + +Returns: `String` + +##### Examples + +###### Example Usage: + +```puppet +fqdn_rand_string(10) +fqdn_rand_string(10, 'ABCDEF!@$%^') +fqdn_rand_string(10, '', 'custom seed') +``` + +### fqdn_rotate + +Type: Ruby 3.x API + +Rotates an array or string a random number of times, combining the `$fqdn` fact +and an optional seed for repeatable randomness. + +#### Examples + +##### Example Usage: + +```puppet +fqdn_rotate(['a', 'b', 'c', 'd']) +fqdn_rotate('abcd') +fqdn_rotate([1, 2, 3], 'custom seed') +``` + +#### `fqdn_rotate()` + +The fqdn_rotate function. + +Returns: `Any` rotated array or string + +##### Examples + +###### Example Usage: + +```puppet +fqdn_rotate(['a', 'b', 'c', 'd']) +fqdn_rotate('abcd') +fqdn_rotate([1, 2, 3], 'custom seed') +``` + +### fqdn_uuid + +Type: Ruby 3.x API + +Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based +on an FQDN string under the DNS namespace + +#### Examples + +##### Example Usage: + +```puppet +fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c' +fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09 +``` + +#### `fqdn_uuid()` + +The fqdn_uuid function. + +Returns: `Any` Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID + +##### Examples + +###### Example Usage: + +```puppet +fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c' +fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09 +``` + +### get_module_path + +Type: Ruby 3.x API + +> *Note:* + that since Puppet 5.4.0 the built-in + [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory) + function in Puppet does the same thing and will return the path to the first found module + if given multiple values or an array. + +#### Examples + +##### Example Usage: + +```puppet +$module_path = get_module_path('stdlib') +``` + +#### `get_module_path()` + +> *Note:* + that since Puppet 5.4.0 the built-in + [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory) + function in Puppet does the same thing and will return the path to the first found module + if given multiple values or an array. + +Returns: `Any` Returns the absolute path of the specified module for the current +environment. + +##### Examples + +###### Example Usage: + +```puppet +$module_path = get_module_path('stdlib') +``` + +### getparam + +Type: Ruby 3.x API + +Takes a resource reference and name of the parameter and +returns value of resource's parameter. Note that user defined +resource types are evaluated lazily. + +Would notice: 'the value we are getting in this example' + +> **Note** that since Puppet 4.0.0 it is possible to get a parameter value by using its data type +and the [ ] operator. The example below is equivalent to a call to getparam(): + ```Example_resource['example_resource_instance']['param']`` + +#### Examples + +##### Example Usage: + +```puppet + +# define a resource type with a parameter +define example_resource($param) { +} + +# declare an instance of that type +example_resource { "example_resource_instance": + param => "'the value we are getting in this example''" +} + +# Because of order of evaluation, a second definition is needed +# that will be evaluated after the first resource has been declared +# +define example_get_param { + # This will notice the value of the parameter + notice(getparam(Example_resource["example_resource_instance"], "param")) +} + +# Declare an instance of the second resource type - this will call notice +example_get_param { 'show_notify': } +``` + +#### `getparam()` + +Takes a resource reference and name of the parameter and +returns value of resource's parameter. Note that user defined +resource types are evaluated lazily. + +Would notice: 'the value we are getting in this example' + +> **Note** that since Puppet 4.0.0 it is possible to get a parameter value by using its data type +and the [ ] operator. The example below is equivalent to a call to getparam(): + ```Example_resource['example_resource_instance']['param']`` + +Returns: `Any` value of a resource's parameter. + +##### Examples + +###### Example Usage: + +```puppet + +# define a resource type with a parameter +define example_resource($param) { +} + +# declare an instance of that type +example_resource { "example_resource_instance": + param => "'the value we are getting in this example''" +} + +# Because of order of evaluation, a second definition is needed +# that will be evaluated after the first resource has been declared +# +define example_get_param { + # This will notice the value of the parameter + notice(getparam(Example_resource["example_resource_instance"], "param")) +} + +# Declare an instance of the second resource type - this will call notice +example_get_param { 'show_notify': } +``` + +### getvar + +Type: Ruby 3.x API + +> **Note:** from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. The new function also has support for +digging into a structured value. See the built-in +[`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) funct + +#### Examples + +##### Example usage + +```puppet +$foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo +``` + +##### Where namespace is stored in a string + +```puppet +$datalocation = 'site::data' +$bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar +``` + +#### `getvar()` + +> **Note:** from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. The new function also has support for +digging into a structured value. See the built-in +[`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) funct + +Returns: `Any` undef - if variable does not exist + +##### Examples + +###### Example usage + +```puppet +$foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo +``` + +###### Where namespace is stored in a string + +```puppet +$datalocation = 'site::data' +$bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar +``` + +### glob + +Type: Ruby 3.x API + +Uses same patterns as Dir#glob. + +#### Examples + +##### Example Usage: + +```puppet +$confs = glob(['/etc/**/*.conf', '/opt/**/*.conf']) +``` + +#### `glob()` + +The glob function. + +Returns: `Any` Returns an Array of file entries of a directory or an Array of directories. + +##### Examples + +###### Example Usage: + +```puppet +$confs = glob(['/etc/**/*.conf', '/opt/**/*.conf']) +``` + +### grep + +Type: Ruby 3.x API + +> **Note:** that since Puppet 4.0.0, the built-in +[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does +the "same" - as any logic can be used to filter, as opposed to just regular expressions: +```['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }``` + +#### Examples + +##### Example Usage: + +```puppet +grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd'] +``` + +#### `grep()` + +> **Note:** that since Puppet 4.0.0, the built-in +[`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does +the "same" - as any logic can be used to filter, as opposed to just regular expressions: +```['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }``` + +Returns: `Any` array of elements that match the provided regular expression. + +##### Examples + +###### Example Usage: + +```puppet +grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd'] +``` + +### has_interface_with + +Type: Ruby 3.x API + +Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`. + +#### Examples + +##### **Usage** + +```puppet +has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false` +has_interface_with("ipaddress", "127.0.0.1") # Returns `true` +``` + +##### If no "kind" is given, then the presence of the interface is checked: + +```puppet +has_interface_with("lo") # Returns `true` +``` + +#### `has_interface_with()` + +Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`. + +Returns: `Any` boolean values `true` or `false` + +##### Examples + +###### **Usage** + +```puppet +has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false` +has_interface_with("ipaddress", "127.0.0.1") # Returns `true` +``` + +###### If no "kind" is given, then the presence of the interface is checked: + +```puppet +has_interface_with("lo") # Returns `true` +``` + +### has_ip_address + +Type: Ruby 3.x API + +This function iterates through the 'interfaces' fact and checks the +'ipaddress_IFACE' facts, performing a simple string comparison. + +#### `has_ip_address()` + +This function iterates through the 'interfaces' fact and checks the +'ipaddress_IFACE' facts, performing a simple string comparison. + +Returns: `Boolean` `true` or `false` + +### has_ip_network + +Type: Ruby 3.x API + +This function iterates through the 'interfaces' fact and checks the +'network_IFACE' facts, performing a simple string comparision. + +#### `has_ip_network()` + +This function iterates through the 'interfaces' fact and checks the +'network_IFACE' facts, performing a simple string comparision. + +Returns: `Any` Boolean value, `true` if the client has an IP address within the requested network. + +### has_key + +Type: Ruby 3.x API + +> **Note:** **Deprecated** since Puppet 4.0.0, this can now be achieved in the Puppet +language with the following equivalent expression: +$my_hash = {'key_one' => 'value_one'} +if 'key_one' in $my_hash { + notice('this will be printed') + +#### Examples + +##### Example Usage: + +```puppet + +$my_hash = {'key_one' => 'value_one'} +if has_key($my_hash, 'key_two') { + notice('we will not reach here') +} +if has_key($my_hash, 'key_one') { + notice('this will be printed') +} +``` + +#### `has_key()` + +> **Note:** **Deprecated** since Puppet 4.0.0, this can now be achieved in the Puppet +language with the following equivalent expression: +$my_hash = {'key_one' => 'value_one'} +if 'key_one' in $my_hash { + notice('this will be printed') + +Returns: `Any` Boolean value + +##### Examples + +###### Example Usage: + +```puppet + +$my_hash = {'key_one' => 'value_one'} +if has_key($my_hash, 'key_two') { + notice('we will not reach here') +} +if has_key($my_hash, 'key_one') { + notice('this will be printed') +} +``` + +### hash + +Type: Ruby 3.x API + +> **Note:** This function has been replaced with the built-in ability to create a new value of almost any +data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function +in Puppet. +This example shows the equivalent expression in the Puppet language: + ``` + Hash(['a',1,'b',2,'c',3]) + Hash([['a',1],['b',2],['c',3]]) + ``` + +#### Examples + +##### Example Usage: + +```puppet +hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3} +``` + +#### `hash()` + +> **Note:** This function has been replaced with the built-in ability to create a new value of almost any +data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function +in Puppet. +This example shows the equivalent expression in the Puppet language: + ``` + Hash(['a',1,'b',2,'c',3]) + Hash([['a',1],['b',2],['c',3]]) + ``` + +Returns: `Any` the converted array as a hash + +##### Examples + +###### Example Usage: + +```puppet +hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3} +``` + +### intersection + +Type: Ruby 3.x API + +This function returns an array of the intersection of two. + +#### Examples + +##### Example Usage: + +```puppet +intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"] +intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) +``` + +#### `intersection()` + +The intersection function. + +Returns: `Any` an array of the intersection of two. + +##### Examples + +###### Example Usage: + +```puppet +intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"] +intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) +``` + +### is_a + +Type: Ruby 4.x API + +See the documentation for "The Puppet Type System" for more information about types. +See the `assert_type()` function for flexible ways to assert the type of a value. + +#### Examples + +##### Example Usage: + +```puppet +# check a data type + foo = 3 + $bar = [1,2,3] + $baz = 'A string!' + + if $foo.is_a(Integer) { + notify { 'foo!': } + } + if $bar.is_a(Array) { + notify { 'bar!': } + } + if $baz.is_a(String) { + notify { 'baz!': } + } +``` + +#### `is_a(Any $value, Type $type)` + +See the documentation for "The Puppet Type System" for more information about types. +See the `assert_type()` function for flexible ways to assert the type of a value. + +Returns: `Boolean` Return's `true` or `false`. + +##### Examples + +###### Example Usage: + +```puppet +# check a data type + foo = 3 + $bar = [1,2,3] + $baz = 'A string!' + + if $foo.is_a(Integer) { + notify { 'foo!': } + } + if $bar.is_a(Array) { + notify { 'bar!': } + } + if $baz.is_a(String) { + notify { 'baz!': } + } +``` + +##### `value` + +Data type: `Any` + +The value to be checked + +##### `type` + +Data type: `Type` + +The expected type + +### is_absolute_path + +Type: Ruby 3.x API + +This function works for windows and unix style paths. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_leg + +#### Examples + +##### The following values will return true: + +```puppet +$my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' +is_absolute_path($my_path) +$my_path2 = '/var/lib/puppet' +is_absolute_path($my_path2) +$my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet'] +is_absolute_path($my_path3) +$my_path4 = ['/var/lib/puppet'] +is_absolute_path($my_path4) +``` + +##### The following values will return false: + +```puppet +is_absolute_path(true) +is_absolute_path('../var/lib/puppet') +is_absolute_path('var/lib/puppet') +$undefined = undef +is_absolute_path($undefined) +``` + +#### `is_absolute_path()` + +This function works for windows and unix style paths. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_leg + +Returns: `Boolean` Returns `true` or `false` + +##### Examples + +###### The following values will return true: + +```puppet +$my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' +is_absolute_path($my_path) +$my_path2 = '/var/lib/puppet' +is_absolute_path($my_path2) +$my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet'] +is_absolute_path($my_path3) +$my_path4 = ['/var/lib/puppet'] +is_absolute_path($my_path4) +``` + +###### The following values will return false: + +```puppet +is_absolute_path(true) +is_absolute_path('../var/lib/puppet') +is_absolute_path('var/lib/puppet') +$undefined = undef +is_absolute_path($undefined) +``` + +### is_absolute_path + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_absolute_path(Any $scope, Any *$args)` + +The is_absolute_path function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_array + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_array(Any $scope, Any *$args)` + +The is_array function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_array + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_array()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_bool + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_bool(Any $scope, Any *$args)` + +The is_bool function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_bool + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_bool()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_domain_name + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_domain_name()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_email_address + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_email_address()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_float + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_float(Any $scope, Any *$args)` + +The is_float function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_float + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_float()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_function_available + +Type: Ruby 3.x API + +This function accepts a string as an argument. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_function_available()` + +This function accepts a string as an argument. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_hash + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_hash()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_integer + +Type: Ruby 3.x API + +The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0' +digit may not be followed by other digits as this indicates that the value is octal (base 8). + +If given any other argument `false` is returned. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_integer()` + +The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0' +digit may not be followed by other digits as this indicates that the value is octal (base 8). + +If given any other argument `false` is returned. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_ip_address + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_ip_address()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_ip_address + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_ip_address(Any $scope, Any *$args)` + +The is_ip_address function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_ipv4_address + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_ipv4_address(Any $scope, Any *$args)` + +The is_ipv4_address function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_ipv4_address + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_ipv4_address()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_ipv6_address + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_ipv6_address()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_ipv6_address + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_ipv6_address(Any $scope, Any *$args)` + +The is_ipv6_address function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_mac_address + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_mac_address()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_numeric + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_numeric(Any $scope, Any *$args)` + +The is_numeric function. + +Returns: `Boolea` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### is_numeric + +Type: Ruby 3.x API + +Returns true if the given argument is a Numeric (Integer or Float), +or a String containing either a valid integer in decimal base 10 form, or +a valid floating point string representation. + +The function recognizes only decimal (base 10) integers and float but not +integers in hex (base 16) or octal (base 8) form. + +The string representation may start with a '-' (minus). If a decimal '.' is used, +it must be followed by at least one digit. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_numeric()` + +Returns true if the given argument is a Numeric (Integer or Float), +or a String containing either a valid integer in decimal base 10 form, or +a valid floating point string representation. + +The function recognizes only decimal (base 10) integers and float but not +integers in hex (base 16) or octal (base 8) form. + +The string representation may start with a '-' (minus). If a decimal '.' is used, +it must be followed by at least one digit. + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_string + +Type: Ruby 3.x API + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +#### `is_string()` + +> **Note:* **Deprecated** Will be removed in a future version of stdlib. See +[`validate_legacy`](#validate_legacy). + +Returns: `Boolean` Returns `true` or `false` + +### is_string + +Type: Ruby 4.x API + +Wrapper that calls the Puppet 3.x funtion of the same name. + +#### `is_string(Any $scope, Any *$args)` + +The is_string function. + +Returns: `Boolean` A boolean value returned from the called 3.x function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the wrapped method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the wrapped method + +### join + +Type: Ruby 3.x API + +> **Note:** **Deprecated** from Puppet 5.4.0 this function has been replaced +with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function. + +#### Examples + +##### Example Usage: + +```puppet +join(['a','b','c'], ",") # Results in: "a,b,c" +``` + +#### `join()` + +> **Note:** **Deprecated** from Puppet 5.4.0 this function has been replaced +with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function. + +Returns: `String` The String containing each of the array values + +##### Examples + +###### Example Usage: + +```puppet +join(['a','b','c'], ",") # Results in: "a,b,c" +``` + +### join_keys_to_values + +Type: Ruby 3.x API + +Keys are cast to strings. If values are arrays, multiple keys +are added for each element. The return value is an array in +which each element is one joined key/value pair. + +> **Note:** Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and +line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual +formatting of values in the array) - see the `new` function for `String` and its formatting +options for `Array` and `Hash`. + +#### Examples + +##### Example Usage: + +```puppet +join_keys_to_values({'a'=>1,'b'=>2}, " is ") # Results in: ["a is 1","b is 2"] +join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") # Results in: ["a is 1","b is 2","b is 3"] +``` + +#### `join_keys_to_values()` + +Keys are cast to strings. If values are arrays, multiple keys +are added for each element. The return value is an array in +which each element is one joined key/value pair. + +> **Note:** Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and +line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual +formatting of values in the array) - see the `new` function for `String` and its formatting +options for `Array` and `Hash`. + +Returns: `Hash` The joined hash + +##### Examples + +###### Example Usage: + +```puppet +join_keys_to_values({'a'=>1,'b'=>2}, " is ") # Results in: ["a is 1","b is 2"] +join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") # Results in: ["a is 1","b is 2","b is 3"] +``` + +### keys + +Type: Ruby 3.x API + +> **Note:** **Deprecated** from Puppet 5.5.0, the built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys) +function will be used instead of this function. + +#### `keys()` + +> **Note:** **Deprecated** from Puppet 5.5.0, the built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys) +function will be used instead of this function. + +Returns: `Array` An array containing each of the hashes key values. + +### length + +Type: Ruby 4.x API + +The original size() function did not handle Puppets new type capabilities, so this function +is a Puppet 4 compatible solution. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function. + +#### `length(Variant[String,Array,Hash] $value)` + +The original size() function did not handle Puppets new type capabilities, so this function +is a Puppet 4 compatible solution. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function. + +Returns: `Integer` The length of the given object + +##### `value` + +Data type: `Variant[String,Array,Hash]` + +The value whose length is to be found + +### load_module_metadata + +Type: Ruby 3.x API + +This function loads the metadata of a given module. + +#### Examples + +##### Example USage: + +```puppet +$metadata = load_module_metadata('archive') +notify { $metadata['author']: } +``` + +#### `load_module_metadata()` + +The load_module_metadata function. + +Returns: `Any` The modules metadata + +##### Examples + +###### Example USage: + +```puppet +$metadata = load_module_metadata('archive') +notify { $metadata['author']: } +``` + +### loadjson + +Type: Ruby 3.x API + +The first parameter can be a file path or a URL. +The second parameter is the default value. It will be returned if the file +was not found or could not be parsed. + +#### Examples + +##### Example Usage: + +```puppet +$myhash = loadjson('/etc/puppet/data/myhash.json') +$myhash = loadjson('https://example.local/my_hash.json') +$myhash = loadjson('https://username:password@example.local/my_hash.json') +$myhash = loadjson('no-file.json', {'default' => 'val +``` + +#### `loadjson()` + +The first parameter can be a file path or a URL. +The second parameter is the default value. It will be returned if the file +was not found or could not be parsed. + +Returns: `Array|String|Hash` The data stored in the JSON file, the type depending on the type of data that was stored. + +##### Examples + +###### Example Usage: + +```puppet +$myhash = loadjson('/etc/puppet/data/myhash.json') +$myhash = loadjson('https://example.local/my_hash.json') +$myhash = loadjson('https://username:password@example.local/my_hash.json') +$myhash = loadjson('no-file.json', {'default' => 'val +``` + +### loadyaml + +Type: Ruby 3.x API + +The first parameter can be a file path or a URL. +The second parameter is the default value. It will be returned if the file +was not found or could not be parsed. + +#### Examples + +##### Example Usage: + +```puppet +$myhash = loadyaml('/etc/puppet/data/myhash.yaml') +$myhash = loadyaml('https://example.local/my_hash.yaml') +$myhash = loadyaml('https://username:password@example.local/my_hash.yaml') +$myhash = loadyaml('no-file.yaml', {'default' => 'val +``` + +#### `loadyaml()` + +The first parameter can be a file path or a URL. +The second parameter is the default value. It will be returned if the file +was not found or could not be parsed. + +Returns: `Array|String|Hash` The data stored in the YAML file, the type depending on the type of data that was stored. + +##### Examples + +###### Example Usage: + +```puppet +$myhash = loadyaml('/etc/puppet/data/myhash.yaml') +$myhash = loadyaml('https://example.local/my_hash.yaml') +$myhash = loadyaml('https://username:password@example.local/my_hash.yaml') +$myhash = loadyaml('no-file.yaml', {'default' => 'val +``` + +### lstrip + +Type: Ruby 3.x API + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function. + +#### `lstrip()` + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function. + +Returns: `String` The stripped string + +### max + +Type: Ruby 3.x API + +Requires at least one argument. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function. + +#### `max()` + +Requires at least one argument. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function. + +Returns: `Any` The highest value among those passed in + +### member + +Type: Ruby 3.x API + +The variable can be a string, fixnum, or array. + +> **Note**: This function does not support nested arrays. If the first argument contains +nested arrays, it will not recurse through them. + +> *Note:* +Since Puppet 4.0.0 the same can be performed in the Puppet language. +For single values the operator `in` can be used: +`'a' in ['a', 'b'] # true` +For arrays by using operator `-` to compute a diff: +`['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted` +`['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted` + +> **Note** that since Puppet 5.2.0, the general form to test the content of an array or +hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any) +and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions. + +#### Examples + +##### **Usage** + +```puppet +member(['a','b'], 'b') # Returns: true +member(['a', 'b', 'c'], ['a', 'b']) # Returns: true +member(['a','b'], 'c') # Returns: false +member(['a', 'b', 'c'], ['d', 'b']) # Returns: false +``` + +#### `member()` + +The variable can be a string, fixnum, or array. + +> **Note**: This function does not support nested arrays. If the first argument contains +nested arrays, it will not recurse through them. + +> *Note:* +Since Puppet 4.0.0 the same can be performed in the Puppet language. +For single values the operator `in` can be used: +`'a' in ['a', 'b'] # true` +For arrays by using operator `-` to compute a diff: +`['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted` +`['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted` + +> **Note** that since Puppet 5.2.0, the general form to test the content of an array or +hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any) +and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions. + +Returns: `Any` Returns whether the given value was a member of the array + +##### Examples + +###### **Usage** + +```puppet +member(['a','b'], 'b') # Returns: true +member(['a', 'b', 'c'], ['a', 'b']) # Returns: true +member(['a','b'], 'c') # Returns: false +member(['a', 'b', 'c'], ['d', 'b']) # Returns: false +``` + +### merge + +Type: Ruby 3.x API + +When there is a duplicate key, the key in the rightmost hash will "win." + +Note that since Puppet 4.0.0 the same merge can be achieved with the + operator. + `$merged_hash = $hash1 + $has + +#### Examples + +##### **Usage** + +```puppet +$hash1 = {'one' => 1, 'two', => 2} +$hash2 = {'two' => 'dos', 'three', => 'tres'} +$merged_hash = merge($hash1, $hash2) # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} +``` + +#### `merge()` + +When there is a duplicate key, the key in the rightmost hash will "win." + +Note that since Puppet 4.0.0 the same merge can be achieved with the + operator. + `$merged_hash = $hash1 + $has + +Returns: `Hash` The merged hash + +##### Examples + +###### **Usage** + +```puppet +$hash1 = {'one' => 1, 'two', => 2} +$hash2 = {'two' => 'dos', 'three', => 'tres'} +$merged_hash = merge($hash1, $hash2) # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} +``` + +### merge + +Type: Ruby 4.x API + +When there is a duplicate key, the key in the rightmost hash will "win." + +Note that since Puppet 4.0.0 the same merge can be achieved with the + operator. + `$merged_hash = $hash1 + $hash2` + +If merge is given a single Iterable (Array, Hash, etc.) it will call a given block with +up to three parameters, and merge each resulting Hash into the accumulated result. All other types +of values returned from the block (typically undef) are skipped (not merged). + +The codeblock can take 2 or three parameters: +* with two, it gets the current hash (as built to this point), and each value (for hash the value is a [key, value] tuple) +* with three, it gets the current hash (as built to this point), the key/index of each value, and then the value + +If the iterable is empty, or no hash was returned from the given block, an empty hash is returned. In the given block, a call to `next()` +will skip that entry, and a call to `break()` will end the iteration. + +The iterative `merge()` has an advantage over doing the same with a general `reduce()` in that the constructed hash +does not have to be copied in each iteration and thus will perform much better with large inputs. + +#### Examples + +##### Using merge() + +```puppet +$hash1 = {'one' => 1, 'two', => 2} +$hash2 = {'two' => 'dos', 'three', => 'tres'} +$merged_hash = merge($hash1, $hash2) # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} +``` + +##### counting occurrences of strings in an array + +```puppet +['a', 'b', 'c', 'c', 'd', 'b'].merge | $hsh, $v | { { $v => $hsh[$v].lest || { 0 } + 1 } } # results in { a => 1, b => 2, c => 2, d => 1 } +``` + +##### skipping values for entries that are longer than 1 char + +```puppet +['a', 'b', 'c', 'c', 'd', 'b', 'blah', 'blah'].merge | $hsh, $v | { if $v =~ String[1,1] { { $v => $hsh[$v].lest || { 0 } + 1 } } } # results in { a => 1, b => 2, c => 2, d => 1 } +``` + +#### `merge(Variant[Hash, Undef, String[0,0]] *$args)` + +The merge function. + +Returns: `Hash` The merged hash + +##### `*args` + +Data type: `Variant[Hash, Undef, String[0,0]]` + +Repeated Param - The hashes that are to be merged + +#### `merge(Iterable *$args, Callable[3,3] &$block)` + +The merge function. + +Returns: `Hash` The merged hash + +##### `*args` + +Data type: `Iterable` + +Repeated Param - The hashes that are to be merged + +##### `&block` + +Data type: `Callable[3,3]` + +A block placed on the repeatable param `args` + +#### `merge(Iterable *$args, Callable[2,2] &$block)` + +The merge function. + +Returns: `Hash` The merged hash + +##### `*args` + +Data type: `Iterable` + +Repeated Param - The hashes that are to be merged + +##### `&block` + +Data type: `Callable[2,2]` + +A block placed on the repeatable param `args` + +### min + +Type: Ruby 3.x API + +Requires at least one argument. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function. + +#### `min()` + +Requires at least one argument. + +> **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function. + +Returns: `Any` The lowest value among the given arguments + +### num2bool + +Type: Ruby 3.x API + +> *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System. +See the new() function in Puppet for the many available type conversions. + +#### `num2bool()` + +> *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System. +See the new() function in Puppet for the many available type conversions. + +Returns: `Boolean` Boolean(0) # false for any zero or negative number +Boolean(1) # true for any positive number + +### os_version_gte + +Type: Ruby 4.x API + +> *Note:* +Only the major version is taken into account. + +#### Examples + +##### Example usage:# + +```puppet +if os_version_gte('Debian', '9') { } +if os_version_gte('Ubuntu', '18.04') { } +``` + +#### `os_version_gte(String[1] $os, String[1] $version)` + +> *Note:* +Only the major version is taken into account. + +Returns: `Boolean` `true` or `false + +##### Examples + +###### Example usage:# + +```puppet +if os_version_gte('Debian', '9') { } +if os_version_gte('Ubuntu', '18.04') { } +``` + +##### `os` + +Data type: `String[1]` + +operating system + +##### `version` + +Data type: `String[1]` + + + +### parsejson + +Type: Ruby 3.x API + +> *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. + +#### `parsejson()` + +> *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. + +Returns: `Any` convert JSON into Puppet structure + +### parseyaml + +Type: Ruby 3.x API + +> *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. + +#### `parseyaml()` + +> *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. + +Returns: `Any` converted YAML into Puppet structure + +### pick + +Type: Ruby 3.x API + +Typically, this function is used to check for a value in the Puppet +Dashboard/Enterprise Console, and failover to a default value like the following: + +```$real_jenkins_version = pick($::jenkins_version, '1.449')``` + +> *Note:* + The value of $real_jenkins_version will first look for a top-scope variable + called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ + Enterprise Console are brought into Puppet as top-scope variables), and, + failing that, will use a default value of 1.449. + +#### `pick()` + +Typically, this function is used to check for a value in the Puppet +Dashboard/Enterprise Console, and failover to a default value like the following: + +```$real_jenkins_version = pick($::jenkins_version, '1.449')``` + +> *Note:* + The value of $real_jenkins_version will first look for a top-scope variable + called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ + Enterprise Console are brought into Puppet as top-scope variables), and, + failing that, will use a default value of 1.449. + +Returns: `Any` the first value in a list of values that is not undefined or an empty string. + +### pick_default + +Type: Ruby 3.x API + +Typically, this function is used to check for a value in the Puppet +Dashboard/Enterprise Console, and failover to a default value like the +following: + + $real_jenkins_version = pick_default($::jenkins_version, '1.449') + +> *Note:* + The value of $real_jenkins_version will first look for a top-scope variable + called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ + Enterprise Console are brought into Puppet as top-scope variables), and, + failing that, will use a default value of 1.449. + + Contrary to the pick() function, the pick_default does not fail if + all arguments are empty. This allows pick_default to use an empty value as + default. + +#### `pick_default()` + +Typically, this function is used to check for a value in the Puppet +Dashboard/Enterprise Console, and failover to a default value like the +following: + + $real_jenkins_version = pick_default($::jenkins_version, '1.449') + +> *Note:* + The value of $real_jenkins_version will first look for a top-scope variable + called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ + Enterprise Console are brought into Puppet as top-scope variables), and, + failing that, will use a default value of 1.449. + + Contrary to the pick() function, the pick_default does not fail if + all arguments are empty. This allows pick_default to use an empty value as + default. + +Returns: `Any` This function is similar to a coalesce function in SQL in that it will return +the first value in a list of values that is not undefined or an empty string +If no value is found, it will return the last argument. + +### prefix + +Type: Ruby 3.x API + +> *Note:* since Puppet 4.0.0 the general way to modify values is in array is by using the map +function in Puppet. This example does the same as the example above: +['a', 'b', 'c'].map |$x| { "p${x}" } + +#### Examples + +##### **Usage** + +```puppet + +prefix(['a','b','c'], 'p') +Will return: ['pa','pb','pc'] +``` + +#### `prefix()` + +> *Note:* since Puppet 4.0.0 the general way to modify values is in array is by using the map +function in Puppet. This example does the same as the example above: +['a', 'b', 'c'].map |$x| { "p${x}" } + +Returns: `Hash` or [Array] The passed values now contains the passed prefix + +##### Examples + +###### **Usage** + +```puppet + +prefix(['a','b','c'], 'p') +Will return: ['pa','pb','pc'] +``` + +### private + +Type: Ruby 3.x API + +**Deprecated:** Sets the current class or definition as private. +Calling the class or definition from outside the current module will fail. + +#### `private()` + +The private function. + +Returns: `Any` Sets the current class or definition as private + +### pry + +Type: Ruby 3.x API + +This is useful for debugging manifest code at specific points during a compilation. + +#### Examples + +##### **Usage** + +```puppet + +`pry()` +``` + +#### `pry()` + +This is useful for debugging manifest code at specific points during a compilation. + +Returns: `Any` debugging information + +##### Examples + +###### **Usage** + +```puppet + +`pry()` +``` + +### pw_hash + +Type: Ruby 3.x API + +The first argument to this function is the password to hash. If it is +undef or an empty string, this function returns undef. + +The second argument to this function is which type of hash to use. It +will be converted into the appropriate crypt(3) hash specifier. Valid +hash types are: + +|Hash type |Specifier| +|---------------------|---------| +|MD5 |1 | +|SHA-256 |5 | +|SHA-512 (recommended)|6 | + +The third argument to this function is the salt to use. + +> *Note:*: this uses the Puppet Master's implementation of crypt(3). If your + environment contains several different operating systems, ensure that they + are compatible before using this function. + +#### `pw_hash()` + +The first argument to this function is the password to hash. If it is +undef or an empty string, this function returns undef. + +The second argument to this function is which type of hash to use. It +will be converted into the appropriate crypt(3) hash specifier. Valid +hash types are: + +|Hash type |Specifier| +|---------------------|---------| +|MD5 |1 | +|SHA-256 |5 | +|SHA-512 (recommended)|6 | + +The third argument to this function is the salt to use. + +> *Note:*: this uses the Puppet Master's implementation of crypt(3). If your + environment contains several different operating systems, ensure that they + are compatible before using this function. + +Returns: `Hash` Provides a hash usable on most POSIX systems. + +### range + +Type: Ruby 3.x API + +NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail. + +> *Note:* + Passing a third argument will cause the generated range to step by that + interval, e.g. + +The Puppet Language support Integer and Float ranges by using the type system. Those are suitable for +iterating a given number of times. + + Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9 + +#### Examples + +##### **Usage** + +```puppet +range("0", "9") +Will return: [0,1,2,3,4,5,6,7,8,9] + +range("00", "09") +Will return: [0,1,2,3,4,5,6,7,8,9] +(Zero padded strings are converted to integers automatically) + +range("a", "c") +Will return: ["a","b","c"] + +range("host01", "host10") +Will return: ["host01", "host02", ..., "host09", "host10"] + +range("0", "9", "2") +Will return: [0,2,4,6,8] +``` + +#### `range()` + +NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail. + +> *Note:* + Passing a third argument will cause the generated range to step by that + interval, e.g. + +The Puppet Language support Integer and Float ranges by using the type system. Those are suitable for +iterating a given number of times. + + Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9 + +Returns: `Any` the range is extrapolated as an array + +##### Examples + +###### **Usage** + +```puppet +range("0", "9") +Will return: [0,1,2,3,4,5,6,7,8,9] + +range("00", "09") +Will return: [0,1,2,3,4,5,6,7,8,9] +(Zero padded strings are converted to integers automatically) + +range("a", "c") +Will return: ["a","b","c"] + +range("host01", "host10") +Will return: ["host01", "host02", ..., "host09", "host10"] + +range("0", "9", "2") +Will return: [0,2,4,6,8] +``` + +### regexpescape + +Type: Ruby 3.x API + +Regexp escape a string or array of strings. +Requires either a single string or an array as an input. + +#### `regexpescape()` + +The regexpescape function. + +Returns: `String` A string of characters with metacharacters converted to their escaped form. + +### reject + +Type: Ruby 3.x API + +> *Note:* +Since Puppet 4.0.0 the same is in general done with the filter function. Here is the equivalence of the reject() function: +['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ + +#### Examples + +##### **Usage** + +```puppet + +reject(['aaa','bbb','ccc','aaaddd'], 'aaa') + +Would return: ['bbb','ccc'] +``` + +#### `reject()` + +> *Note:* +Since Puppet 4.0.0 the same is in general done with the filter function. Here is the equivalence of the reject() function: +['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ + +Returns: `Any` an array containing all the elements which doesn'' match the provided regular expression + +##### Examples + +###### **Usage** + +```puppet + +reject(['aaa','bbb','ccc','aaaddd'], 'aaa') + +Would return: ['bbb','ccc'] +``` + +### reverse + +Type: Ruby 3.x API + +> *Note:* that the same can be done with the reverse_each() function in Puppet. + +#### `reverse()` + +> *Note:* that the same can be done with the reverse_each() function in Puppet. + +Returns: `Any` reversed string or array + +### round + +Type: Ruby 3.x API + +```round(2.9)``` returns ```3``` + +```round(2.4)``` returns ```2``` + +> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core + will be used instead of this function. + +#### `round()` + +```round(2.9)``` returns ```3``` + +```round(2.4)``` returns ```2``` + +> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core + will be used instead of this function. + +Returns: `Any` the rounded value as integer + +### rstrip + +Type: Ruby 3.x API + +> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +#### `rstrip()` + +> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +Returns: `Any` the string with leading spaces removed + +### seeded_rand + +Type: Ruby 3.x API + +Generates a random whole number greater than or equal to 0 and less +than MAX, using the value of SEED for repeatable randomness. If SEED +starts with "$fqdn:", this is behaves the same as `fqdn_rand`. + +#### Examples + +##### **Usage:** + +```puppet +seeded_rand(MAX, SEED). +MAX must be a positive integer; SEED is any string. +``` + +#### `seeded_rand()` + +Generates a random whole number greater than or equal to 0 and less +than MAX, using the value of SEED for repeatable randomness. If SEED +starts with "$fqdn:", this is behaves the same as `fqdn_rand`. + +Returns: `Any` random number greater than or equal to 0 and less than MAX + +##### Examples + +###### **Usage:** + +```puppet +seeded_rand(MAX, SEED). +MAX must be a positive integer; SEED is any string. +``` + +### seeded_rand_string + +Type: Ruby 4.x API + +Generates a consistent random string of specific length based on provided seed. + +#### Examples + +##### Generate a consistently random string of length 8 with a seed: + +```puppet +seeded_rand_string(8, "${module_name}::redis_password") +``` + +##### Generate a random string from a specific set of characters: + +```puppet +seeded_rand_string(5, '', 'abcdef') +``` + +#### `seeded_rand_string(Integer[1] $length, String $seed, Optional[String[2]] $charset)` + +The seeded_rand_string function. + +Returns: `String` Random string. + +##### Examples + +###### Generate a consistently random string of length 8 with a seed: + +```puppet +seeded_rand_string(8, "${module_name}::redis_password") +``` + +###### Generate a random string from a specific set of characters: + +```puppet +seeded_rand_string(5, '', 'abcdef') +``` + +##### `length` + +Data type: `Integer[1]` + +Length of string to be generated. + +##### `seed` + +Data type: `String` + +Seed string. + +##### `charset` + +Data type: `Optional[String[2]]` + +String that contains characters to use for the random string. + +### shell_escape + +Type: Ruby 3.x API + +>* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single +quotes. + +This function behaves the same as ruby's Shellwords.shellescape() function. + +#### `shell_escape()` + +>* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single +quotes. + +This function behaves the same as ruby's Shellwords.shellescape() function. + +Returns: `Any` A string of characters with metacharacters converted to their escaped form. + +### shell_join + +Type: Ruby 3.x API + +Builds a command line string from the given array of strings. +Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between. +This function behaves the same as ruby's Shellwords.shelljoin() function + +#### `shell_join()` + +Builds a command line string from the given array of strings. +Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between. +This function behaves the same as ruby's Shellwords.shelljoin() function + +Returns: `Any` a command line string + +### shell_split + +Type: Ruby 3.x API + +This function behaves the same as ruby's Shellwords.shellsplit() function + +#### `shell_split()` + +This function behaves the same as ruby's Shellwords.shellsplit() function + +Returns: `Any` array of tokens + +### shuffle + +Type: Ruby 3.x API + +@summary + Randomizes the order of a string or array elements. + +#### `shuffle()` + +@summary + Randomizes the order of a string or array elements. + +Returns: `Any` randomized string or array + +### size + +Type: Ruby 3.x API + +> *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions +of Puppet < 5.4.0 use the stdlib length() function. + +#### `size()` + +> *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions +of Puppet < 5.4.0 use the stdlib length() function. + +Returns: `Any` the number of elements in a string, an array or a hash + +### sort + +Type: Ruby 3.x API + +Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this. + +#### `sort()` + +Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this. + +Returns: `Any` sorted string or array + +### sprintf_hash + +Type: Ruby 4.x API + +The first parameter is format string describing how the rest of the parameters in the hash +should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for +all the details. + +In the given argument hash with parameters, all keys are converted to symbols so they work +with the `sprintf` function. + +Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the +`sprintf` function in puppet core. + +#### Examples + +##### Format a string and number + +```puppet +$output = sprintf_hash('String: %s / number converted to binary: %b', + { 'foo' => 'a string', 'number' => 5 }) +# $output = 'String: a string / number converted to binary: 101' +``` + +#### `sprintf_hash(String $format, Hash $arguments)` + +The first parameter is format string describing how the rest of the parameters in the hash +should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for +all the details. + +In the given argument hash with parameters, all keys are converted to symbols so they work +with the `sprintf` function. + +Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the +`sprintf` function in puppet core. + +Returns: `Any` The formatted string. + +##### Examples + +###### Format a string and number + +```puppet +$output = sprintf_hash('String: %s / number converted to binary: %b', + { 'foo' => 'a string', 'number' => 5 }) +# $output = 'String: a string / number converted to binary: 101' +``` + +##### `format` + +Data type: `String` + +The format to use. + +##### `arguments` + +Data type: `Hash` + +Hash with parameters. + +### squeeze + +Type: Ruby 3.x API + +Returns a new string where runs of the same character that occur in this set are replaced by a single character. + +#### `squeeze()` + +The squeeze function. + +Returns: `Any` a new string where runs of the same character that occur in this set are replaced by a single character. + +### stdlib::extname + +Type: Ruby 4.x API + +If Path is a Dotfile, or starts with a Period, then the starting Dot is not +dealt with the Start of the Extension. + +An empty String will also be returned, when the Period is the last Character +in Path. + +#### Examples + +##### Determining the Extension of a Filename + +```puppet +stdlib::extname('test.rb') => '.rb' +stdlib::extname('a/b/d/test.rb') => '.rb' +stdlib::extname('test') => '' +stdlib::extname('.profile') => '' +``` + +#### `stdlib::extname(String $filename)` + +If Path is a Dotfile, or starts with a Period, then the starting Dot is not +dealt with the Start of the Extension. + +An empty String will also be returned, when the Period is the last Character +in Path. + +Returns: `String` The Extension starting from the last Period + +##### Examples + +###### Determining the Extension of a Filename + +```puppet +stdlib::extname('test.rb') => '.rb' +stdlib::extname('a/b/d/test.rb') => '.rb' +stdlib::extname('test') => '' +stdlib::extname('.profile') => '' +``` + +##### `filename` + +Data type: `String` + +The Filename + +### stdlib::ip_in_range + +Type: Ruby 4.x API + +Returns true if the ipaddress is within the given CIDRs + +#### Examples + +##### ip_in_range(, ) + +```puppet +stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true +``` + +#### `stdlib::ip_in_range(String $ipaddress, Variant[String, Array] $range)` + +The stdlib::ip_in_range function. + +Returns: `Boolean` True or False + +##### Examples + +###### ip_in_range(, ) + +```puppet +stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true +``` + +##### `ipaddress` + +Data type: `String` + +The IP address to check + +##### `range` + +Data type: `Variant[String, Array]` + +One CIDR or an array of CIDRs +defining the range(s) to check against + +### str2bool + +Type: Ruby 3.x API + +> *Note:* that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value. +See the function new() in Puppet for details what the Boolean data type supports. + +#### `str2bool()` + +> *Note:* that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value. +See the function new() in Puppet for details what the Boolean data type supports. + +Returns: `Any` This attempt to convert to boolean strings that contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things +like: 0, F,f, N,n, false, FALSE, no to 'false'. + +### str2saltedsha512 + +Type: Ruby 3.x API + +Given any simple string, you will get a hex version +of a salted-SHA512 password hash that can be inserted into your Puppet +manifests as a valid password attribute. + +#### `str2saltedsha512()` + +Given any simple string, you will get a hex version +of a salted-SHA512 password hash that can be inserted into your Puppet +manifests as a valid password attribute. + +Returns: `Any` converted string as a hex version of a salted-SHA512 password hash + +### strftime + +Type: Ruby 3.x API + +> *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this +function. It also supports the Timestamp and Timespan data types in the Puppet language. + +**Format meaning:** + + %a - The abbreviated weekday name (``Sun'') + %A - The full weekday name (``Sunday'') + %b - The abbreviated month name (``Jan'') + %B - The full month name (``January'') + %c - The preferred local date and time representation + %C - Century (20 in 2009) + %d - Day of the month (01..31) + %D - Date (%m/%d/%y) + %e - Day of the month, blank-padded ( 1..31) + %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) + %h - Equivalent to %b + %H - Hour of the day, 24-hour clock (00..23) + %I - Hour of the day, 12-hour clock (01..12) + %j - Day of the year (001..366) + %k - hour, 24-hour clock, blank-padded ( 0..23) + %l - hour, 12-hour clock, blank-padded ( 0..12) + %L - Millisecond of the second (000..999) + %m - Month of the year (01..12) + %M - Minute of the hour (00..59) + %n - Newline (\n) + %N - Fractional seconds digits, default is 9 digits (nanosecond) + %3N millisecond (3 digits) + %6N microsecond (6 digits) + %9N nanosecond (9 digits) + %p - Meridian indicator (``AM'' or ``PM'') + %P - Meridian indicator (``am'' or ``pm'') + %r - time, 12-hour (same as %I:%M:%S %p) + %R - time, 24-hour (%H:%M) + %s - Number of seconds since 1970-01-01 00:00:00 UTC. + %S - Second of the minute (00..60) + %t - Tab character (\t) + %T - time, 24-hour (%H:%M:%S) + %u - Day of the week as a decimal, Monday being 1. (1..7) + %U - Week number of the current year, + starting with the first Sunday as the first + day of the first week (00..53) + %v - VMS date (%e-%b-%Y) + %V - Week number of year according to ISO 8601 (01..53) + %W - Week number of the current year, + starting with the first Monday as the first + day of the first week (00..53) + %w - Day of the week (Sunday is 0, 0..6) + %x - Preferred representation for the date alone, no time + %X - Preferred representation for the time alone, no date + %y - Year without a century (00..99) + %Y - Year with century + %z - Time zone as hour offset from UTC (e.g. +0900) + %Z - Time zone name + %% - Literal ``%'' character + +#### Examples + +##### **Usage** + +```puppet + +To return the time since epoch: strftime("%s") +To return the date: strftime("%Y-%m-%d") +``` + +#### `strftime()` + +> *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this +function. It also supports the Timestamp and Timespan data types in the Puppet language. + +**Format meaning:** + + %a - The abbreviated weekday name (``Sun'') + %A - The full weekday name (``Sunday'') + %b - The abbreviated month name (``Jan'') + %B - The full month name (``January'') + %c - The preferred local date and time representation + %C - Century (20 in 2009) + %d - Day of the month (01..31) + %D - Date (%m/%d/%y) + %e - Day of the month, blank-padded ( 1..31) + %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) + %h - Equivalent to %b + %H - Hour of the day, 24-hour clock (00..23) + %I - Hour of the day, 12-hour clock (01..12) + %j - Day of the year (001..366) + %k - hour, 24-hour clock, blank-padded ( 0..23) + %l - hour, 12-hour clock, blank-padded ( 0..12) + %L - Millisecond of the second (000..999) + %m - Month of the year (01..12) + %M - Minute of the hour (00..59) + %n - Newline (\n) + %N - Fractional seconds digits, default is 9 digits (nanosecond) + %3N millisecond (3 digits) + %6N microsecond (6 digits) + %9N nanosecond (9 digits) + %p - Meridian indicator (``AM'' or ``PM'') + %P - Meridian indicator (``am'' or ``pm'') + %r - time, 12-hour (same as %I:%M:%S %p) + %R - time, 24-hour (%H:%M) + %s - Number of seconds since 1970-01-01 00:00:00 UTC. + %S - Second of the minute (00..60) + %t - Tab character (\t) + %T - time, 24-hour (%H:%M:%S) + %u - Day of the week as a decimal, Monday being 1. (1..7) + %U - Week number of the current year, + starting with the first Sunday as the first + day of the first week (00..53) + %v - VMS date (%e-%b-%Y) + %V - Week number of year according to ISO 8601 (01..53) + %W - Week number of the current year, + starting with the first Monday as the first + day of the first week (00..53) + %w - Day of the week (Sunday is 0, 0..6) + %x - Preferred representation for the date alone, no time + %X - Preferred representation for the time alone, no date + %y - Year without a century (00..99) + %Y - Year with century + %z - Time zone as hour offset from UTC (e.g. +0900) + %Z - Time zone name + %% - Literal ``%'' character + +Returns: `Any` converted time according to the directives in the given format string + +##### Examples + +###### **Usage** + +```puppet + +To return the time since epoch: strftime("%s") +To return the date: strftime("%Y-%m-%d") +``` + +### strip + +Type: Ruby 3.x API + +> *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +#### Examples + +##### **Usage** + +```puppet + +strip(" aaa ") +Would result in: "aaa" +``` + +#### `strip()` + +> *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +Returns: `Any` String or Array converted + +##### Examples + +###### **Usage** + +```puppet + +strip(" aaa ") +Would result in: "aaa" +``` + +### suffix + +Type: Ruby 3.x API + +> *Note:* that since Puppet 4.0.0 the general way to modify values is in array is by using the map +function in Puppet. This example does the same as the example above: + +```['a', 'b', 'c'].map |$x| { "${x}p" }``` + +#### Examples + +##### **Usage** + +```puppet + +suffix(['a','b','c'], 'p') +Will return: ['ap','bp','cp'] +``` + +#### `suffix()` + +> *Note:* that since Puppet 4.0.0 the general way to modify values is in array is by using the map +function in Puppet. This example does the same as the example above: + +```['a', 'b', 'c'].map |$x| { "${x}p" }``` + +Returns: `Any` Array or Hash with updated elements containing the passed suffix + +##### Examples + +###### **Usage** + +```puppet + +suffix(['a','b','c'], 'p') +Will return: ['ap','bp','cp'] +``` + +### swapcase + +Type: Ruby 3.x API + +This function will swap the existing case of a string. + +#### Examples + +##### **Usage** + +```puppet + +swapcase("aBcD") +Would result in: "AbCd" +``` + +#### `swapcase()` + +The swapcase function. + +Returns: `Any` string with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase + +##### Examples + +###### **Usage** + +```puppet + +swapcase("aBcD") +Would result in: "AbCd" +``` + +### time + +Type: Ruby 3.x API + +> *Note:* that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and +Timespan (a duration). The following example is equivalent to calling time() without +any arguments: + +```Timestamp()``` + +#### Examples + +##### **Usage** + +```puppet + +time() +Will return something like: 1311972653 +``` + +#### `time()` + +> *Note:* that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and +Timespan (a duration). The following example is equivalent to calling time() without +any arguments: + +```Timestamp()``` + +Returns: `Any` the current time since epoch as an integer. + +##### Examples + +###### **Usage** + +```puppet + +time() +Will return something like: 1311972653 +``` + +### to_bytes + +Type: Ruby 3.x API + +Takes a single string value as an argument. +These conversions reflect a layperson's understanding of +1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB. + +#### `to_bytes()` + +Takes a single string value as an argument. +These conversions reflect a layperson's understanding of +1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB. + +Returns: `Any` converted value into bytes + +### to_json + +Type: Ruby 4.x API + +Convert a data structure and output to JSON + +#### Examples + +##### how to output JSON + +```puppet +# output json to a file + file { '/tmp/my.json': + ensure => file, + content => to_json($myhash), + } +``` + +#### `to_json(Any $data)` + +The to_json function. + +Returns: `Any` converted data to json + +##### Examples + +###### how to output JSON + +```puppet +# output json to a file + file { '/tmp/my.json': + ensure => file, + content => to_json($myhash), + } +``` + +##### `data` + +Data type: `Any` + +data structure which needs to be converted into JSON + +### to_json_pretty + +Type: Ruby 4.x API + +Convert data structure and output to pretty JSON + +#### Examples + +##### **Usage** + +```puppet +* how to output pretty JSON to file + file { '/tmp/my.json': + ensure => file, + content => to_json_pretty($myhash), + } + +* how to output pretty JSON skipping over keys with undef values + file { '/tmp/my.json': + ensure => file, + content => to_json_pretty({ + param_one => 'value', + param_two => undef, + }), + } +``` + +#### `to_json_pretty(Variant[Hash, Array] $data, Optional[Boolean] $skip_undef)` + +The to_json_pretty function. + +Returns: `Any` converted data to pretty json + +##### Examples + +###### **Usage** + +```puppet +* how to output pretty JSON to file + file { '/tmp/my.json': + ensure => file, + content => to_json_pretty($myhash), + } + +* how to output pretty JSON skipping over keys with undef values + file { '/tmp/my.json': + ensure => file, + content => to_json_pretty({ + param_one => 'value', + param_two => undef, + }), + } +``` + +##### `data` + +Data type: `Variant[Hash, Array]` + +data structure which needs to be converted to pretty json + +##### `skip_undef` + +Data type: `Optional[Boolean]` + +value `true` or `false` + +### to_yaml + +Type: Ruby 4.x API + +Convert a data structure and output it as YAML + +#### Examples + +##### how to output YAML + +```puppet +# output yaml to a file + file { '/tmp/my.yaml': + ensure => file, + content => to_yaml($myhash), + } +``` + +#### `to_yaml(Any $data)` + +The to_yaml function. + +Returns: `String` + +##### Examples + +###### how to output YAML + +```puppet +# output yaml to a file + file { '/tmp/my.yaml': + ensure => file, + content => to_yaml($myhash), + } +``` + +##### `data` + +Data type: `Any` + + + +### try_get_value + +Type: Ruby 3.x API + +Key can contain slashes to describe path components. The function will go down +the structure and try to extract the required value. +`` +$data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } +} + +$value = try_get_value($data, 'a/b/2', 'not_found', '/') +=> $value = 'b3' +``` +``` +a -> first hash key +b -> second hash key +2 -> array index starting with 0 + +not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil. +/ -> (optional) path delimiter. Defaults to '/'. +``` + +In addition to the required "key" argument, "try_get_value" accepts default +argument. It will be returned if no value was found or a path component is +missing. And the fourth argument can set a variable path separator. + +#### `try_get_value()` + +Key can contain slashes to describe path components. The function will go down +the structure and try to extract the required value. +`` +$data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } +} + +$value = try_get_value($data, 'a/b/2', 'not_found', '/') +=> $value = 'b3' +``` +``` +a -> first hash key +b -> second hash key +2 -> array index starting with 0 + +not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil. +/ -> (optional) path delimiter. Defaults to '/'. +``` + +In addition to the required "key" argument, "try_get_value" accepts default +argument. It will be returned if no value was found or a path component is +missing. And the fourth argument can set a variable path separator. + +Returns: `Any` Looks up into a complex structure of arrays and hashes and returns a value +or the default value if nothing was found. + +### type + +Type: Ruby 3.x API + +please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system. + +* string +* array +* hash +* float +* integer +* boolean + +#### `type()` + +please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system. + +* string +* array +* hash +* float +* integer +* boolean + +Returns: `Any` the type when passed a value. Type can be one of: + +### type3x + +Type: Ruby 3.x API + +* string +* array +* hash +* float +* integer +* boolean + +#### `type3x()` + +* string +* array +* hash +* float +* integer +* boolean + +Returns: `Any` the type when passed a value. Type can be one of: + +### type_of + +Type: Ruby 4.x API + +See the documentation for "The Puppet Type System" for more information about types. +See the `assert_type()` function for flexible ways to assert the type of a value. + +The built-in type() function in puppet is generally preferred over this function +this function is provided for backwards compatibility. + +#### Examples + +##### how to compare values' types + +```puppet +# compare the types of two values +if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") } +``` + +##### how to compare against an abstract type + +```puppet +unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") } +unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") } +``` + +#### `type_of(Any $value)` + +See the documentation for "The Puppet Type System" for more information about types. +See the `assert_type()` function for flexible ways to assert the type of a value. + +The built-in type() function in puppet is generally preferred over this function +this function is provided for backwards compatibility. + +Returns: `String` the type of the passed value + +##### Examples + +###### how to compare values' types + +```puppet +# compare the types of two values +if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") } +``` + +###### how to compare against an abstract type + +```puppet +unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") } +unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") } +``` + +##### `value` + +Data type: `Any` + + + +### union + +Type: Ruby 3.x API + +This function returns a union of two or more arrays. + +#### Examples + +##### **Usage** + +```puppet + +union(["a","b","c"],["b","c","d"]) +Would return: ["a","b","c","d"] +``` + +#### `union()` + +The union function. + +Returns: `Any` a unionized array of two or more arrays + +##### Examples + +###### **Usage** + +```puppet + +union(["a","b","c"],["b","c","d"]) +Would return: ["a","b","c","d"] +``` + +### unique + +Type: Ruby 3.x API + +This function will remove duplicates from strings and arrays. + +#### Examples + +##### **Usage** + +```puppet + +unique("aabbcc") +Will return: abc + +You can also use this with arrays: + +unique(["a","a","b","b","c","c"]) +This returns: ["a","b","c"] +``` + +#### `unique()` + +The unique function. + +Returns: `Any` String or array with duplicates removed + +##### Examples + +###### **Usage** + +```puppet + +unique("aabbcc") +Will return: abc + +You can also use this with arrays: + +unique(["a","a","b","b","c","c"]) +This returns: ["a","b","c"] +``` + +### unix2dos + +Type: Ruby 3.x API + +Takes a single string argument. + +#### `unix2dos()` + +Takes a single string argument. + +Returns: `Any` the DOS version of the given string. + +### upcase + +Type: Ruby 3.x API + +> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +#### Examples + +##### **Usage** + +```puppet + +upcase("abcd") +Will return ABCD +``` + +#### `upcase()` + +> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +Returns: `Any` converted string ot array of strings to uppercase + +##### Examples + +###### **Usage** + +```puppet + +upcase("abcd") +Will return ABCD +``` + +### uriescape + +Type: Ruby 3.x API + +Urlencodes a string or array of strings. +Requires either a single string or an array as an input. + +#### `uriescape()` + +The uriescape function. + +Returns: `String` a string that contains the converted value + +### validate_absolute_path + +Type: Ruby 3.x API + +Validate the string represents an absolute path in the filesystem. This function works +for windows and unix style paths. + +#### Examples + +##### **Usage** + +```puppet + +The following values will pass: + + $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' + validate_absolute_path($my_path) + $my_path2 = '/var/lib/puppet' + validate_absolute_path($my_path2) + $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] + validate_absolute_path($my_path3) + $my_path4 = ['/var/lib/puppet','/usr/share/puppet'] + validate_absolute_path($my_path4) + +The following values will fail, causing compilation to abort: + + validate_absolute_path(true) + validate_absolute_path('../var/lib/puppet') + validate_absolute_path('var/lib/puppet') + validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) + validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) + $undefined = undef + validate_absolute_path($undefin +``` + +#### `validate_absolute_path()` + +The validate_absolute_path function. + +Returns: `Any` passes when the string is an absolute path or raise an error when it is not and fails compilation + +##### Examples + +###### **Usage** + +```puppet + +The following values will pass: + + $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' + validate_absolute_path($my_path) + $my_path2 = '/var/lib/puppet' + validate_absolute_path($my_path2) + $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] + validate_absolute_path($my_path3) + $my_path4 = ['/var/lib/puppet','/usr/share/puppet'] + validate_absolute_path($my_path4) + +The following values will fail, causing compilation to abort: + + validate_absolute_path(true) + validate_absolute_path('../var/lib/puppet') + validate_absolute_path('var/lib/puppet') + validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) + validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) + $undefined = undef + validate_absolute_path($undefin +``` + +### validate_absolute_path + +Type: Ruby 4.x API + +Validate the string represents an absolute path in the filesystem. + +#### `validate_absolute_path(Any $scope, Any *$args)` + +The validate_absolute_path function. + +Returns: `Boolean` A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_array + +Type: Ruby 4.x API + +Validate the passed value represents an array. + +#### `validate_array(Any $scope, Any *$args)` + +The validate_array function. + +Returns: `Any` A boolean value (`true` or `false`) returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_array + +Type: Ruby 3.x API + +Validate that all passed values are array data structures. Abort catalog +compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet +The following values will pass: + + $my_array = [ 'one', 'two' ] + validate_array($my_array) + +The following values will fail, causing compilation to abort: + + validate_array(true) + validate_array('some_string') + $undefined = undef + validate_array($undefined +``` + +#### `validate_array()` + +The validate_array function. + +Returns: `Any` validate array + +##### Examples + +###### **Usage** + +```puppet +The following values will pass: + + $my_array = [ 'one', 'two' ] + validate_array($my_array) + +The following values will fail, causing compilation to abort: + + validate_array(true) + validate_array('some_string') + $undefined = undef + validate_array($undefined +``` + +### validate_augeas + +Type: Ruby 3.x API + +The first argument of this function should be a string to +test, and the second argument should be the name of the Augeas lens to use. +If Augeas fails to parse the string with the lens, the compilation will +abort with a parse error. + +A third argument can be specified, listing paths which should +not be found in the file. The `$file` variable points to the location +of the temporary file being tested in the Augeas tree. + +#### Examples + +##### **Usage** + +```puppet + +If you want to make sure your passwd content never contains +a user `foo`, you could write: + + validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) + +If you wanted to ensure that no users used the '/bin/barsh' shell, +you could use: + + validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]'] + +If a fourth argument is specified, this will be the error message raised and +seen by the user. + +A helpful error message can be returned like this: + + validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') +``` + +#### `validate_augeas()` + +The first argument of this function should be a string to +test, and the second argument should be the name of the Augeas lens to use. +If Augeas fails to parse the string with the lens, the compilation will +abort with a parse error. + +A third argument can be specified, listing paths which should +not be found in the file. The `$file` variable points to the location +of the temporary file being tested in the Augeas tree. + +Returns: `Any` validate string using an Augeas lens + +##### Examples + +###### **Usage** + +```puppet + +If you want to make sure your passwd content never contains +a user `foo`, you could write: + + validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) + +If you wanted to ensure that no users used the '/bin/barsh' shell, +you could use: + + validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]'] + +If a fourth argument is specified, this will be the error message raised and +seen by the user. + +A helpful error message can be returned like this: + + validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') +``` + +### validate_bool + +Type: Ruby 3.x API + +Validate that all passed values are either true or false. Abort catalog +compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet + +The following values will pass: + + $iamtrue = true + validate_bool(true) + validate_bool(true, true, false, $iamtrue) + +The following values will fail, causing compilation to abort: + + $some_array = [ true ] + validate_bool("false") + validate_bool("true") + validate_bool($some_array) +``` + +#### `validate_bool()` + +The validate_bool function. + +Returns: `Any` validate boolean + +##### Examples + +###### **Usage** + +```puppet + +The following values will pass: + + $iamtrue = true + validate_bool(true) + validate_bool(true, true, false, $iamtrue) + +The following values will fail, causing compilation to abort: + + $some_array = [ true ] + validate_bool("false") + validate_bool("true") + validate_bool($some_array) +``` + +### validate_bool + +Type: Ruby 4.x API + +Validate the passed value represents a boolean. + +#### `validate_bool(Any $scope, Any *$args)` + +The validate_bool function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_cmd + +Type: Ruby 3.x API + +The first argument of this function should be a string to +test, and the second argument should be a path to a test command +taking a % as a placeholder for the file path (will default to the end). +If the command, launched against a tempfile containing the passed string, +returns a non-null value, compilation will abort with a parse error. +If a third argument is specified, this will be the error message raised and +seen by the user. + +A helpful error message can be returned like this: + +#### Examples + +##### **Usage** + +```puppet + +Defaults to end of path + validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') + +% as file location + validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') +``` + +#### `validate_cmd()` + +The first argument of this function should be a string to +test, and the second argument should be a path to a test command +taking a % as a placeholder for the file path (will default to the end). +If the command, launched against a tempfile containing the passed string, +returns a non-null value, compilation will abort with a parse error. +If a third argument is specified, this will be the error message raised and +seen by the user. + +A helpful error message can be returned like this: + +Returns: `Any` validate of a string with an external command + +##### Examples + +###### **Usage** + +```puppet + +Defaults to end of path + validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') + +% as file location + validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') +``` + +### validate_domain_name + +Type: Ruby 3.x API + +Validate that all values passed are syntactically correct domain names. +Fail compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet + +The following values will pass: + + $my_domain_name = 'server.domain.tld' + validate_domain_name($my_domain_name) + validate_domain_name('domain.tld', 'puppet.com', $my_domain_name) + +The following values will fail, causing compilation to abort: + + validate_domain_name(1) + validate_domain_name(true) + validate_domain_name('invalid domain') + validate_domain_name('-foo.example.com') + validate_domain_name('www.example.2com') +``` + +#### `validate_domain_name()` + +The validate_domain_name function. + +Returns: `Any` passes when the given values are syntactically correct domain names or raise an error when they are not and fails compilation + +##### Examples + +###### **Usage** + +```puppet + +The following values will pass: + + $my_domain_name = 'server.domain.tld' + validate_domain_name($my_domain_name) + validate_domain_name('domain.tld', 'puppet.com', $my_domain_name) + +The following values will fail, causing compilation to abort: + + validate_domain_name(1) + validate_domain_name(true) + validate_domain_name('invalid domain') + validate_domain_name('-foo.example.com') + validate_domain_name('www.example.2com') +``` + +### validate_email_address + +Type: Ruby 3.x API + +Validate that all values passed are valid email addresses. +Fail compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet + +The following values will pass: + + $my_email = "waldo@gmail.com" + validate_email_address($my_email) + validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) + +The following values will fail, causing compilation to abort: + + $some_array = [ 'bad_email@/d/efdf.com' ] + validate_email_address($some_array) +``` + +#### `validate_email_address()` + +The validate_email_address function. + +Returns: `Any` Fail compilation if any value fails this check. + +##### Examples + +###### **Usage** + +```puppet + +The following values will pass: + + $my_email = "waldo@gmail.com" + validate_email_address($my_email) + validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) + +The following values will fail, causing compilation to abort: + + $some_array = [ 'bad_email@/d/efdf.com' ] + validate_email_address($some_array) +``` + +### validate_hash + +Type: Ruby 4.x API + +Validate the passed value represents a hash. + +#### `validate_hash(Any $scope, Any *$args)` + +The validate_hash function. + +Returns: `Any` A boolean value (`true` or `false`) returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_hash + +Type: Ruby 3.x API + +Validate that all passed values are hash data structures. Abort catalog +compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet + +The following values will pass: + + $my_hash = { 'one' => 'two' } + validate_hash($my_hash) + +The following values will fail, causing compilation to abort: + + validate_hash(true) + validate_hash('some_string') + $undefined = undef + validate_hash($undefined) +``` + +#### `validate_hash()` + +The validate_hash function. + +Returns: `Any` validate hash + +##### Examples + +###### **Usage** + +```puppet + +The following values will pass: + + $my_hash = { 'one' => 'two' } + validate_hash($my_hash) + +The following values will fail, causing compilation to abort: + + validate_hash(true) + validate_hash('some_string') + $undefined = undef + validate_hash($undefined) +``` + +### validate_integer + +Type: Ruby 3.x API + +The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. +The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. +If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check +if (all elements of) the first argument are greater or equal to the given minimum. +It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer. + +#### Examples + +##### **Usage** + +```puppet + +The following values will pass: + + validate_integer(1) + validate_integer(1, 2) + validate_integer(1, 1) + validate_integer(1, 2, 0) + validate_integer(2, 2, 2) + validate_integer(2, '', 0) + validate_integer(2, undef, 0) + $foo = undef + validate_integer(2, $foo, 0) + validate_integer([1,2,3,4,5], 6) + validate_integer([1,2,3,4,5], 6, 0) + +Plus all of the above, but any combination of values passed as strings ('1' or "1"). +Plus all of the above, but with (correct) combinations of negative integer values. + +The following values will not: + + validate_integer(true) + validate_integer(false) + validate_integer(7.0) + validate_integer({ 1 => 2 }) + $foo = undef + validate_integer($foo) + validate_integer($foobaridontexist) + + validate_integer(1, 0) + validate_integer(1, true) + validate_integer(1, '') + validate_integer(1, undef) + validate_integer(1, , 0) + validate_integer(1, 2, 3) + validate_integer(1, 3, 2) + validate_integer(1, 3, true) + +Plus all of the above, but any combination of values passed as strings ('false' or "false"). +Plus all of the above, but with incorrect combinations of negative integer values. +Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. +``` + +#### `validate_integer()` + +The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. +The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. +If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check +if (all elements of) the first argument are greater or equal to the given minimum. +It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer. + +Returns: `Any` Validate that the first argument is an integer (or an array of integers). Fail compilation if any of the checks fail. + +##### Examples + +###### **Usage** + +```puppet + +The following values will pass: + + validate_integer(1) + validate_integer(1, 2) + validate_integer(1, 1) + validate_integer(1, 2, 0) + validate_integer(2, 2, 2) + validate_integer(2, '', 0) + validate_integer(2, undef, 0) + $foo = undef + validate_integer(2, $foo, 0) + validate_integer([1,2,3,4,5], 6) + validate_integer([1,2,3,4,5], 6, 0) + +Plus all of the above, but any combination of values passed as strings ('1' or "1"). +Plus all of the above, but with (correct) combinations of negative integer values. + +The following values will not: + + validate_integer(true) + validate_integer(false) + validate_integer(7.0) + validate_integer({ 1 => 2 }) + $foo = undef + validate_integer($foo) + validate_integer($foobaridontexist) + + validate_integer(1, 0) + validate_integer(1, true) + validate_integer(1, '') + validate_integer(1, undef) + validate_integer(1, , 0) + validate_integer(1, 2, 3) + validate_integer(1, 3, 2) + validate_integer(1, 3, true) + +Plus all of the above, but any combination of values passed as strings ('false' or "false"). +Plus all of the above, but with incorrect combinations of negative integer values. +Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. +``` + +### validate_integer + +Type: Ruby 4.x API + +Validate the passed value represents an integer. + +#### `validate_integer(Any $scope, Any *$args)` + +The validate_integer function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_ip_address + +Type: Ruby 4.x API + +Validate the passed value represents an ip_address. + +#### `validate_ip_address(Any $scope, Any *$args)` + +The validate_ip_address function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_ip_address + +Type: Ruby 3.x API + +Validate that all values passed are valid IP addresses, +regardless they are IPv4 or IPv6 +Fail compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet +The following values will pass: + + $my_ip = "1.2.3.4" + validate_ip_address($my_ip) + validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip) + + $my_ip = "3ffe:505:2" + validate_ip_address(1) + validate_ip_address($my_ip) + validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip) + +The following values will fail, causing compilation to abort: + + $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] + validate_ip_address($some_array) +``` + +#### `validate_ip_address()` + +The validate_ip_address function. + +Returns: `Any` passes when the given values are valid IP addresses or raise an error when they are not and fails compilation + +##### Examples + +###### **Usage** + +```puppet +The following values will pass: + + $my_ip = "1.2.3.4" + validate_ip_address($my_ip) + validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip) + + $my_ip = "3ffe:505:2" + validate_ip_address(1) + validate_ip_address($my_ip) + validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip) + +The following values will fail, causing compilation to abort: + + $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] + validate_ip_address($some_array) +``` + +### validate_ipv4_address + +Type: Ruby 4.x API + +Validate the passed value represents an ipv4_address. + +#### `validate_ipv4_address(Any $scope, Any *$args)` + +The validate_ipv4_address function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_ipv4_address + +Type: Ruby 3.x API + +Validate that all values passed are valid IPv4 addresses. +Fail compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet +The following values will pass: + + $my_ip = "1.2.3.4" + validate_ipv4_address($my_ip) + validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip) + +The following values will fail, causing compilation to abort: + + $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] + validate_ipv4_address($some_array) +``` + +#### `validate_ipv4_address()` + +The validate_ipv4_address function. + +Returns: `Any` passes when the given values are valid IPv4 addresses or raise an error when they are not and fails compilation + +##### Examples + +###### **Usage** + +```puppet +The following values will pass: + + $my_ip = "1.2.3.4" + validate_ipv4_address($my_ip) + validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip) + +The following values will fail, causing compilation to abort: + + $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] + validate_ipv4_address($some_array) +``` + +### validate_ipv6_address + +Type: Ruby 4.x API + +Validate the passed value represents an ipv6_address. + +#### `validate_ipv6_address(Any $scope, Any *$args)` + +The validate_ipv6_address function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_ipv6_address + +Type: Ruby 3.x API + +Validate that all values passed are valid IPv6 addresses. +Fail compilation if any value fails this check. + +#### Examples + +##### **Usage** + +```puppet +The following values will pass: + + $my_ip = "3ffe:505:2" + validate_ipv6_address(1) + validate_ipv6_address($my_ip) + validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip) + +The following values will fail, causing compilation to abort: + + $some_array = [ true, false, "garbage string", "1.2.3.4" ] + validate_ipv6_address($some_array) +``` + +#### `validate_ipv6_address()` + +The validate_ipv6_address function. + +Returns: `Any` passes when the given values are valid IPv6 addresses or raise an error when they are not and fails compilation + +##### Examples + +###### **Usage** + +```puppet +The following values will pass: + + $my_ip = "3ffe:505:2" + validate_ipv6_address(1) + validate_ipv6_address($my_ip) + validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip) + +The following values will fail, causing compilation to abort: + + $some_array = [ true, false, "garbage string", "1.2.3.4" ] + validate_ipv6_address($some_array) +``` + +### validate_legacy + +Type: Ruby 4.x API + +Validate a value against both the target_type (new) and the previous_validation function (old). + +#### `validate_legacy(Any $scope, Type $target_type, String $function_name, Any $value, Any *$args)` + +The function checks a value against both the target_type (new) and the previous_validation function (old). + +Returns: `Any` A boolean value (`true` or `false`) returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `target_type` + +Data type: `Type` + + + +##### `function_name` + +Data type: `String` + + + +##### `value` + +Data type: `Any` + + + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +#### `validate_legacy(Any $scope, String $type_string, String $function_name, Any $value, Any *$args)` + +The validate_legacy function. + +Returns: `Any` Legacy validation method + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `type_string` + +Data type: `String` + + + +##### `function_name` + +Data type: `String` + + + +##### `value` + +Data type: `Any` + + + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_numeric + +Type: Ruby 3.x API + +The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. +The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. +If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check +if (all elements of) the first argument are greater or equal to the given minimum. +It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric. + +For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too. + +#### `validate_numeric()` + +The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. +The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. +If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check +if (all elements of) the first argument are greater or equal to the given minimum. +It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric. + +For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too. + +Returns: `Any` Validate that the first argument is a numeric value (or an array of numeric values). Fail compilation if any of the checks fail. + +### validate_numeric + +Type: Ruby 4.x API + +Validate the passed value represents a numeric value. + +#### `validate_numeric(Any $scope, Any *$args)` + +The validate_numeric function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_re + +Type: Ruby 3.x API + +The first argument of this function should be a string to +test, and the second argument should be a stringified regular expression +(without the // delimiters) or an array of regular expressions. If none +of the regular expressions match the string passed in, compilation will +abort with a parse error. +If a third argument is specified, this will be the error message raised and +seen by the user. + +> *Note:* +Compilation will also abort, if the first argument is not a String. Always use +quotes to force stringification: +validate_re("${::operatingsystemmajrelease}", '^[57]$') + +#### Examples + +##### **Usage** + +```puppet +The following strings will validate against the regular expressions: + + validate_re('one', '^one$') + validate_re('one', [ '^one', '^two' ]) + +The following strings will fail to validate, causing compilation to abort: + + validate_re('one', [ '^two', '^three' ]) + +A helpful error message can be returned like this: + + validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') +``` + +#### `validate_re()` + +The first argument of this function should be a string to +test, and the second argument should be a stringified regular expression +(without the // delimiters) or an array of regular expressions. If none +of the regular expressions match the string passed in, compilation will +abort with a parse error. +If a third argument is specified, this will be the error message raised and +seen by the user. + +> *Note:* +Compilation will also abort, if the first argument is not a String. Always use +quotes to force stringification: +validate_re("${::operatingsystemmajrelease}", '^[57]$') + +Returns: `Any` validation of a string against one or more regular expressions. + +##### Examples + +###### **Usage** + +```puppet +The following strings will validate against the regular expressions: + + validate_re('one', '^one$') + validate_re('one', [ '^one', '^two' ]) + +The following strings will fail to validate, causing compilation to abort: + + validate_re('one', [ '^two', '^three' ]) + +A helpful error message can be returned like this: + + validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') +``` + +### validate_re + +Type: Ruby 4.x API + +Perform validation of a string against one or more regular +expressions. + +#### `validate_re(Any $scope, Any *$args)` + +The validate_re function. + +Returns: `Boolean` `true` or `false` returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method +The first argument of this function should be a string to +test, and the second argument should be a stringified regular expression +(without the // delimiters) or an array of regular expressions + +### validate_slength + +Type: Ruby 3.x API + +Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. +An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings, +and if arg 2 and arg 3 are not convertable to a number. + +#### Examples + +##### **Usage** + +```puppet +The following values will pass: + + validate_slength("discombobulate",17) + validate_slength(["discombobulate","moo"],17) + validate_slength(["discombobulate","moo"],17,3) + +The following valueis will not: + + validate_slength("discombobulate",1) + validate_slength(["discombobulate","thermometer"],5) + validate_slength(["discombobulate","moo"],17,10) +``` + +#### `validate_slength()` + +The validate_slength function. + +Returns: `Any` validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. Fail compilation if any of the checks fail. + +##### Examples + +###### **Usage** + +```puppet +The following values will pass: + + validate_slength("discombobulate",17) + validate_slength(["discombobulate","moo"],17) + validate_slength(["discombobulate","moo"],17,3) + +The following valueis will not: + + validate_slength("discombobulate",1) + validate_slength(["discombobulate","thermometer"],5) + validate_slength(["discombobulate","moo"],17,10) +``` + +### validate_slength + +Type: Ruby 4.x API + +Validate that a passed string has length less/equal with the passed value + +#### `validate_slength(Any $scope, Any *$args)` + +Validate that a passed string has length less/equal with the passed value + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_string + +Type: Ruby 4.x API + +Validate that all passed values are string data structures. + +#### `validate_string(Any $scope, Any *$args)` + +The validate_string function. + +Returns: `Boolean` `true` or `false` +A boolean value returned from the called function. + +##### `scope` + +Data type: `Any` + +The main value that will be passed to the method + +##### `*args` + +Data type: `Any` + +Any additional values that are to be passed to the method + +### validate_string + +Type: Ruby 3.x API + +> *Note:* +Validate_string(undef) will not fail in this version of the +functions API (incl. current and future parser). Instead, use: +``` + if $var == undef { + fail('...') + } +``` + +#### Examples + +##### **Usage** + +```puppet +The following values will pass: + + $my_string = "one two" + validate_string($my_string, 'three') + +The following values will fail, causing compilation to abort: + + validate_string(true) + validate_string([ 'some', 'array' ]) +``` + +#### `validate_string()` + +> *Note:* +Validate_string(undef) will not fail in this version of the +functions API (incl. current and future parser). Instead, use: +``` + if $var == undef { + fail('...') + } +``` + +Returns: `Any` Validate that all passed values are string data structures. Failed +compilation if any value fails this check. + +##### Examples + +###### **Usage** + +```puppet +The following values will pass: + + $my_string = "one two" + validate_string($my_string, 'three') + +The following values will fail, causing compilation to abort: + + validate_string(true) + validate_string([ 'some', 'array' ]) +``` + +### validate_x509_rsa_key_pair + +Type: Ruby 3.x API + +```validate_x509_rsa_key_pair($cert, $key)``` + +#### `validate_x509_rsa_key_pair()` + +```validate_x509_rsa_key_pair($cert, $key)``` + +Returns: `Any` Fail compilation if any value fails this check. + +### values + +Type: Ruby 3.x API + +> *Note:* +From Puppet 5.5.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +#### Examples + +##### **Usage** + +```puppet +$hash = { + 'a' => 1, + 'b' => 2, + 'c' => 3, +} +values($hash) + +This example would return: ```[1,2,3]``` +``` + +#### `values()` + +> *Note:* +From Puppet 5.5.0, the compatible function with the same name in Puppet core +will be used instead of this function. + +Returns: `Any` array of values + +##### Examples + +###### **Usage** + +```puppet +$hash = { + 'a' => 1, + 'b' => 2, + 'c' => 3, +} +values($hash) + +This example would return: ```[1,2,3]``` +``` + +### values_at + +Type: Ruby 3.x API + +The first argument is the array you want to analyze, and the second element can +be a combination of: + +* A single numeric index +* A range in the form of 'start-stop' (eg. 4-9) +* An array combining the above + +> *Note:* +Since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language. +A negative value is taken to be "from the end" of the array: + +`['a', 'b', 'c', 'd'][1, 2]` results in `['b', 'c']` +`['a', 'b', 'c', 'd'][2, -1]` results in `['c', 'd']` +`['a', 'b', 'c', 'd'][1, -2]` results in `['b', 'c']` + +#### Examples + +##### **Usage** + +```puppet + +values_at(['a','b','c'], 2) +Would return ['c'] + +values_at(['a','b','c'], ["0-1"]) +Would return ['a','b'] + +values_at(['a','b','c','d','e'], [0, "2-3"]) +Would return ['a','c','d'] +``` + +#### `values_at()` + +The first argument is the array you want to analyze, and the second element can +be a combination of: + +* A single numeric index +* A range in the form of 'start-stop' (eg. 4-9) +* An array combining the above + +> *Note:* +Since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language. +A negative value is taken to be "from the end" of the array: + +`['a', 'b', 'c', 'd'][1, 2]` results in `['b', 'c']` +`['a', 'b', 'c', 'd'][2, -1]` results in `['c', 'd']` +`['a', 'b', 'c', 'd'][1, -2]` results in `['b', 'c']` + +Returns: `Any` an array of values identified by location + +##### Examples + +###### **Usage** + +```puppet + +values_at(['a','b','c'], 2) +Would return ['c'] + +values_at(['a','b','c'], ["0-1"]) +Would return ['a','b'] + +values_at(['a','b','c','d','e'], [0, "2-3"]) +Would return ['a','c','d'] +``` + +### zip + +Type: Ruby 3.x API + +Takes one element from first array and merges corresponding elements from second array. + +#### Examples + +##### + +```puppet +zip(['1','2','3'],['4','5','6']) +Would result in: ["1", "4"], ["2", "5"], ["3", "6"] +``` + +#### `zip()` + +The zip function. + +Returns: `Any` This generates a sequence of n-element arrays, where n is one more than the count of arguments. + +##### Examples + +###### + +```puppet +zip(['1','2','3'],['4','5','6']) +Would result in: ["1", "4"], ["2", "5"], ["3", "6"] +``` + +## Data types + +### Stdlib::Absolutepath + +A strict absolutepath type + +Alias of `Variant[Stdlib::Windowspath, Stdlib::Unixpath]` + +### Stdlib::Base32 + +Type to match base32 String + +Alias of `Pattern[/^[a-z2-7]+={,6}$/, /^[A-Z2-7]+={,6}$/]` + +### Stdlib::Base64 + +Type to match base64 String + +Alias of `Pattern[/^[a-zA-Z0-9\/\+]+={,2}$/]` + +### Stdlib::Compat::Absolute_path + +Emulate the is_absolute_path and validate_absolute_path functions + +The first pattern is originally from is_absolute_path, which had it from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path? +slash = '[\\\\/]' +name = '[^\\\\/]+' +%r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i, + +Alias of `Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]]` + +### Stdlib::Compat::Array + +Emulate the is_array and validate_array functions + +Alias of `Array[Any]` + +### Stdlib::Compat::Bool + +Emulate the is_bool and validate_bool functions + +Alias of `Boolean` + +### Stdlib::Compat::Float + +Emulate the is_float function +The regex is what's currently used in is_float +To keep your development moving forward, you can also add a deprecation warning using the Integer type: + +```class example($value) { validate_float($value,) }``` + +would turn into + +``` +class example(Stdlib::Compat::Float $value) { + validate_float($value, 10, 0) + assert_type(Integer[0, 10], $value) |$expected, $actual| { + warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.") + } +} +``` + +This allows you to find all places where a consumers of your code call it with unexpected values. + +Alias of `Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]]` + +### Stdlib::Compat::Hash + +Emulate the is_hash and validate_hash functions + +Alias of `Hash[Any, Any]` + +### Stdlib::Compat::Integer + +Emulate the is_integer and validate_integer functions +The regex is what's currently used in is_integer +validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function. +For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything. +To keep your development moving forward, you can also add a deprecation warning using the Integer type: + +```class example($value) { validate_integer($value, 10, 0) }``` + +would turn into + +``` +class example(Stdlib::Compat::Integer $value) { + validate_numeric($value, 10, 0) + assert_type(Integer[0, 10], $value) |$expected, $actual| { + warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.") + } +} +``` + +> Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers. + +This allows you to find all places where a consumers of your code call it with unexpected values. + +Alias of `Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]]` + +### Stdlib::Compat::Ip_address + +The Stdlib::Compat::Ip_address data type. + +Alias of `Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]` + +### Stdlib::Compat::Ipv4 + +Emulate the validate_ipv4_address and is_ipv4_address functions + +Alias of `Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/]` + +### Stdlib::Compat::Ipv6 + +The Stdlib::Compat::Ipv6 data type. + +Alias of `Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/]` + +### Stdlib::Compat::Numeric + +Emulate the is_numeric and validate_numeric functions +The regex is what's currently used in is_numeric +validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function. +For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything. +To keep your development moving forward, you can also add a deprecation warning using the Integer type: + +```class example($value) { validate_numeric($value, 10, 0) }``` + +would turn into + +``` +class example(Stdlib::Compat::Numeric $value) { + validate_numeric($value, 10, 0) + assert_type(Integer[0, 10], $value) |$expected, $actual| { + warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.") + } +} +``` + +> Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers. + +This allows you to find all places where a consumers of your code call it with unexpected values. + +Alias of `Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]]` + +### Stdlib::Compat::String + +Emulate the is_string and validate_string functions + +Alias of `Optional[String]` + +### Stdlib::Ensure::Service + +The Stdlib::Ensure::Service data type. + +Alias of `Enum['stopped', 'running']` + +### Stdlib::Filemode + +See `man chmod.1` for the regular expression for symbolic mode + +Alias of `Pattern[/^(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))$/]` + +### Stdlib::Filesource + +Validate the source parameter on file types + +Alias of `Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[ + /^file:\/\/\/([^\/\0]+(\/)?)+$/, + /^puppet:\/\/(([\w-]+\.?)+)?\/([^\/\0]+(\/)?)+$/, + ]]` + +### Stdlib::Fqdn + +The Stdlib::Fqdn data type. + +Alias of `Pattern[/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/]` + +### Stdlib::HTTPSUrl + +The Stdlib::HTTPSUrl data type. + +Alias of `Pattern[/(?i:^https:\/\/)/]` + +### Stdlib::HTTPUrl + +The Stdlib::HTTPUrl data type. + +Alias of `Pattern[/(?i:^https?:\/\/)/]` + +### Stdlib::Host + +The Stdlib::Host data type. + +Alias of `Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]` + +### Stdlib::IP::Address + +The Stdlib::IP::Address data type. + +Alias of `Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6]` + +### Stdlib::IP::Address::Nosubnet + +The Stdlib::IP::Address::Nosubnet data type. + +Alias of `Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet]` + +### Stdlib::IP::Address::V4 + +The Stdlib::IP::Address::V4 data type. + +Alias of `Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet]` + +### Stdlib::IP::Address::V4::CIDR + +The Stdlib::IP::Address::V4::CIDR data type. + +Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/]` + +### Stdlib::IP::Address::V4::Nosubnet + +The Stdlib::IP::Address::V4::Nosubnet data type. + +Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]` + +### Stdlib::IP::Address::V6 + +The Stdlib::IP::Address::V6 data type. + +Alias of `Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet]` + +### Stdlib::IP::Address::V6::Alternative + +The Stdlib::IP::Address::V6::Alternative data type. + +Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` + +### Stdlib::IP::Address::V6::CIDR + +The Stdlib::IP::Address::V6::CIDR data type. + +Alias of `Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/]` + +### Stdlib::IP::Address::V6::Compressed + +The Stdlib::IP::Address::V6::Compressed data type. + +Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` + +### Stdlib::IP::Address::V6::Full + +The Stdlib::IP::Address::V6::Full data type. + +Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]` + +### Stdlib::IP::Address::V6::Nosubnet + +The Stdlib::IP::Address::V6::Nosubnet data type. + +Alias of `Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative]` + +### Stdlib::IP::Address::V6::Nosubnet::Alternative + +The Stdlib::IP::Address::V6::Nosubnet::Alternative data type. + +Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]` + +### Stdlib::IP::Address::V6::Nosubnet::Compressed + +The Stdlib::IP::Address::V6::Nosubnet::Compressed data type. + +Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, /\A([[:xdigit:]]{1,4}:){7}:\z/]` + +### Stdlib::IP::Address::V6::Nosubnet::Full + +The Stdlib::IP::Address::V6::Nosubnet::Full data type. + +Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/]` + +### Stdlib::MAC + +A type for a MAC address + +Alias of `Pattern[/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/, /^([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})$/]` + +### Stdlib::ObjectStore + +The Stdlib::ObjectStore data type. + +Alias of `Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri]` + +### Stdlib::ObjectStore::GSUri + +The Stdlib::ObjectStore::GSUri data type. + +Alias of `Pattern[/^gs:\/\//]` + +### Stdlib::ObjectStore::S3Uri + +The Stdlib::ObjectStore::S3Uri data type. + +Alias of `Pattern[/^s3:\/\//]` + +### Stdlib::Port + +The Stdlib::Port data type. + +Alias of `Integer[0, 65535]` + +### Stdlib::Port::Privileged + +The Stdlib::Port::Privileged data type. + +Alias of `Integer[1, 1023]` + +### Stdlib::Port::Unprivileged + +The Stdlib::Port::Unprivileged data type. + +Alias of `Integer[1024, 65535]` + +### Stdlib::Syslogfacility + +The Stdlib::Syslogfacility data type. + +Alias of `Enum['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7']` + +### Stdlib::Unixpath + +this regex rejects any path component that does not start with "/" or is NUL + +Alias of `Pattern[/^\/([^\/\0]+\/*)*$/]` + +### Stdlib::Windowspath + +The Stdlib::Windowspath data type. + +Alias of `Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/]` + +### Stdlib::Yes_no + +The Stdlib::Yes_no data type. + +Alias of `Pattern[/\A(?i:(yes|no))\z/]` + diff --git a/3rdparty/modules/stdlib/Rakefile b/3rdparty/modules/stdlib/Rakefile index 2d60dbbda..f11fbe9d5 100644 --- a/3rdparty/modules/stdlib/Rakefile +++ b/3rdparty/modules/stdlib/Rakefile @@ -1,3 +1,4 @@ +require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? @@ -15,7 +16,7 @@ end def changelog_project return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['name'] + returnVal = nil || JSON.load(File.read('metadata.json'))['source'].match(%r{.*/([^/]*)})[1] raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator project:#{returnVal}" returnVal @@ -23,7 +24,7 @@ end def changelog_future_release return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = JSON.load(File.read('metadata.json'))['version'] + returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator future_release:#{returnVal}" returnVal diff --git a/3rdparty/modules/stdlib/appveyor.yml b/3rdparty/modules/stdlib/appveyor.yml index e10ba3bf7..ef7b5481e 100644 --- a/3rdparty/modules/stdlib/appveyor.yml +++ b/3rdparty/modules/stdlib/appveyor.yml @@ -3,6 +3,7 @@ version: 1.1.x.{build} branches: only: - master + - release skip_commits: message: /^\(?doc\)?.*/ clone_depth: 10 @@ -33,6 +34,27 @@ environment: PUPPET_GEM_VERSION: ~> 6.0 RUBY_VERSION: 25-x64 CHECK: parallel_spec + - + RUBY_VERSION: 25-x64 + ACCEPTANCE: yes + TARGET_HOST: localhost + - + RUBY_VERSION: 25-x64 + ACCEPTANCE: yes + TARGET_HOST: localhost + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 +for: +- + matrix: + only: + - ACCEPTANCE: yes + install: + - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% + - bundle install --jobs 4 --retry 2 + - type Gemfile.lock + test_script: + - bundle exec rake spec_prep + - bundle exec rake litmus:acceptance:localhost matrix: fast_finish: true install: diff --git a/3rdparty/modules/stdlib/checksums.json b/3rdparty/modules/stdlib/checksums.json index ac4b535f3..c78098026 100644 --- a/3rdparty/modules/stdlib/checksums.json +++ b/3rdparty/modules/stdlib/checksums.json @@ -1,323 +1,223 @@ { - "CHANGELOG.md": "ef7ba4bf3e7b05133b8b6f360d184d3c", + "CHANGELOG.md": "f1fc30999d56efbd02fe5000cf2c3e27", "CONTRIBUTING.md": "4d17f3c942e7c93d1577cc4438a231e4", - "Gemfile": "3864447c01e8ca140685b2f085f2d262", + "Gemfile": "1a5466fcfc1a2f40765b4abc5ea9ad06", "HISTORY.md": "6b78ee53e5d501d081c45c5ee8f604e1", "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", "MAINTAINERS.md": "b40ec4f2c16145af6f723c2c34bb2ff9", "NOTICE": "b2e552587e5969886fdd60481e8b0351", - "README.md": "1b6e0b411dea04156265364ba854742e", + "README.md": "292f3898d725d5e153e3d06b63db7620", "README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165", "README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1", + "REFERENCE.md": "752ff41096c3e86e5ff8550895ad998d", "RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9", - "Rakefile": "5df4774149839a995ed5681f6545b6ff", - "appveyor.yml": "941f3c7018fe10bd2df05cbd0a9f0339", + "Rakefile": "5f547559ab75272c2f69c0cfff9d0dd0", + "appveyor.yml": "787231ca36ea3c98313389eb01bb0653", + "distelli-manifest.yml": "2b03c8cae145c90561cd4a0b43f9eea5", "examples/file_line.pp": "d8126b139dd1dce21ff26910d1c5a245", "examples/has_interface_with.pp": "d69d520cf3ff4d0b495480afaca359ef", "examples/has_ip_address.pp": "32f42575e49aa66f0f2398a70ae2a9f4", "examples/has_ip_network.pp": "bfb8db068c58d77c4dd7ae9697536537", "examples/init.pp": "b52fd907330ddbd9c3e070cf39f7b317", - "lib/facter/facter_dot_d.rb": "9f65108ecd7b8c5ce9c90ab4cd9d45be", - "lib/facter/package_provider.rb": "12d57e65f9b90c13e7808c347fbdc0b0", - "lib/facter/pe_version.rb": "245bb8ea121e8a55e1a38668cc480530", - "lib/facter/puppet_settings.rb": "d86bacf2b962a4744b701868cda31729", - "lib/facter/root_home.rb": "b384092f0470b9e2177edaf546de2ec1", + "lib/facter/facter_dot_d.rb": "82a1f2646f4ce640c6dcea2bfcbbecc8", + "lib/facter/package_provider.rb": "b17127f4c7f20443f6c85c4836745bac", + "lib/facter/pe_version.rb": "3450350a1510b2846aec7b927bbeab8d", + "lib/facter/puppet_settings.rb": "d939328efb70ec800443c8515e885f69", + "lib/facter/root_home.rb": "c2a013cb787ef788c539980d3e954048", "lib/facter/service_provider.rb": "66cc42526eae631e306b397391f1f01c", "lib/facter/util/puppet_settings.rb": "f69007bcc02031cd772fa7f2dffa3c0c", - "lib/puppet/functions/deprecation.rb": "705115a036e0235840db59cf9f4c17fe", - "lib/puppet/functions/fact.rb": "5879006198f1f4106acfe13422087d56", - "lib/puppet/functions/is_a.rb": "5a61d6a34ef45d7a5490455f334ef48a", - "lib/puppet/functions/is_absolute_path.rb": "0806756fc12b1fc752d1b54e81b15832", - "lib/puppet/functions/is_array.rb": "4d5c8d6af4e481ebb42f73b6504685c8", - "lib/puppet/functions/is_bool.rb": "9ae803c605c5ed057508c6501ef1a47f", - "lib/puppet/functions/is_float.rb": "ebe18dc0096233fcd555423761fc29f2", - "lib/puppet/functions/is_ip_address.rb": "ab9a1c6172db59cc15023f220853e2f2", - "lib/puppet/functions/is_ipv4_address.rb": "dec325b5911ce409b16c643697a13822", - "lib/puppet/functions/is_ipv6_address.rb": "f4864fee72c42bd3e40914768fb10f8e", - "lib/puppet/functions/is_numeric.rb": "970d785070eaa02bcac3e0589a8d5e7f", - "lib/puppet/functions/is_string.rb": "5aa459896fda1782f74752a1d324f048", - "lib/puppet/functions/length.rb": "3320c90f7685178c11937174fcf3119c", - "lib/puppet/functions/os_version_gte.rb": "120da86bc93fb4ccb1a45e13d5603560", - "lib/puppet/functions/seeded_rand_string.rb": "24e657c88e9b2a4a77a6cf1310758568", - "lib/puppet/functions/sprintf_hash.rb": "19bee19c55865e3240be3567741ba347", - "lib/puppet/functions/stdlib/extname.rb": "a8df502dce6d3020f5ff32322b68045d", - "lib/puppet/functions/to_json.rb": "bb6893a3e9eb6c48064c5a3c0bd4a41a", - "lib/puppet/functions/to_json_pretty.rb": "61ff20121b4c09987eadf3242b6231cf", - "lib/puppet/functions/to_yaml.rb": "0358dfd97b9a051e15046c6842b327be", - "lib/puppet/functions/type_of.rb": "4ee9c082047c08b8b1a82bc0bef8fd78", - "lib/puppet/functions/validate_absolute_path.rb": "556b0e3de450f03d724747d7d3825309", - "lib/puppet/functions/validate_array.rb": "efe329c6c8f65fce1ae2560fa5751530", - "lib/puppet/functions/validate_bool.rb": "5516a0f2efb48eeb4460fc713c6f9521", - "lib/puppet/functions/validate_hash.rb": "ce99bea6e1ee4da1a67b53b3ce06ce96", - "lib/puppet/functions/validate_integer.rb": "c028b299f194c221002ba442077e9209", - "lib/puppet/functions/validate_ip_address.rb": "278f3e0ea96b4b31e7b85c13887079b6", - "lib/puppet/functions/validate_ipv4_address.rb": "bd015492af1f3c4bef7ac780ae1c7e61", - "lib/puppet/functions/validate_ipv6_address.rb": "5144a327b6850ed5b7fb26fa37113353", - "lib/puppet/functions/validate_legacy.rb": "789bdef436873b6fcc8205c6d2270e43", - "lib/puppet/functions/validate_numeric.rb": "2bd2733f44749e0e56940ceaf5d8e2f8", - "lib/puppet/functions/validate_re.rb": "12c3412a7383b1d258dba5d4307e9464", - "lib/puppet/functions/validate_slength.rb": "1fc441736085bd0b5c7862f5dc9f839a", - "lib/puppet/functions/validate_string.rb": "c0fe867d3b5f8fbcaa3641f0f393a669", - "lib/puppet/parser/functions/abs.rb": "f36ef597641f56b400bf5425f329b52c", - "lib/puppet/parser/functions/any2array.rb": "bb45c181f51b6cb124de9ab44ff74ae5", - "lib/puppet/parser/functions/any2bool.rb": "12535df795966eadcf27e05413c691cc", - "lib/puppet/parser/functions/assert_private.rb": "c61884d43ebdb5ee5a5aa1507165084a", - "lib/puppet/parser/functions/base64.rb": "5c044321bc37fecd54e06a0ec5a067ba", - "lib/puppet/parser/functions/basename.rb": "6b0dc955024352c8007d175f900dba36", - "lib/puppet/parser/functions/bool2num.rb": "0d0a75d743e099eafada405f57ead3ea", - "lib/puppet/parser/functions/bool2str.rb": "ab45ec6cbcd35194d478c2da0527ab74", - "lib/puppet/parser/functions/camelcase.rb": "b46cd7766f7f500142fedaae6e81eb47", - "lib/puppet/parser/functions/capitalize.rb": "45d3ba2d02056b5dd0bc7f69ab046817", - "lib/puppet/parser/functions/ceiling.rb": "7cc2fba2933190774468035d24778f51", - "lib/puppet/parser/functions/chomp.rb": "393c7ea2399b531b1528cbbac6948f3c", - "lib/puppet/parser/functions/chop.rb": "b8d88826795cf13f803f264ce42e1cdf", - "lib/puppet/parser/functions/clamp.rb": "5c2c8f3f048ed1afd0c34c0eb475b076", - "lib/puppet/parser/functions/concat.rb": "107cf03fb8343dbf20f69bd4a07a7bb1", - "lib/puppet/parser/functions/convert_base.rb": "a34a1172f158c4780f6387df082aade0", - "lib/puppet/parser/functions/count.rb": "b3bcfa1fc10df6f2635c10804cfb567c", - "lib/puppet/parser/functions/deep_merge.rb": "fae771cff4fc1d6c639bea1672e05c9c", - "lib/puppet/parser/functions/defined_with_params.rb": "bd2564fe13dd46e4afac1e7f7db45eee", - "lib/puppet/parser/functions/delete.rb": "875f64cf060e00bb6f187875a4bc5e88", - "lib/puppet/parser/functions/delete_at.rb": "d909ad4779276559cb05b09193b047e0", - "lib/puppet/parser/functions/delete_regex.rb": "509b6526b9dea21321c6d7a0f2de591a", - "lib/puppet/parser/functions/delete_undef_values.rb": "01e6547fcd9ff93bb5294be3c0761a49", - "lib/puppet/parser/functions/delete_values.rb": "7cc9f122bc7ddfb6359146cd68e5f27a", - "lib/puppet/parser/functions/deprecation.rb": "9f935fec2f9f0d01394292eb6f21bd7d", - "lib/puppet/parser/functions/difference.rb": "419c1179460a2878d99b577dfb41977d", - "lib/puppet/parser/functions/dig.rb": "d315de1659a037430fea9623bff323a6", - "lib/puppet/parser/functions/dig44.rb": "433ae008eed28fa3f99dbdd64926bfd8", - "lib/puppet/parser/functions/dirname.rb": "eaafc8268d35709f8d460a48e918ee4c", - "lib/puppet/parser/functions/dos2unix.rb": "ab2f9f280c616be55f58903948e226a2", - "lib/puppet/parser/functions/downcase.rb": "384d5ad77ac70bd199fcd63fa31ede38", - "lib/puppet/parser/functions/empty.rb": "455ab7360e7d15f78ff8f359e6da432a", - "lib/puppet/parser/functions/enclose_ipv6.rb": "89c728eb11f71ed9390664bad9732328", - "lib/puppet/parser/functions/ensure_packages.rb": "8f72ca68f1d93fc7042552fef8fdb2b2", - "lib/puppet/parser/functions/ensure_resource.rb": "2915c77baa0d45531912613dd1cac902", - "lib/puppet/parser/functions/ensure_resources.rb": "805d56e894c9dcca2595464fa87a7c56", - "lib/puppet/parser/functions/flatten.rb": "8558874ff069ba6cbaecac47c4836ca9", - "lib/puppet/parser/functions/floor.rb": "1fdd8c7a0d1350c4e67578209cbfd937", - "lib/puppet/parser/functions/fqdn_rand_string.rb": "731365381b6a28a196e108329e16c6c2", - "lib/puppet/parser/functions/fqdn_rotate.rb": "3925369078084f98f9b527d25cc9e4d2", - "lib/puppet/parser/functions/fqdn_uuid.rb": "adbd60dbcc561c8586567a6e58abec82", - "lib/puppet/parser/functions/get_module_path.rb": "91b47019658cb4f438a8f96c6e12213b", - "lib/puppet/parser/functions/getparam.rb": "b8f4a75c6e0d9732c5f937bd35b00923", - "lib/puppet/parser/functions/getvar.rb": "60ee5451005017bd3234113354f68765", - "lib/puppet/parser/functions/glob.rb": "f8177554be6da357b0822edaa7eb8d14", - "lib/puppet/parser/functions/grep.rb": "f8a965a28326f7cde962a13d8273d617", - "lib/puppet/parser/functions/has_interface_with.rb": "422015811c5b7c0656b83eaea3b8fdcc", - "lib/puppet/parser/functions/has_ip_address.rb": "fc76c9a87145560f58a4ae9a6d9df444", - "lib/puppet/parser/functions/has_ip_network.rb": "b1bb1868e6fef95f8ae840d420ab0816", - "lib/puppet/parser/functions/has_key.rb": "2831eb02496ac82c790e49d4538bd983", - "lib/puppet/parser/functions/hash.rb": "a986ba1253550e868d61e777dbda0890", - "lib/puppet/parser/functions/intersection.rb": "6436444eb8585ee71cfd5bd1e0802026", - "lib/puppet/parser/functions/is_absolute_path.rb": "268600b66670a29690be009d45013d42", - "lib/puppet/parser/functions/is_array.rb": "0e425e55c8ce9cc5e327d53d114391ba", - "lib/puppet/parser/functions/is_bool.rb": "4e021a5143c2c98b31344acceda5fbe2", - "lib/puppet/parser/functions/is_domain_name.rb": "1abf04d1d57de6f7f630045c0efe5e4c", - "lib/puppet/parser/functions/is_email_address.rb": "d11c644fa1bd73f8e1d36c4f9e67272e", - "lib/puppet/parser/functions/is_float.rb": "b95a00f15242e3f26a5cf129db7d31e5", - "lib/puppet/parser/functions/is_function_available.rb": "3bb60da5789493da017f84d48ac46f08", - "lib/puppet/parser/functions/is_hash.rb": "3f74a7e9b6e47b834c4ad58939c27eab", - "lib/puppet/parser/functions/is_integer.rb": "e3480725fccac1c7eba28162dc62393d", - "lib/puppet/parser/functions/is_ip_address.rb": "3616dacf58febcd4944945d3c2647efe", - "lib/puppet/parser/functions/is_ipv4_address.rb": "7930d25d23d92f0e5cb81f93315cea16", - "lib/puppet/parser/functions/is_ipv6_address.rb": "c206564af3a738e504afca2284497d3c", - "lib/puppet/parser/functions/is_mac_address.rb": "ce813427e763d0405931dc216e51bca2", - "lib/puppet/parser/functions/is_numeric.rb": "4bd1a47192ce4040810819789fbf3147", - "lib/puppet/parser/functions/is_string.rb": "cf06fecd6147bea77d406a189b649f81", - "lib/puppet/parser/functions/join.rb": "338cfe4797a5b41d34d0dcdceb4cff2f", - "lib/puppet/parser/functions/join_keys_to_values.rb": "86e4211f195c4c9d92c5e3806789a561", - "lib/puppet/parser/functions/keys.rb": "1702d1c00a24ca4e9ba6a4f36c4ec808", - "lib/puppet/parser/functions/load_module_metadata.rb": "4972bafc84e5b7ce4a00cbee21aece18", - "lib/puppet/parser/functions/loadjson.rb": "442e1250912a44965637782998776ef6", - "lib/puppet/parser/functions/loadyaml.rb": "8ad8f48f3649b39bdeca825a61d68e9e", - "lib/puppet/parser/functions/lstrip.rb": "078230c59baa5ebb433d1ddc2ebd808b", - "lib/puppet/parser/functions/max.rb": "c9acf0c8bd3902ec613844fac4eb0201", - "lib/puppet/parser/functions/member.rb": "ddd3572cb73353e4cfd95bcea423030b", - "lib/puppet/parser/functions/merge.rb": "fecd4133ce85334adf93332fdc9f65f1", - "lib/puppet/parser/functions/min.rb": "9016deb88938647bd52faf8cdea6f83c", - "lib/puppet/parser/functions/num2bool.rb": "60e725ab19cffcd745a0b904a7a59d6b", - "lib/puppet/parser/functions/parsejson.rb": "fee0dc33cd6e18b0d9a5fe8befb66cd2", - "lib/puppet/parser/functions/parseyaml.rb": "f4b67d011970c1799bc6fb36a3caf1f2", - "lib/puppet/parser/functions/pick.rb": "502384aedc46dd5987fe31c494f48e61", - "lib/puppet/parser/functions/pick_default.rb": "acf85e30452afb8a1811a4ca8557f188", - "lib/puppet/parser/functions/prefix.rb": "6912509e79ebdff5f9b4e7d630442157", - "lib/puppet/parser/functions/private.rb": "a1f44a1c32da00aa14f474f4f303be87", - "lib/puppet/parser/functions/pry.rb": "970544bf6308b7b6902b936063a45109", - "lib/puppet/parser/functions/pw_hash.rb": "07fea662493e5b2ffcf37dbb4c4e74b9", - "lib/puppet/parser/functions/range.rb": "38f7ebcf5a66954f9127756d32291534", - "lib/puppet/parser/functions/regexpescape.rb": "d7d22f987d616f2b5ec9d967f1528f53", - "lib/puppet/parser/functions/reject.rb": "9847dac360af182c4880dece7b4bc034", - "lib/puppet/parser/functions/reverse.rb": "2d1045255bbe50fc6d4cd97ad4a6eec3", - "lib/puppet/parser/functions/round.rb": "aaf276b15f731cf44da7a69621cd3b96", - "lib/puppet/parser/functions/rstrip.rb": "1be3bf1eff074c784e980cda2c146683", - "lib/puppet/parser/functions/seeded_rand.rb": "4f45ef0723411ff8281aaf093f0fabc2", - "lib/puppet/parser/functions/shell_escape.rb": "6e51793b8483eb6bfc4be98b438fd47e", - "lib/puppet/parser/functions/shell_join.rb": "4fbe23ff73932f65db696f106517887e", - "lib/puppet/parser/functions/shell_split.rb": "cb851119ee167ccb12930c53e94333cc", - "lib/puppet/parser/functions/shuffle.rb": "6b16497151e961fbdb6e00ec70d6bbe9", - "lib/puppet/parser/functions/size.rb": "e3a0aa89c776b592ed24c1dd27773e33", - "lib/puppet/parser/functions/sort.rb": "ea24d1e27954b6ee69d30f3fce391b65", - "lib/puppet/parser/functions/squeeze.rb": "e42e1d5ec9a23443d14ff07512fd695f", - "lib/puppet/parser/functions/str2bool.rb": "9fac94e3e949b2a4406ac2d22510b06e", - "lib/puppet/parser/functions/str2saltedsha512.rb": "d4443e8985b4ce6f6e925c6f46d8456c", - "lib/puppet/parser/functions/strftime.rb": "d17fc58b649eb6b7315752b853cd7f3b", - "lib/puppet/parser/functions/strip.rb": "011469a450ae484f199c09f55f3ab809", - "lib/puppet/parser/functions/suffix.rb": "1893244c6bb354a6b1093f65041c643c", - "lib/puppet/parser/functions/swapcase.rb": "d1a53787b35ae9a5a643c49f4e0975a8", - "lib/puppet/parser/functions/time.rb": "4a0ec2a06a1361dbf3cd11a07aa57a71", - "lib/puppet/parser/functions/to_bytes.rb": "55a65ad70ea78983e7c1d6d565094c1f", - "lib/puppet/parser/functions/try_get_value.rb": "b039b960b07a21b935baf6c78fb94612", - "lib/puppet/parser/functions/type.rb": "3115a269dc87e6cdb586d6cf4c2b0529", - "lib/puppet/parser/functions/type3x.rb": "7a72502f0291c66b0e4ce76e33e481c7", - "lib/puppet/parser/functions/union.rb": "690e5c15a1e7b95ab4b90ee18eb48f81", - "lib/puppet/parser/functions/unique.rb": "e448da2c183c0e19bd6e64bc423a749f", - "lib/puppet/parser/functions/unix2dos.rb": "0aa6e66d1c47ca0bb417e248b01f6f1b", - "lib/puppet/parser/functions/upcase.rb": "55ef15d383673d44a1848833a46cfd11", - "lib/puppet/parser/functions/uriescape.rb": "f2facfe201658a65a7e81199cdd1bef7", - "lib/puppet/parser/functions/validate_absolute_path.rb": "892faf0e74b99b11190ec7fc4b78a893", - "lib/puppet/parser/functions/validate_array.rb": "9518be91bab77e56be711d1498d119b9", - "lib/puppet/parser/functions/validate_augeas.rb": "c5bbf1bc42b7ea024e48ab12b46f55e9", - "lib/puppet/parser/functions/validate_bool.rb": "bea67f1a0f5fc23ee8b632000cfa63db", - "lib/puppet/parser/functions/validate_cmd.rb": "dbb22e68eca3f6be63fb49b465b1d611", - "lib/puppet/parser/functions/validate_domain_name.rb": "04f4b1d0be9a8a12d278f0b044f78427", - "lib/puppet/parser/functions/validate_email_address.rb": "6dc01f14c43fdff19106a2388d01b51a", - "lib/puppet/parser/functions/validate_hash.rb": "80f7cfb430818e1497d3b12769d8f9c4", - "lib/puppet/parser/functions/validate_integer.rb": "edb176a717c4af6cd50d2d26e4da149d", - "lib/puppet/parser/functions/validate_ip_address.rb": "55d0f019803d687bf95bcc64e8751ba5", - "lib/puppet/parser/functions/validate_ipv4_address.rb": "94843b876cc92414b29223f7ac3cc3b6", - "lib/puppet/parser/functions/validate_ipv6_address.rb": "6c10396f466f64a6f897d1be4291dd4a", - "lib/puppet/parser/functions/validate_numeric.rb": "092cce5ed9d3a73319c48cdf9a2a822e", - "lib/puppet/parser/functions/validate_re.rb": "df6a2cc342dad63d008ef257fde9038a", - "lib/puppet/parser/functions/validate_slength.rb": "b20959e080f36bf320eacb472d125741", - "lib/puppet/parser/functions/validate_string.rb": "0239e1697134605a6385ff8c9bdc066b", - "lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "b16e5ebaeb497e1639c7bf78d61c2b45", - "lib/puppet/parser/functions/values.rb": "793ec0d600822461829eda4abcd89f9c", - "lib/puppet/parser/functions/values_at.rb": "d03bb02de4bf80ecd1846a4e6dc99ce8", - "lib/puppet/parser/functions/zip.rb": "aef1ee868716d07b01e605ae6c4741cc", - "lib/puppet/provider/file_line/ruby.rb": "06dd4b2bd0037fcdc8382fcd4214dda3", - "lib/puppet/type/anchor.rb": "95867e600863019b08990277c4254cac", - "lib/puppet/type/file_line.rb": "208655541a332e54e2d9abac0e328d33", + "lib/puppet/functions/deprecation.rb": "9f7706a22f47383421bc10e712ff9d0a", + "lib/puppet/functions/fact.rb": "a457dbc9ec08144b0886a964e74ba8a1", + "lib/puppet/functions/is_a.rb": "60372a583cc765976e7a49504de0684f", + "lib/puppet/functions/is_absolute_path.rb": "4d6a337eeb633639a58fb396b4d7176f", + "lib/puppet/functions/is_array.rb": "21d22504bf41733e1784e9a6c3dc59a5", + "lib/puppet/functions/is_bool.rb": "baadfbdb76d9b7c3cb5f8159a53c5bf3", + "lib/puppet/functions/is_float.rb": "b4327ddf6f33462b76f706ace51cea00", + "lib/puppet/functions/is_ip_address.rb": "fee3d0323de6f9966ed92cab5eabdfb3", + "lib/puppet/functions/is_ipv4_address.rb": "5d262c46367303d24195fa54d1226a0c", + "lib/puppet/functions/is_ipv6_address.rb": "ac870a59c005cd54d3cd1028a650073c", + "lib/puppet/functions/is_numeric.rb": "82ba88985c27ff7e5074baf2d3de0c19", + "lib/puppet/functions/is_string.rb": "d04e1e1312e2d5fe9cf91d9478aaa47a", + "lib/puppet/functions/length.rb": "d3a3bed61149d19e86c29c38fbf89a36", + "lib/puppet/functions/merge.rb": "ebae086c10f411f4c5cc52ae0a084eb8", + "lib/puppet/functions/os_version_gte.rb": "7c32f86861a7bc6b6a04c12d072644e2", + "lib/puppet/functions/seeded_rand_string.rb": "58f5005c4d667c27a06451339dad8bac", + "lib/puppet/functions/sprintf_hash.rb": "39a468b9c0f0bfbd319f19da28bdc9eb", + "lib/puppet/functions/stdlib/extname.rb": "ddafe4ddf35f3be7bc2aebc5fd975c39", + "lib/puppet/functions/stdlib/ip_in_range.rb": "62820a0b4bdc207b0000a11ca339a2d3", + "lib/puppet/functions/to_json.rb": "9be02065dd8fc8b4c14cc7daa52119c5", + "lib/puppet/functions/to_json_pretty.rb": "239234548ae13dc0bb23c82f104bfd22", + "lib/puppet/functions/to_yaml.rb": "8ce138d4f3ba93ee480311d5b753259e", + "lib/puppet/functions/type_of.rb": "6e7c6e50f6fe92c32f578a644dd66b66", + "lib/puppet/functions/validate_absolute_path.rb": "5872ffdc5b0462eb5826ef10e614dc9d", + "lib/puppet/functions/validate_array.rb": "b219e008bc5441a7179faa01da0e98dd", + "lib/puppet/functions/validate_bool.rb": "9468b5124a3956d8c8120c90a5bcd57a", + "lib/puppet/functions/validate_hash.rb": "cda57f161742d37b8a0248865dab7ee0", + "lib/puppet/functions/validate_integer.rb": "fd0c34b11d4327cfefc53c2294f222e7", + "lib/puppet/functions/validate_ip_address.rb": "f54d16dc96f7851c60e5964a64da2398", + "lib/puppet/functions/validate_ipv4_address.rb": "c205d7b710eb0c234f9661d8cc703039", + "lib/puppet/functions/validate_ipv6_address.rb": "6fb3fb641c996132ae0ac352ff2e9f23", + "lib/puppet/functions/validate_legacy.rb": "7f4abc0b7fe49cf41847f2ee9d7562ed", + "lib/puppet/functions/validate_numeric.rb": "9cae03d48f6ca997fe3b4f482985f095", + "lib/puppet/functions/validate_re.rb": "55b302d7e594eb7557a0c6903cb4a3ac", + "lib/puppet/functions/validate_slength.rb": "eb14887b0e4c7659681d045334283de8", + "lib/puppet/functions/validate_string.rb": "0910a5c7de84edacafe8d00d1e86c2a1", + "lib/puppet/parser/functions/abs.rb": "1caab301efc51e6ac877eb310ea642e9", + "lib/puppet/parser/functions/any2array.rb": "f3bdf3cdd61c1a87c5c9892806cf9082", + "lib/puppet/parser/functions/any2bool.rb": "246bdf9237a49cd5fca8a46d0e5c3419", + "lib/puppet/parser/functions/assert_private.rb": "5a847d20e2945f431d011ed77942be33", + "lib/puppet/parser/functions/base64.rb": "75d1b726a0da0ab666375aaba1dfa05e", + "lib/puppet/parser/functions/basename.rb": "193dee93291bbac4055f12004c69e898", + "lib/puppet/parser/functions/bool2num.rb": "58e4e3d6902d77906edf512e4c9fd5ca", + "lib/puppet/parser/functions/bool2str.rb": "c3282f7e658e951c3b562250f06070d6", + "lib/puppet/parser/functions/camelcase.rb": "16a2e5a7c4980444ae412a832f6f799e", + "lib/puppet/parser/functions/capitalize.rb": "1d6dccd218cf7816e99453ac9eb5495b", + "lib/puppet/parser/functions/ceiling.rb": "0b1f1cc86e247a6264e2a694bc7460c5", + "lib/puppet/parser/functions/chomp.rb": "6b556817deaf53cafbfbe1126b5a7db2", + "lib/puppet/parser/functions/chop.rb": "6add3bc3fbfd419f96a5d0d627811dd9", + "lib/puppet/parser/functions/clamp.rb": "e2b41cb6c03b3f10c4573af79b020baa", + "lib/puppet/parser/functions/concat.rb": "c8552953e0677992f8930cbd26aa8c47", + "lib/puppet/parser/functions/convert_base.rb": "d65d544dec14d9819f013d01b654455a", + "lib/puppet/parser/functions/count.rb": "cace9e26cf58c571842ff7146bc0579e", + "lib/puppet/parser/functions/deep_merge.rb": "2796acbb37e779eb595ecf165788ab35", + "lib/puppet/parser/functions/defined_with_params.rb": "7f9a270365f9a047355a01492994e0ab", + "lib/puppet/parser/functions/delete.rb": "1885535df5a4c06e39c16b98220b746d", + "lib/puppet/parser/functions/delete_at.rb": "af1d44d9654694a7f6877b7e5b9ed639", + "lib/puppet/parser/functions/delete_regex.rb": "ad1e1ac49ad0589c20b433bd22da973d", + "lib/puppet/parser/functions/delete_undef_values.rb": "bc1221ac34bfabc4ff8e808bdd854ebf", + "lib/puppet/parser/functions/delete_values.rb": "eadb784d5c678961f324679a615347d6", + "lib/puppet/parser/functions/deprecation.rb": "cb5fdb8e71a888437ca2956d833edcf2", + "lib/puppet/parser/functions/difference.rb": "ce4921704459ab9d412e9c6a76f08470", + "lib/puppet/parser/functions/dig.rb": "babc1c588e32d7561b29e57460ceec31", + "lib/puppet/parser/functions/dig44.rb": "ad97e68abc70939375e7d8c156114994", + "lib/puppet/parser/functions/dirname.rb": "825b61480896626794a632f465858ed0", + "lib/puppet/parser/functions/dos2unix.rb": "6baffd01b4076fb3093d6a1659947625", + "lib/puppet/parser/functions/downcase.rb": "15115685c59ad44ec0dd4d8c404c13c1", + "lib/puppet/parser/functions/empty.rb": "39c8cae896b5200049898257b5580b7b", + "lib/puppet/parser/functions/enclose_ipv6.rb": "bc9e304cda8623148cf2b43eed50ee4e", + "lib/puppet/parser/functions/ensure_packages.rb": "b8d8398536030e18b9a611adbbc4ead0", + "lib/puppet/parser/functions/ensure_resource.rb": "ebc7ff4e6819f9a5571321ce94296622", + "lib/puppet/parser/functions/ensure_resources.rb": "fbff17623dbfe7abe699e5e101a58666", + "lib/puppet/parser/functions/flatten.rb": "8eb8ee688df30854ee6102f7916b95d4", + "lib/puppet/parser/functions/floor.rb": "9a3726fb87f6f3e1d93bc1a1d6378dbd", + "lib/puppet/parser/functions/fqdn_rand_string.rb": "f891ff98c960078f9ae0fad60e3f3448", + "lib/puppet/parser/functions/fqdn_rotate.rb": "3411883e14b61afcfcf98f21c917b1be", + "lib/puppet/parser/functions/fqdn_uuid.rb": "de08b8739e876a935aba2cd4948d2167", + "lib/puppet/parser/functions/get_module_path.rb": "7bce665daf99e68bd06bbec57b707f29", + "lib/puppet/parser/functions/getparam.rb": "0ee6179adda0795ec38bc1e90eaa6591", + "lib/puppet/parser/functions/getvar.rb": "7e943851d8be874b49e49e4b792e843f", + "lib/puppet/parser/functions/glob.rb": "506e79fd7ade56c13195c4cb11cad73e", + "lib/puppet/parser/functions/grep.rb": "018e6930aed61e72c29a847295bf0740", + "lib/puppet/parser/functions/has_interface_with.rb": "fa1bea02dabd790f1e33119b359cf7db", + "lib/puppet/parser/functions/has_ip_address.rb": "35ee815f26129bcaf820fc6108f96bb6", + "lib/puppet/parser/functions/has_ip_network.rb": "dd1dded44a27ee8052827c901c4d20bd", + "lib/puppet/parser/functions/has_key.rb": "44e5a56409ddee7c26f04cd50185aa17", + "lib/puppet/parser/functions/hash.rb": "d1d45cbb4a4fe27b4182a2c230026f94", + "lib/puppet/parser/functions/intersection.rb": "469b60a6a15b0380664039b8304c38cc", + "lib/puppet/parser/functions/is_absolute_path.rb": "d1d6c130ba7231d5c4987ae30e45f4e2", + "lib/puppet/parser/functions/is_array.rb": "4e4ca6ccfc2fd352351583f01989d10d", + "lib/puppet/parser/functions/is_bool.rb": "f1e09e73d4fca5ce0ffd0781de541b07", + "lib/puppet/parser/functions/is_domain_name.rb": "b51986bab6685bfc8bd3117bd4be9322", + "lib/puppet/parser/functions/is_email_address.rb": "f3a126e7d3cb10a4b25bb3db631fe442", + "lib/puppet/parser/functions/is_float.rb": "eff28cde457b69e50947fa1e462b6e11", + "lib/puppet/parser/functions/is_function_available.rb": "20b970c665432431c0b1879027572dd0", + "lib/puppet/parser/functions/is_hash.rb": "afdce2b8afbf9f43267a351f8dd47425", + "lib/puppet/parser/functions/is_integer.rb": "3a6b477144f55d46950dc06b049d98a1", + "lib/puppet/parser/functions/is_ip_address.rb": "3ef677e90e7345cd12e886fde0561727", + "lib/puppet/parser/functions/is_ipv4_address.rb": "3a125625891bde53b7a7e80981b69965", + "lib/puppet/parser/functions/is_ipv6_address.rb": "f4bab5d4223aa5af9606b3843db0b99a", + "lib/puppet/parser/functions/is_mac_address.rb": "25a695daa304d101ce42535341f85534", + "lib/puppet/parser/functions/is_numeric.rb": "400934c5f70239322f8ed3e77bd83c92", + "lib/puppet/parser/functions/is_string.rb": "46f41a621ad827f24fdb0a4f95b1eb7b", + "lib/puppet/parser/functions/join.rb": "94eb446f1c08c84245b3dc4d2c9f2575", + "lib/puppet/parser/functions/join_keys_to_values.rb": "7aa31c88062bff5de5763bca3b66c369", + "lib/puppet/parser/functions/keys.rb": "22dc39591357405e98751147c3f59c05", + "lib/puppet/parser/functions/load_module_metadata.rb": "715a14fde1d65b3894dfdcff460e5d3b", + "lib/puppet/parser/functions/loadjson.rb": "e0b63ae98a9bd95bfe648607ab5e391f", + "lib/puppet/parser/functions/loadyaml.rb": "4e4370d56487bdc8c0fd7ebc94532b1b", + "lib/puppet/parser/functions/lstrip.rb": "1a536f290d87c2287f9cd4a6647b90ad", + "lib/puppet/parser/functions/max.rb": "80f3fadc7a4ef00c2cea938f5552687e", + "lib/puppet/parser/functions/member.rb": "7b1dcef3f895d76a2250f4f998936b51", + "lib/puppet/parser/functions/merge.rb": "00d4573f8ccfb1b54cff984df3281770", + "lib/puppet/parser/functions/min.rb": "828e10db1bf46d880eba94c09367fc23", + "lib/puppet/parser/functions/num2bool.rb": "03101587ea7761f5d2043bef8a0e4813", + "lib/puppet/parser/functions/parsejson.rb": "84edfcfbdfa9be8df246cd6263bf27a4", + "lib/puppet/parser/functions/parseyaml.rb": "a63c7b27e3bdaf363e288be9a4689b9f", + "lib/puppet/parser/functions/pick.rb": "f4e94df732ed5d209c9fc8db5ac35207", + "lib/puppet/parser/functions/pick_default.rb": "17f442caa18d25075de2cd7abd65a791", + "lib/puppet/parser/functions/prefix.rb": "bcf32e7f5867dcb40ec0cdca8002329f", + "lib/puppet/parser/functions/private.rb": "681d49c29c4b8df691a41e90df7e6500", + "lib/puppet/parser/functions/pry.rb": "5bac48462794f5d18d3ad30f1141aeb1", + "lib/puppet/parser/functions/pw_hash.rb": "f9c7c8896ba99b9262196e6ea67fa07c", + "lib/puppet/parser/functions/range.rb": "3c445b69b908d96a388a1572cc359470", + "lib/puppet/parser/functions/regexpescape.rb": "27fe5962756477de3fb71a646135e96c", + "lib/puppet/parser/functions/reject.rb": "4cceb698ed1d0a2f0fbe8e91c4f68a21", + "lib/puppet/parser/functions/reverse.rb": "0b3fe898d9418db6b3affbade6c035c3", + "lib/puppet/parser/functions/round.rb": "e4d15bdb144ece4710608fd5356ab106", + "lib/puppet/parser/functions/rstrip.rb": "65ae5dd164e117a6d79595b47952ae05", + "lib/puppet/parser/functions/seeded_rand.rb": "8a2f323648633466001af665b6f6c624", + "lib/puppet/parser/functions/shell_escape.rb": "5ed2fe520fcebb2ef46ecd6f8cf1d414", + "lib/puppet/parser/functions/shell_join.rb": "d048ff0d100edeb148cb7d5ef13f9c82", + "lib/puppet/parser/functions/shell_split.rb": "5985ff9873995ed9d496935f81daee8a", + "lib/puppet/parser/functions/shuffle.rb": "9873cf32c81535410732125b21b2876c", + "lib/puppet/parser/functions/size.rb": "fa2e1774d0373ed0e61aa7966b5f4737", + "lib/puppet/parser/functions/sort.rb": "11cb9d7293aafd907fe55b319fc64a9b", + "lib/puppet/parser/functions/squeeze.rb": "8dd784412fbe111b13ce92744cdc1a29", + "lib/puppet/parser/functions/str2bool.rb": "70775b38472584f0522ae032bd54502d", + "lib/puppet/parser/functions/str2saltedsha512.rb": "37a123c3fca9cd8b3f472dc18227673f", + "lib/puppet/parser/functions/strftime.rb": "b526a0156b6f346ce64150a7263f1734", + "lib/puppet/parser/functions/strip.rb": "5fd70908ed62c6f6fb58098dbae3993e", + "lib/puppet/parser/functions/suffix.rb": "e986d3c52043586ed419b4689d27e745", + "lib/puppet/parser/functions/swapcase.rb": "e93d7a8e5eaa8e420234941a61199181", + "lib/puppet/parser/functions/time.rb": "911832e13dd13c3531ffbe1312aa22a0", + "lib/puppet/parser/functions/to_bytes.rb": "9b4040cc7173e6747739a9a2490ba6a0", + "lib/puppet/parser/functions/try_get_value.rb": "b1877fbff0a04c7beb15ddec3eae7b9e", + "lib/puppet/parser/functions/type.rb": "a544624a9f720d7774b1f672dd4064a0", + "lib/puppet/parser/functions/type3x.rb": "c8642e93f813bcfdb80476816b0bc596", + "lib/puppet/parser/functions/union.rb": "72eeb4e9ca3edc0d6f44d70fe5385e34", + "lib/puppet/parser/functions/unique.rb": "04aad75f752f2c85442613da72ae7265", + "lib/puppet/parser/functions/unix2dos.rb": "ba608b4b35b8e1bc99bfc8ada0b329f6", + "lib/puppet/parser/functions/upcase.rb": "5fff4d1a0a3ca212387749786d5c19e9", + "lib/puppet/parser/functions/uriescape.rb": "ee7242decf04d2d44a91d196f79e8488", + "lib/puppet/parser/functions/validate_absolute_path.rb": "3d0d00999ebfd0c6bec4ac04a1b9b285", + "lib/puppet/parser/functions/validate_array.rb": "9abed7f85fd4724fab21ff1073de8b41", + "lib/puppet/parser/functions/validate_augeas.rb": "4a9795e7945193afe0fc3a614a2f6022", + "lib/puppet/parser/functions/validate_bool.rb": "f04a095d2c645329a748ddb3fd60798f", + "lib/puppet/parser/functions/validate_cmd.rb": "19537747b1df38084b968fbb4f6f0f17", + "lib/puppet/parser/functions/validate_domain_name.rb": "0f0be32a421c34e8df570f817f307617", + "lib/puppet/parser/functions/validate_email_address.rb": "a7af8b3f2bd4148a104e9dc1390d2faa", + "lib/puppet/parser/functions/validate_hash.rb": "e72a8b38f87586fed6616b23e4a3de5c", + "lib/puppet/parser/functions/validate_integer.rb": "55277d89d5b6e13d889b784578730f74", + "lib/puppet/parser/functions/validate_ip_address.rb": "093d46312d6dd618954c0076a8f667f7", + "lib/puppet/parser/functions/validate_ipv4_address.rb": "65bb41c57c489f8032d1b892b4534061", + "lib/puppet/parser/functions/validate_ipv6_address.rb": "abc96d513f8bd739c69cb78cd8811dc5", + "lib/puppet/parser/functions/validate_numeric.rb": "0f8225b9decf1c908e5c387ca039f2b0", + "lib/puppet/parser/functions/validate_re.rb": "26ebeaba9c6b0d7c2ab2a7c1fadca37b", + "lib/puppet/parser/functions/validate_slength.rb": "fd26a0f026f12181801f18e9d7a27534", + "lib/puppet/parser/functions/validate_string.rb": "77fd937008ec3da670b5acf2c7920227", + "lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "bb34e2398eaaacf053dfb9c27be3442b", + "lib/puppet/parser/functions/values.rb": "f7d883ec3b76ae7a1ab7a8ed68feec06", + "lib/puppet/parser/functions/values_at.rb": "4a88d4dd856930d9218b93c97ce9829c", + "lib/puppet/parser/functions/zip.rb": "186ad52bdd38054d2fcb42a32a80281f", + "lib/puppet/provider/file_line/ruby.rb": "fb2376cadd33481286e5427489fdff00", + "lib/puppet/type/anchor.rb": "5a5df539a80bf1593b70d12a9ec3458f", + "lib/puppet/type/file_line.rb": "5e944a6f40914fe71920ca1307127069", "locales/config.yaml": "d3795b3334faf13674a5d1e3759064ac", "locales/ja/puppetlabs-stdlib.po": "805e5d893d2025ad57da8ec0614a6753", "locales/puppetlabs-stdlib.pot": "23c892ac0683aef4b09aabe0037750ae", - "manifests/init.pp": "9560a09f657d7eebbfdb920cefcc1d4f", - "manifests/stages.pp": "72eb4fa624474faf23b39e57cf1590bd", - "metadata.json": "1be898fdb374bd36f05aa6dd4f4ab3c4", - "readmes/README_ja_JP.md": "36810eaee0543bb5c7a446c6fd576811", - "spec/acceptance/abs_spec.rb": "320dc9b8ecf5cc434942db3c76cc44c8", - "spec/acceptance/anchor_spec.rb": "96b18124a8bd485928ef49ac82072789", - "spec/acceptance/any2array_spec.rb": "8071bc5d9616d73d29c252ca3f919300", - "spec/acceptance/base64_spec.rb": "817503716d7df9052ca3730a8d3fa1f5", - "spec/acceptance/bool2num_spec.rb": "2adb07b2abf9fab7845f8e93d63cfe0e", - "spec/acceptance/build_csv.rb": "0d4e10040cb934a78c523bebda8a2362", - "spec/acceptance/capitalize_spec.rb": "3956adeac93418b6702811b83a6e1dd1", - "spec/acceptance/ceiling_spec.rb": "2e913e0bc8a92eaa92ceaa5ec91f3b54", - "spec/acceptance/chomp_spec.rb": "8a27b04bf893da4acd02334a03cdc51b", - "spec/acceptance/chop_spec.rb": "d79ff0a335e2648e468af137560c15f7", - "spec/acceptance/clamp_spec.rb": "35aa8410bbd283546b3325c90c394521", - "spec/acceptance/concat_spec.rb": "0432bcd648b43d2b9fe539543cddfadd", - "spec/acceptance/count_spec.rb": "67c9f9083e980ab397b3d259367ac201", - "spec/acceptance/deep_merge_spec.rb": "a29b282369d829b04784c2b7035a66b0", - "spec/acceptance/defined_with_params_spec.rb": "f136180ec4f44e2f49ed15944a5d4a51", - "spec/acceptance/delete_at_spec.rb": "a6bae7649fcfe02eaf58660a81660a9d", - "spec/acceptance/delete_spec.rb": "69ff71ade09add15063a1375b49d7ad9", - "spec/acceptance/delete_undef_values_spec.rb": "258ca3da1b06afc1e6d8588eed92e8f2", - "spec/acceptance/delete_values_spec.rb": "3a15a34628df45f6a2f25ebf14e3e4f1", - "spec/acceptance/deprecation_spec.rb": "3298d3fc62c4f18211add9ed273df85f", - "spec/acceptance/difference_spec.rb": "e6a0ebbdfffcd374520d40fce11d957b", - "spec/acceptance/dirname_spec.rb": "84cad3f9b2bb6d7e36fbf8b8df1be77b", - "spec/acceptance/downcase_spec.rb": "f57a4296899bbd732f1c3ed438601c7f", - "spec/acceptance/empty_spec.rb": "b89067b0975336683a38bf20a6a1f036", - "spec/acceptance/ensure_resource_spec.rb": "d09c350ba1d0bf7ff14bacf4f1c8e487", - "spec/acceptance/flatten_spec.rb": "54da51ee7665de8b56252d20215a3c30", - "spec/acceptance/floor_spec.rb": "2faea9ed579f7e9f3b045bed2c99fe62", - "spec/acceptance/fqdn_rand_string_spec.rb": "33d5fa38b5f880157ea69dd25a12a332", - "spec/acceptance/fqdn_rotate_spec.rb": "c280ce28ba57b9d67a3e3b1a0c14f342", - "spec/acceptance/get_module_path_spec.rb": "cb34a578c336f8572835520425878d5d", - "spec/acceptance/getparam_spec.rb": "eaa6149d19c6082d7d6cb7f81c1aa342", - "spec/acceptance/getvar_spec.rb": "afe43ffe3e071e0c1d18b679f714fdfc", - "spec/acceptance/grep_spec.rb": "b74c67c94d39a49e9ee395a6c5fc9c9d", - "spec/acceptance/has_interface_with_spec.rb": "36e2cc57fb3f9044e2b93fa98eb436ab", - "spec/acceptance/has_ip_address_spec.rb": "da00303c038e758115e96a0fb65ab9c5", - "spec/acceptance/has_ip_network_spec.rb": "c4991bb6905d4aeba6bab1c9f7cc3fa5", - "spec/acceptance/has_key_spec.rb": "d4eb28efd599e1eac485bf9f6ca930d3", - "spec/acceptance/hash_spec.rb": "0736319571163989e4df71dcff017fd1", - "spec/acceptance/intersection_spec.rb": "8bd80ad4ebf9627add63f257bf0674e4", - "spec/acceptance/is_a_spec.rb": "ecca7dbb41739ebffcefccc2cb85722d", - "spec/acceptance/is_array_spec.rb": "b5baf237a47ace8d53c3748c3432f226", - "spec/acceptance/is_bool_spec.rb": "fa53d0fc3486fc6473184105fad31f2e", - "spec/acceptance/is_domain_name_spec.rb": "963998fd1d72750dd800c8227fa9354c", - "spec/acceptance/is_float_spec.rb": "4f4d179d4e4ca3b6f38ccca6bb855a3f", - "spec/acceptance/is_function_available_spec.rb": "83bb5c733cf1dd2c15fa2f3add9ce61e", - "spec/acceptance/is_hash_spec.rb": "2bfe3af74c15731b2ab251bbaf386245", - "spec/acceptance/is_integer_spec.rb": "f68672a767a6216e3502fc08e61f4a01", - "spec/acceptance/is_ip_address_spec.rb": "680bcb2199c16d346a65c29c6042148c", - "spec/acceptance/is_ipv4_address_spec.rb": "5bbb9b312267da1a2124558867d0cec3", - "spec/acceptance/is_ipv6_address_spec.rb": "05e45351f00b3c4fbfc7ec78bb9f93c6", - "spec/acceptance/is_mac_address_spec.rb": "d6279ad39509c73429f2e60a342f8a51", - "spec/acceptance/is_numeric_spec.rb": "a4b6c6d0b4570672f4cf8ecea3324d9f", - "spec/acceptance/is_string_spec.rb": "1faf6b5fc01a5924077449b3ecf22cbb", - "spec/acceptance/join_keys_to_values_spec.rb": "d8e6a7575e96e33e44ded6c1ef4d329c", - "spec/acceptance/join_spec.rb": "a0db319d437e05e97608cea0525d11e2", - "spec/acceptance/keys_spec.rb": "5712c1b5fdbb268369923d4f3a7e4a5c", - "spec/acceptance/loadjson_spec.rb": "c4a2bebd9648f8843cd394fc78691cb7", - "spec/acceptance/loadyaml_spec.rb": "641cee5b4c85bb01033c75bc5cc9678e", - "spec/acceptance/lstrip_spec.rb": "e1730ce36754f397ce8b75b4fb367e73", - "spec/acceptance/max_spec.rb": "eecd12858eb839a5a6335e2092b093c4", - "spec/acceptance/member_spec.rb": "92facc113e77834516361f7e91a6b07a", - "spec/acceptance/merge_spec.rb": "a2d398f1b407736d576a01a350a7b378", - "spec/acceptance/min_spec.rb": "4b47af34106bc46990b72479b760a06f", + "manifests/init.pp": "b7b0b780b800ba4fa1b7bc77d5c760e7", + "manifests/stages.pp": "4c455c755205fb405b1b598b172358f0", + "metadata.json": "add365d33a389660e84e0d3a484a3716", + "provision.yaml": "3640cb4b000ddaa38122efbdf8ff9c6b", + "readmes/README_ja_JP.md": "3c20e2c1d8edeffa0935fb7b8d0be64b", + "spec/acceptance/anchor_spec.rb": "8da30674d0c852e84776bb66bd6fa450", + "spec/acceptance/file_line_spec.rb": "223c241e3fca6ed815612176fbcb801e", "spec/acceptance/nodesets/centos-7-x64.yml": "a713f3abd3657f0ae2878829badd23cd", "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39", "spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808", "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae", "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df", "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58", - "spec/acceptance/num2bool_spec.rb": "a1c7ae1ae573238474264f512ceac029", - "spec/acceptance/parsejson_spec.rb": "703943409a4942e143a9ee64428137d2", - "spec/acceptance/parseyaml_spec.rb": "4c423fec2126c06d73b680ccedb2d92a", - "spec/acceptance/pick_default_spec.rb": "74ef7cc0cff5613e2f5bb51860cc78f5", - "spec/acceptance/pick_spec.rb": "883435ee18338b44d8a809df948f013a", - "spec/acceptance/prefix_spec.rb": "6e3763b5c18208441b21d2f6eae24339", - "spec/acceptance/pw_hash_spec.rb": "14bbe22f9eb59c4010abd33db766b2ab", - "spec/acceptance/range_spec.rb": "d875cff37547b97946bebb726918c9d6", - "spec/acceptance/reject_spec.rb": "844ab5a15688cf0d4777f78f1ba94513", - "spec/acceptance/reverse_spec.rb": "3b1bb403962eedbdbc86f02c396bada0", - "spec/acceptance/rstrip_spec.rb": "4497598e178e70e906311ed45dcc9a26", - "spec/acceptance/shuffle_spec.rb": "c3541f8e2612d38aa11cb848ba5c2fd6", - "spec/acceptance/size_spec.rb": "c74418e929f607652e8c3b973a12d17a", - "spec/acceptance/sort_spec.rb": "828bc21cb73e63676cb19d66b64f9e47", - "spec/acceptance/squeeze_spec.rb": "1f6dd45cab59278b021a3c8ee931a988", - "spec/acceptance/str2bool_spec.rb": "875a523687b93ab94169ca06b02d8fc2", - "spec/acceptance/str2saltedsha512_spec.rb": "d7552194362956fd86e7be11c49d75e9", - "spec/acceptance/strftime_spec.rb": "009ef42851b32aa797cdea874bf9e3cc", - "spec/acceptance/strip_spec.rb": "8e7d9e5b028c831f9982b77eed7d4961", - "spec/acceptance/suffix_spec.rb": "3fc89836a92965f8093187554099bc5a", - "spec/acceptance/swapcase_spec.rb": "9b90e7d7d441e998a7946fb33a7d9edd", - "spec/acceptance/time_spec.rb": "b262929e40fb53bbaabca8fda696c5b3", - "spec/acceptance/to_bytes_spec.rb": "0907f39eb1815eb766e18d458a44a967", - "spec/acceptance/try_get_value_spec.rb": "2dfffd91ac418d5429b32ddb4cdb236c", - "spec/acceptance/type3x_spec.rb": "fa30d2d82906b774d69109ad08f963b4", - "spec/acceptance/type_spec.rb": "1d55a0ad8635c239a33a1d107bda5404", - "spec/acceptance/union_spec.rb": "7fc2a6f6b6c4c2abb625926cd9013cca", - "spec/acceptance/unique_spec.rb": "66bf8230e4a8a9ae15a8d2850ceb281b", - "spec/acceptance/upcase_spec.rb": "e5975b83f4ada72bcdbae15d872596aa", - "spec/acceptance/uriescape_spec.rb": "29ce7eea67a8b400c2f2f6d9e63390f6", - "spec/acceptance/validate_absolute_path_spec.rb": "96150e35fd107582636420289240a1e9", - "spec/acceptance/validate_array_spec.rb": "50273b0f02c5c45d52386d501f025712", - "spec/acceptance/validate_augeas_spec.rb": "006d3658397e85dd497d7c612cbb3ae5", - "spec/acceptance/validate_bool_spec.rb": "448cc97e9b277cea82a6aa15cb40cc88", - "spec/acceptance/validate_cmd_spec.rb": "c42681ac8aed0ca83577c0205fec6aa9", - "spec/acceptance/validate_hash_spec.rb": "e0c2114c7c365a90230335a2e8d9d817", - "spec/acceptance/validate_ipv4_address_spec.rb": "233a114fc42a9a138902531d8b5b2b50", - "spec/acceptance/validate_ipv6_address_spec.rb": "215aed228a0c626ee321212534b31264", - "spec/acceptance/validate_re_spec.rb": "10eb1f29d0cd62dfafef9f99939cbc81", - "spec/acceptance/validate_slength_spec.rb": "6c82dcb830e1d2cf66b60c425e5aa27b", - "spec/acceptance/validate_string_spec.rb": "3e4d023775e7b11de5d1deabf4bb4e39", - "spec/acceptance/values_at_spec.rb": "25ab415d4a3b2bbbf225f1e3410978dc", - "spec/acceptance/values_spec.rb": "7cd9f430afad102cae1feb5d4a6cc743", - "spec/acceptance/zip_spec.rb": "fc7b9e42b408d0fe2171b4eabfcfd585", "spec/default_facts.yml": "d4442f09ee2f33f2d55f078d0ee2634f", "spec/fixtures/dscacheutil/root": "e1a7622f55f3d1be258c9a5b16b474be", "spec/fixtures/lsuser/root": "2ed657fa157372a81634539bb1a56be8", @@ -325,89 +225,90 @@ "spec/fixtures/test/manifests/base64.pp": "935f9c1b4ac741c58b7abd49d3cfb794", "spec/fixtures/test/manifests/deftype.pp": "1f2e86fa39604fdfde8fd20b9ae92813", "spec/fixtures/test/manifests/ensure_resources.pp": "898c473ba5641313294827f4b4845bd6", - "spec/functions/abs_spec.rb": "0821179e4127a8754ccf509c759b7c41", + "spec/functions/abs_spec.rb": "1d2758920667c0920f77998882ca2b32", "spec/functions/any2array_spec.rb": "8ca97ceb68a60ff5c4ade6e6aa7b81df", "spec/functions/any2bool_spec.rb": "48b23ce295c256aa14cfeac0501cc3a5", "spec/functions/assert_private_spec.rb": "d48bc3c4ed2115c18859b2db1490795c", "spec/functions/base64_spec.rb": "5083c40b825f86863cc2950d97d3807b", - "spec/functions/basename_spec.rb": "beeae06a6fc449d44352031e4a61e900", - "spec/functions/bool2num_spec.rb": "bb82d4eed099e97c5af545cdce3445d6", + "spec/functions/basename_spec.rb": "31d3cb7e871b59f909154372fc983751", + "spec/functions/bool2num_spec.rb": "49b6cc96b6c215e1c4bf1ad303913ff9", "spec/functions/bool2str_spec.rb": "286b56a5bab37d4849e10b7f0f9630ed", "spec/functions/camelcase_spec.rb": "e4693de9fcd022bc9c798e27bf1c11ae", "spec/functions/capitalize_spec.rb": "be58e5ff4956bcca07055d66369021d2", - "spec/functions/ceiling_spec.rb": "b3a9f9285b217d9eb407981e39a7552f", - "spec/functions/chomp_spec.rb": "746af6dc903bb7f20ef801a1ab3bc40e", - "spec/functions/chop_spec.rb": "fc59485a227d36556f88a77e53bcfde4", - "spec/functions/clamp_spec.rb": "8094bc19ff0fe82dfd0a072b654bf318", - "spec/functions/concat_spec.rb": "e21069451db12fb90e30a2c2f01879df", + "spec/functions/ceiling_spec.rb": "211eb2e796a1e8671ec528a60d6926c2", + "spec/functions/chomp_spec.rb": "c9516458b1ca71f61399e077bdd8b1b5", + "spec/functions/chop_spec.rb": "0d4d38ae09fc8ba02b50711ecac6e876", + "spec/functions/clamp_spec.rb": "e9502b5652b205c01aa6115c69ab7a79", + "spec/functions/concat_spec.rb": "cdadaafc6e42b319d6a1f0d4aaa1bca9", "spec/functions/convert_base_spec.rb": "534bd90106b2c58f736b897974c5a10a", "spec/functions/count_spec.rb": "d5990b080447cff101f05d8aeb1e6df6", "spec/functions/deep_merge_spec.rb": "2bb3422045040c4dac2ad75fbae07995", "spec/functions/defined_with_params_spec.rb": "b4e13e71b935fd4823321b297abfb3e9", - "spec/functions/delete_at_spec.rb": "eeb300241f56b186138510969cfc6088", - "spec/functions/delete_regex_spec.rb": "3004d1f3a40297da06816c9a40ebbcd7", - "spec/functions/delete_spec.rb": "16b01482d05b790b53718b0436cf31b3", - "spec/functions/delete_undef_values_spec.rb": "f19b0b244f0483f25fac1dbde5f5568b", - "spec/functions/delete_values_spec.rb": "a61b115f69844f7f416d3c2e9dfa308e", + "spec/functions/delete_at_spec.rb": "10e09867a03e94623f8d0e040c288480", + "spec/functions/delete_regex_spec.rb": "7bfc5d6ded6cb48830b6cc6934c9c455", + "spec/functions/delete_spec.rb": "bb7d3606a64492ad51384979b6be74d6", + "spec/functions/delete_undef_values_spec.rb": "7252fb2c51c3e1ad969a285965d54d0e", + "spec/functions/delete_values_spec.rb": "80e23a8f6083703728858604a55a35f6", "spec/functions/deprecation_spec.rb": "a8c77ef118546f3a9bacbe3e71fa1f16", - "spec/functions/difference_spec.rb": "a5d33319d500e4752714ac83bee4d35d", - "spec/functions/dig44_spec.rb": "818be861d447c8efcc84f4d8f94f0546", + "spec/functions/difference_spec.rb": "dbb47074b5143c53cd6870b2d86556f7", + "spec/functions/dig44_spec.rb": "30abd1bd2c5b1b840b3178d24b2ac8ca", "spec/functions/dig_spec.rb": "ac6671760e3864540aa0790ee37bd5ab", - "spec/functions/dirname_spec.rb": "23220e14486056dd9dcce127aa9ada16", - "spec/functions/dos2unix_spec.rb": "f7f10a39d4d4d42bef7a1bc99d97ea1c", - "spec/functions/downcase_spec.rb": "f9afb4203c5587ad9082801e02547f98", - "spec/functions/empty_spec.rb": "5b10598d2782eb25b10e4dd9e186aca0", + "spec/functions/dirname_spec.rb": "7d9af39a3276e3f4de82e067aedb38d1", + "spec/functions/dos2unix_spec.rb": "62e06e17b0dea96720d4c016e9866a53", + "spec/functions/downcase_spec.rb": "b7de6605596cb6d95b453af2152acd63", + "spec/functions/empty_spec.rb": "e3db267a4e0c79ec50b886e29bc1db59", "spec/functions/ensure_packages_spec.rb": "aa087a5474ffe29d3a8a6f5e8bf5aacb", "spec/functions/ensure_resource_spec.rb": "e3762777948cf285c5c2ce806ef1992b", "spec/functions/ensure_resources_spec.rb": "9222a26a12afacf5e31ae19174a534fd", "spec/functions/extname_spec.rb": "1b8fff4c728711931b66d36caabae937", - "spec/functions/flatten_spec.rb": "f40671d863548ea6626a79c184cd69fd", - "spec/functions/floor_spec.rb": "b7eeadfab998dd364cf92e8b13981a8a", + "spec/functions/flatten_spec.rb": "a32ff65cf680993ad67199942bd31bc8", + "spec/functions/floor_spec.rb": "2a7eb8a32a874791259def91eaa077cf", "spec/functions/fqdn_rand_string_spec.rb": "91371725b89be5b026a7d9a179066021", "spec/functions/fqdn_rotate_spec.rb": "e940b050175501f857efcb1b279f53a4", - "spec/functions/fqdn_uuid_spec.rb": "60526a453f556867b369496ca1215a86", + "spec/functions/fqdn_uuid_spec.rb": "186f9dc35bb09b887dfec17f13a16bbe", "spec/functions/get_module_path_spec.rb": "2d22d3b677b3fe67337d6d9e88994cc9", "spec/functions/getparam_spec.rb": "807694642f3ebdfafca4c8f0eca4c062", "spec/functions/getvar_spec.rb": "f4b6e5e025feb8ef1a1425d85c615ae0", "spec/functions/glob_spec.rb": "537139a45aa1acfb605aa0cb6b598b73", "spec/functions/grep_spec.rb": "c8bd616f1d4940261e8a9f7b05254528", "spec/functions/has_interface_with_spec.rb": "d484da75727170eb3ff22bbc71394fd1", - "spec/functions/has_ip_address_spec.rb": "811d63a9c87a1de43a18d07c8ee5a796", - "spec/functions/has_ip_network_spec.rb": "9ec0c0c607a60d2dde3a66fc969e4478", + "spec/functions/has_ip_address_spec.rb": "ff9bb2bd0bd5a9d2f2109871ff16fc98", + "spec/functions/has_ip_network_spec.rb": "32120659b36ac71a769594b3227ac083", "spec/functions/has_key_spec.rb": "d4d97da7d35a794e72d1bbc5e0a4838f", "spec/functions/hash_spec.rb": "a9d483dfbd3f2d66b457851ff3144b1a", "spec/functions/intersection_spec.rb": "72688d38e9301d9e15bae6bb3f7d8568", + "spec/functions/ip_in_range_spec.rb": "513e2718af40ccc65373fc212a7d74d8", "spec/functions/is_a_spec.rb": "e657f393cc3572883aa2ab872840f4bf", "spec/functions/is_array_spec.rb": "9e9bc571ecb67b57ad0033da1e02a578", "spec/functions/is_bool_spec.rb": "598acad9be16faa86a4370d7646b06d9", - "spec/functions/is_domain_name_spec.rb": "0e2cf9c9410827484ee3652591757faf", + "spec/functions/is_domain_name_spec.rb": "250ceb83bc0b85dafbbae809aa678c35", "spec/functions/is_email_address_spec.rb": "f3e60f28e9d66d7707a434a8edc79900", - "spec/functions/is_float_spec.rb": "344ff678f331307c20f3c5b7dba89f55", - "spec/functions/is_function_available_spec.rb": "0f46d970fca74c87dbcbbaa588b6dc37", - "spec/functions/is_hash_spec.rb": "cec4b5638ea3f871350a055cee98ea11", + "spec/functions/is_float_spec.rb": "d4051f03f193cab8ba81896038772080", + "spec/functions/is_function_available_spec.rb": "98987ebd25e5050948673f3db95cb237", + "spec/functions/is_hash_spec.rb": "2e4b2a2690947509c11032dab5645c83", "spec/functions/is_integer_spec.rb": "0ba7bc665d334191a838bd34f6c97a75", - "spec/functions/is_ip_address_spec.rb": "704138919636e1b758417d561042f7bc", + "spec/functions/is_ip_address_spec.rb": "f04e3ee8b4b41b82cd24dd714b0e81db", "spec/functions/is_ipv4_address_spec.rb": "fa7ed52ae8e95eb53640ddedfb75c776", - "spec/functions/is_ipv6_address_spec.rb": "3e58b90f1e6cd581a3744856e1f82b48", + "spec/functions/is_ipv6_address_spec.rb": "73d89a99e3a3e67da7c503122dd02f97", "spec/functions/is_mac_address_spec.rb": "be6fc820b9583aa23730581a7fd0218b", - "spec/functions/is_numeric_spec.rb": "57302fc9c642e6d9d0299b403f8ff082", - "spec/functions/is_string_spec.rb": "aa2821208c0f039d748b871a6a6560af", + "spec/functions/is_numeric_spec.rb": "7d4846a71d0a9bc2376dcc9f512b7430", + "spec/functions/is_string_spec.rb": "641b0b76f520d70e0a6df33ca26dbc78", "spec/functions/join_keys_to_values_spec.rb": "a365b021aea1a0a54f27b24b0b1d3f24", "spec/functions/join_spec.rb": "2c1da15b52b6a9cea55825328f2e0ada", "spec/functions/keys_spec.rb": "185acb2eeb716cf93c99cbbd41327224", "spec/functions/length_spec.rb": "2f9edfc8fbb4058a267bd00674cad654", - "spec/functions/load_module_metadata_spec.rb": "2419390d7e41728aa460ef46cc06319f", - "spec/functions/loadjson_spec.rb": "12019b907452e777eacedb8b974abdae", + "spec/functions/load_module_metadata_spec.rb": "e85aedac6540d4dbec21120afd31e361", + "spec/functions/loadjson_spec.rb": "bebf061634829a66072f4abcde61cde8", "spec/functions/loadyaml_spec.rb": "0a6dd0a389c49f90d61f915b6718411a", "spec/functions/lstrip_spec.rb": "552c469f04c8de63b6c8cefb0280cba3", "spec/functions/max_spec.rb": "e82809c424860b8d94ef8af70abd4891", - "spec/functions/member_spec.rb": "f82cacb72d59a306ffe262b2382c7f19", - "spec/functions/merge_spec.rb": "48761dac5afc99bd381f76f88927cdb0", - "spec/functions/min_spec.rb": "4e8d5f82ad27d8f5b8c3ae1595aa56a1", - "spec/functions/num2bool_spec.rb": "fe3c3dbec9787622850175db510fe4f0", - "spec/functions/os_version_gte_spec.rb": "175b70864c196b0c99473b2206d1b09b", + "spec/functions/member_spec.rb": "bc3cb6ff6d32dea36045b2c1f370e7b0", + "spec/functions/merge_spec.rb": "b5389b77b34509dfc4775d9d2b0c28c1", + "spec/functions/min_spec.rb": "085856878e00b66f1dd572e12fec6069", + "spec/functions/num2bool_spec.rb": "4b76538824434d08fce88f7acf337c66", + "spec/functions/os_version_gte_spec.rb": "25df25bf257e5f5f7d523e5acf0dc990", "spec/functions/parsejson_spec.rb": "70b494139e7289908b6adb36ea8f3bed", - "spec/functions/parseyaml_spec.rb": "aace674f64e4629e6377276b307ea723", + "spec/functions/parseyaml_spec.rb": "070ca4698f0a468d2c03af84e72f5384", "spec/functions/pick_default_spec.rb": "43306416fdac7e7a3378fe51cb9bf9e7", "spec/functions/pick_spec.rb": "856384e60757e1d94ca3aef161be3d0a", "spec/functions/prefix_spec.rb": "5e6eb13f3f9834e975152812f22f2e99", @@ -426,21 +327,21 @@ "spec/functions/shell_split_spec.rb": "f6ab347d718d140ffdcccd0590c889d8", "spec/functions/shuffle_spec.rb": "3c775cb2fae13839f477cbec188eea1a", "spec/functions/size_spec.rb": "dc4aa41250a64e728ce8135e888e3081", - "spec/functions/sort_spec.rb": "e63f4b92a90d5e9c7e541a41dc89df12", + "spec/functions/sort_spec.rb": "97475dc1e162991a8ebdcb3f1334f6ee", "spec/functions/sprintf_hash_spec.rb": "1b014e8c0a44b935ec0c045e275ad6b3", "spec/functions/squeeze_spec.rb": "fa3531e7cd49989b1ece7d48ccd10255", "spec/functions/str2bool_spec.rb": "d099ca74f02ac231f699e59d7a41bafb", "spec/functions/str2saltedsha512_spec.rb": "815dfb2f7c65f81769c117129e45bf85", - "spec/functions/strftime_spec.rb": "7f57c8b5350e9bfd4eb0f414f9192778", + "spec/functions/strftime_spec.rb": "e4ff0163ab707966186d7941b0e5f18d", "spec/functions/strip_spec.rb": "1212eef324f730400c8a62d9db95a22c", - "spec/functions/suffix_spec.rb": "5e2834f3885002c9ff9ac20dd6333415", + "spec/functions/suffix_spec.rb": "61754a258fda440bc0f5e00af91f30a9", "spec/functions/swapcase_spec.rb": "d0dc69eda3fcdf043cc116ccb6ee3b28", "spec/functions/time_spec.rb": "0d1032f734d35e53ee33904d17465cbc", "spec/functions/to_bytes_spec.rb": "dbc093a1a72429a0a67e784ecabc100a", "spec/functions/to_json_pretty_spec.rb": "42d902947a4afc3708846d3864a5f5a4", "spec/functions/to_json_spec.rb": "1e2d9917ddf37af4e241b89bd9e009e3", "spec/functions/to_yaml_spec.rb": "1c3302e5d19b2ae929ecdf44668b0492", - "spec/functions/try_get_value_spec.rb": "53ab2e553ae441821ad02be3c952a34a", + "spec/functions/try_get_value_spec.rb": "c98599d09b8d4eabbfbc2c273c3337b4", "spec/functions/type3x_spec.rb": "9898ca5ab31f4fded1a5d38767e7e981", "spec/functions/type_of_spec.rb": "ecfeb9d47e54f5aae421f7855853d47a", "spec/functions/type_spec.rb": "7c70254652b2e46ef7c80dce5667c32b", @@ -449,31 +350,31 @@ "spec/functions/unix2dos_spec.rb": "77e6d0e7c703576924981038472c8e4e", "spec/functions/upcase_spec.rb": "363e49846e4ca0a3a6eca2c19e0f2c04", "spec/functions/uriescape_spec.rb": "d0730544b94c15d63e99e7ed50c13e92", - "spec/functions/validate_absolute_path_spec.rb": "a549c5e4697689c8d68d69df43c0cf10", - "spec/functions/validate_array_spec.rb": "c890aabc47c35316deeed9921a941020", + "spec/functions/validate_absolute_path_spec.rb": "d55aa2bb90d4b687aa9de9edcdd03208", + "spec/functions/validate_array_spec.rb": "b25dfc7ab21645d2a3dae2c5de11de95", "spec/functions/validate_augeas_spec.rb": "4bf035ec4548a00d42f73643374d6f58", - "spec/functions/validate_bool_spec.rb": "5e835885844167c3d5a31172a5c9f422", + "spec/functions/validate_bool_spec.rb": "d19f26dd3d51f4145ce0ed0db5da9897", "spec/functions/validate_cmd_spec.rb": "179e570e9aec94c5dcaf337a6b431d20", "spec/functions/validate_domain_name_spec.rb": "611f3b301003d11a6a55e293dc3a8e5c", "spec/functions/validate_email_address_spec.rb": "8bac32b793f1e4264ae32df975d4d893", - "spec/functions/validate_hash_spec.rb": "5eccbe065b5eda4c5e01278b4bf78d44", + "spec/functions/validate_hash_spec.rb": "27fd29cf193662834c6056726d7cc1e2", "spec/functions/validate_integer_spec.rb": "10affb4021ea0c64e54d4f6bcaf70c78", "spec/functions/validate_ip_address_spec.rb": "dd1abc13784514aa328e44bf2057561a", - "spec/functions/validate_ipv4_address_spec.rb": "a9aeef982051cbeabe1b4f279d3e13d2", + "spec/functions/validate_ipv4_address_spec.rb": "146dc770bc7e7427bbf1bb2f332e0a92", "spec/functions/validate_ipv6_address_spec.rb": "4bdd3a680ec2d256a9187c174e32f9ba", "spec/functions/validate_legacy_spec.rb": "f5b522d41c65a8a52a0b4f0056b68da6", "spec/functions/validate_numeric_spec.rb": "36891aa54f3b0f3d6c70758ccd2e3ac7", - "spec/functions/validate_re_spec.rb": "440d0abad99b0c898aa541d5b5037098", + "spec/functions/validate_re_spec.rb": "acacf14849bb3ec47643cd83bffea2ec", "spec/functions/validate_slength_spec.rb": "4a4440cf424665ccc8b09cfaca52517c", - "spec/functions/validate_string_spec.rb": "898fb0e2be0336414aabdfa6202b97f6", + "spec/functions/validate_string_spec.rb": "3a65a2f90be1ee23b04a5713b98a9d7d", "spec/functions/validate_x509_rsa_key_pair_spec.rb": "d73371004571f46dda1837dec3661d39", "spec/functions/values_at_spec.rb": "9b0d8851c3b1ef74dbbfcacd68c033ef", "spec/functions/values_spec.rb": "debbd0e2c93ddf45adfeae82caa2b50f", - "spec/functions/zip_spec.rb": "da07c5877fe4318e53c215e981a2ee92", + "spec/functions/zip_spec.rb": "469ec7bd49ec9a7bba90e9f2ed4c2afb", "spec/monkey_patches/alias_should_to_must.rb": "3455626d32375d114ee5622e19a1fa6c", "spec/monkey_patches/publicize_methods.rb": "d2ae9210754b0a4eae0d6bf33737fe90", - "spec/spec_helper.rb": "a0540643c8838d5b6677f18e7d5423ea", - "spec/spec_helper_acceptance.rb": "d37250e62078059e9ac11bbe6d77356a", + "spec/spec_helper.rb": "3a5cb451e0a0b4995c5d07f306088603", + "spec/spec_helper_acceptance.rb": "cce39efa586eb23fd74fbd3d8ed58db3", "spec/spec_helper_local.rb": "5644c5ce611a9e131cf37106e2a8b841", "spec/support/shared_data.rb": "dfe4cbdbe2833d670a89bcdf3163839b", "spec/type_aliases/absolute_path_spec.rb": "a03a9c6fe2e3e6fbb23cd62c263032c2", @@ -506,12 +407,16 @@ "spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb": "c5fad1a8e5fee0cfac3ee9f1b5083804", "spec/type_aliases/ip_address_v6_spec.rb": "74a4c54bf8fffc4ebc3e33c12b085640", "spec/type_aliases/numeric_spec.rb": "06ae28964dfad6ca60ac59468c33104b", + "spec/type_aliases/objectstore_gsuri_spec.rb": "189bdf8314c75dcdc39a05375c166a80", + "spec/type_aliases/objectstore_s3uri_spec.rb": "7eb47306dd35f2993ee9ca01061e5663", + "spec/type_aliases/objectstore_spec.rb": "49673c2ec656d39f23c326052181f78a", "spec/type_aliases/port__privileged_spec.rb": "531e8567e3251548324088e1cdac29d6", "spec/type_aliases/port__unprivileged_spec.rb": "ec5aa19f8bfb62307617c0e9b002475d", "spec/type_aliases/port_spec.rb": "6fff6e2cfc7b91e49b6dd169629f8a53", "spec/type_aliases/string_spec.rb": "458ac453f5870066824b6a11ec49f9ae", "spec/type_aliases/unixpath_spec.rb": "04e31be6626f96e605459b4ce8c94395", "spec/type_aliases/windowspath_spec.rb": "a1473316f1745fa3e20be83a2eb026c7", + "spec/type_aliases/yes_no_spec.rb": "65925081b1eee87e5fe56028e9706fcd", "spec/unit/facter/facter_dot_d_spec.rb": "3853da05ad110c512bbbacce81e17176", "spec/unit/facter/package_provider_spec.rb": "c23d89ad7313f647f917d8a945815693", "spec/unit/facter/pe_version_spec.rb": "f013e4ef5aa532fc2af19ddf3a82cf48", @@ -562,9 +467,14 @@ "types/ip/address/v6.pp": "1f3c0aa34dbc083d26f135246c8576eb", "types/ip/address.pp": "9929a758afc9469acbcff0c2050bb0ab", "types/mac.pp": "6c4a697bca8a68bdc6db1394108df6d0", + "types/objectstore/gsuri.pp": "8c315d523e14eaca1f1ae40fd0ef1389", + "types/objectstore/s3uri.pp": "ebb69db2ae883d4a59bf57b6bd434e63", + "types/objectstore.pp": "3955f09901518fa97d6dbb1630c893f7", "types/port/privileged.pp": "c4ce776dd07a3c8dd3379db8cd49e32a", "types/port/unprivileged.pp": "85359128fa9261fe8bf58c8525574404", "types/port.pp": "b1edd08c4eff860b3ea8bd84cd48ba81", + "types/syslogfacility.pp": "b5d29bc1d50708ae16edd13f6bb4b1fe", "types/unixpath.pp": "b64a48701e7adfda45d31fd80bee4ad0", - "types/windowspath.pp": "4c1eda331ecb43de98c29ed22d0ad448" + "types/windowspath.pp": "4c1eda331ecb43de98c29ed22d0ad448", + "types/yes_no.pp": "9837204961362ecc238bd9f8cac38a39" } \ No newline at end of file diff --git a/3rdparty/modules/stdlib/distelli-manifest.yml b/3rdparty/modules/stdlib/distelli-manifest.yml new file mode 100644 index 000000000..4561e152c --- /dev/null +++ b/3rdparty/modules/stdlib/distelli-manifest.yml @@ -0,0 +1,25 @@ +team-modules/puppetlabs-stdlib: + PreBuild: + - source /opt/rh/rh-ruby25/enable + - echo "--- LETS update BUNDLER ---" + - bundle install --path vendor/bundle --jobs 3 + Build: + - echo "--- PROVISIONING ---" + - source /opt/rh/rh-ruby25/enable + - bundle exec rake litmus:provision_list[release_checks] + - cat inventory.yaml + - echo "--- AGENT INSTALLATION ---" + - bundle exec rake litmus:install_agent + - echo "--- MODULE INSTALLATION ---" + - bundle exec rake litmus:install_module + - echo "--- TESTS RUNNING ---" + - bundle exec rake litmus:acceptance:parallel + AfterBuildSuccess: + - source /opt/rh/rh-ruby25/enable + - bundle exec rake litmus:tear_down + AfterBuildFailure: + - source /opt/rh/rh-ruby25/enable + - bundle exec rake litmus:tear_down + CommitData: + - RepoType: Git + - RepoPath: . diff --git a/3rdparty/modules/stdlib/lib/facter/facter_dot_d.rb b/3rdparty/modules/stdlib/lib/facter/facter_dot_d.rb index 5025ed9e2..2d6e17961 100644 --- a/3rdparty/modules/stdlib/lib/facter/facter_dot_d.rb +++ b/3rdparty/modules/stdlib/lib/facter/facter_dot_d.rb @@ -1,5 +1,6 @@ -# A Facter plugin that loads facts from /etc/facter/facts.d -# and /etc/puppetlabs/facter/facts.d. +# @summary +# A Facter plugin that loads facts from /etc/facter/facts.d +# and /etc/puppetlabs/facter/facts.d. # # Facts can be in the form of JSON, YAML or Text files # and any executable that returns key=value pairs. @@ -13,7 +14,7 @@ # fact scripts more often than is needed class Facter::Util::DotD require 'yaml' - + # These will be nil if Puppet is not available. def initialize(dir = '/etc/facts.d', cache_file = File.join(Puppet[:libdir], 'facts_dot_d.cache')) @dir = dir @cache_file = cache_file @@ -21,12 +22,15 @@ class Facter::Util::DotD @types = { '.txt' => :txt, '.json' => :json, '.yaml' => :yaml } end + # entries def entries Dir.entries(@dir).reject { |f| f =~ %r{^\.|\.ttl$} }.sort.map { |f| File.join(@dir, f) } rescue [] end + # fact_type + # @param file def fact_type(file) extension = File.extname(file) @@ -37,6 +41,8 @@ class Facter::Util::DotD type end + # txt_parser + # @param file def txt_parser(file) File.readlines(file).each do |line| next unless line =~ %r{^([^=]+)=(.+)$} @@ -51,6 +57,8 @@ class Facter::Util::DotD Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}") end + # json_parser + # @param file def json_parser(file) begin require 'json' @@ -68,6 +76,8 @@ class Facter::Util::DotD Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}") end + # yaml_parser + # @param file def yaml_parser(file) require 'yaml' @@ -80,6 +90,8 @@ class Facter::Util::DotD Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}") end + # script_parser + # @param file def script_parser(file) result = cache_lookup(file) ttl = cache_time(file) @@ -110,12 +122,15 @@ class Facter::Util::DotD Facter.debug(e.backtrace.join("\n\t")) end + # cache_save def cache_save! cache = load_cache File.open(@cache_file, 'w', 0o600) { |f| f.write(YAML.dump(cache)) } rescue # rubocop:disable Lint/HandleExceptions end + # cache_store + # @param file def cache_store(file, data) load_cache @@ -123,6 +138,8 @@ class Facter::Util::DotD rescue # rubocop:disable Lint/HandleExceptions end + # cache_lookup + # @param file def cache_lookup(file) cache = load_cache @@ -140,6 +157,8 @@ class Facter::Util::DotD return nil end + # cache_time + # @param file def cache_time(file) meta = file + '.ttl' @@ -148,6 +167,7 @@ class Facter::Util::DotD return 0 end + # load_cache def load_cache @cache ||= if File.exist?(@cache_file) YAML.load_file(@cache_file) @@ -161,6 +181,7 @@ class Facter::Util::DotD return @cache end + # create def create entries.each do |fact| type = fact_type(fact) diff --git a/3rdparty/modules/stdlib/lib/facter/package_provider.rb b/3rdparty/modules/stdlib/lib/facter/package_provider.rb index 0aec17183..d993e79ef 100644 --- a/3rdparty/modules/stdlib/lib/facter/package_provider.rb +++ b/3rdparty/modules/stdlib/lib/facter/package_provider.rb @@ -10,7 +10,9 @@ require 'puppet/type' require 'puppet/type/package' +# These will be nil if Puppet is not available. Facter.add(:package_provider) do + # Instantiates a dummy package resource and return the provider setcode do if defined? Gem && Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6') Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s diff --git a/3rdparty/modules/stdlib/lib/facter/pe_version.rb b/3rdparty/modules/stdlib/lib/facter/pe_version.rb index 594f9dce6..d01185580 100644 --- a/3rdparty/modules/stdlib/lib/facter/pe_version.rb +++ b/3rdparty/modules/stdlib/lib/facter/pe_version.rb @@ -8,6 +8,7 @@ # # Caveats: # +# Fact: pe_version Facter.add('pe_version') do setcode do puppet_ver = Facter.value('puppetversion') @@ -20,6 +21,7 @@ Facter.add('pe_version') do end end +# Fact: is_pe Facter.add('is_pe') do setcode do if Facter.value(:pe_version).to_s.empty? @@ -30,6 +32,7 @@ Facter.add('is_pe') do end end +# Fact: pe_major_version Facter.add('pe_major_version') do confine :is_pe => true setcode do @@ -40,6 +43,7 @@ Facter.add('pe_major_version') do end end +# Fact: pe_minor_version Facter.add('pe_minor_version') do confine :is_pe => true setcode do @@ -50,6 +54,7 @@ Facter.add('pe_minor_version') do end end +# Fact: pe_patch_version Facter.add('pe_patch_version') do confine :is_pe => true setcode do diff --git a/3rdparty/modules/stdlib/lib/facter/puppet_settings.rb b/3rdparty/modules/stdlib/lib/facter/puppet_settings.rb index b9321893f..1ab3d8c87 100644 --- a/3rdparty/modules/stdlib/lib/facter/puppet_settings.rb +++ b/3rdparty/modules/stdlib/lib/facter/puppet_settings.rb @@ -16,7 +16,7 @@ rescue LoadError => e load rb_file if File.exist?(rb_file) || raise(e) end -# These will be nil if Puppet is not available. +# Facter fact returns the value of the Puppet vardir Facter.add(:puppet_vardir) do setcode do Facter::Util::PuppetSettings.with_puppet do @@ -25,6 +25,7 @@ Facter.add(:puppet_vardir) do end end +# Facter fact returns the value of the Puppet environment path Facter.add(:puppet_environmentpath) do setcode do Facter::Util::PuppetSettings.with_puppet do @@ -33,6 +34,7 @@ Facter.add(:puppet_environmentpath) do end end +# Facter fact returns the value of the Puppet server Facter.add(:puppet_server) do setcode do Facter::Util::PuppetSettings.with_puppet do diff --git a/3rdparty/modules/stdlib/lib/facter/root_home.rb b/3rdparty/modules/stdlib/lib/facter/root_home.rb index d4add7b4d..7544dd09e 100644 --- a/3rdparty/modules/stdlib/lib/facter/root_home.rb +++ b/3rdparty/modules/stdlib/lib/facter/root_home.rb @@ -1,8 +1,11 @@ -# A facter fact to determine the root home directory. -# This varies on PE supported platforms and may be -# reconfigured by the end user. +# root_home.rb module Facter::Util::RootHome + # @summary + # A facter fact to determine the root home directory. + # This varies on PE supported platforms and may be + # reconfigured by the end user. class << self + # determines the root home directory def returnt_root_home root_ent = Facter::Util::Resolution.exec('getent passwd root') # The home directory is the sixth element in the passwd entry diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb b/3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb index af6109d9d..2f6b0c0ed 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/deprecation.rb @@ -1,10 +1,16 @@ -# Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. -# The msg is the message text including any positional information that is formatted by the user/caller of the method. -# It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), -# :off (no message / error is displayed) and :warning (default, outputs a warning) *Type*: String, String. +# Function to print deprecation warnings, Logs a warning once for a given key. +# +# The uniqueness key - can appear once. +# The msg is the message text including any positional information that is formatted by the +# user/caller of the method. +# It is affected by the puppet setting 'strict', which can be set to :error +# (outputs as an error message), :off (no message / error is displayed) and :warning +# (default, outputs a warning) *Type*: String, String. # - Puppet::Functions.create_function(:deprecation) do + # @param key + # @param message + # @return deprecated warnings dispatch :deprecation do param 'String', :key param 'String', :message diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/fact.rb b/3rdparty/modules/stdlib/lib/puppet/functions/fact.rb index 48736ad3f..c963d1665 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/fact.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/fact.rb @@ -1,19 +1,25 @@ -# Digs into the facts hash using dot-notation +# @summary +# Digs into the facts hash using dot-notation # -# Example usage: +# Supports the use of dot-notation for referring to structured facts. If a fact requested +# does not exist, returns Undef. # +# @example Example usage: # fact('osfamily') # fact('os.architecture') # -# Array indexing: -# +# @example Array indexing: # fact('mountpoints."/dev".options.1') # -# Fact containing a "." in the name: -# +# @example Fact containing a "." in the name: # fact('vmware."VRA.version"') # Puppet::Functions.create_function(:fact) do + # @param fact_name + # The name of the fact to check + # + # @return + # All information retrieved on the given fact_name dispatch :fact do param 'String', :fact_name end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb index 24b97441c..0302df92d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_a.rb @@ -1,25 +1,35 @@ -# Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. +# @summary +# Boolean check to determine whether a variable is of a given data type. +# This is equivalent to the `=~` type checks. # -# @example how to check a data type +# @example Example Usage: # # check a data type -# foo = 3 -# $bar = [1,2,3] -# $baz = 'A string!' +# foo = 3 +# $bar = [1,2,3] +# $baz = 'A string!' # -# if $foo.is_a(Integer) { -# notify { 'foo!': } -# } -# if $bar.is_a(Array) { -# notify { 'bar!': } -# } -# if $baz.is_a(String) { -# notify { 'baz!': } -# } +# if $foo.is_a(Integer) { +# notify { 'foo!': } +# } +# if $bar.is_a(Array) { +# notify { 'bar!': } +# } +# if $baz.is_a(String) { +# notify { 'baz!': } +# } # # See the documentation for "The Puppet Type System" for more information about types. # See the `assert_type()` function for flexible ways to assert the type of a value. # Puppet::Functions.create_function(:is_a) do + # @param value + # The value to be checked + # + # @param type + # The expected type + # + # @return [Boolean] + # Return's `true` or `false`. dispatch :is_a do param 'Any', :value param 'Type', :type diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb index c9d92ebd7..0dfc581e7 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_absolute_path.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_absolute_path) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb index fdc60dd5d..5e8d08df8 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_array.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_array) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb index 1672f0a3d..fb40230d1 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_bool.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_bool) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb index 03e94d3a4..e15d3e4c7 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_float.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_float) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb index 1ab67e7a7..92e556461 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_ip_address.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_ip_address) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb index 034f9ba10..bd5b11eca 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv4_address.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_ipv4_address) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb index c8fb3ab67..5d3d0e3b1 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_ipv6_address.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_ipv6_address) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb index 79a6bbf82..32dc63140 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_numeric.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_numeric) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolea] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb b/3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb index a32216c05..a112efdd3 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/is_string.rb @@ -1,4 +1,14 @@ +# @summary +# Wrapper that calls the Puppet 3.x funtion of the same name. Puppet::Functions.create_function(:is_string) do + # @param scope + # The main value that will be passed to the wrapped method + # + # @param args + # Any additional values that are to be passed to the wrapped method + # + # @return [Boolean] + # A boolean value returned from the called 3.x function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/length.rb b/3rdparty/modules/stdlib/lib/puppet/functions/length.rb index ccd662a16..9a163deaf 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/length.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/length.rb @@ -1,10 +1,18 @@ -# A function to eventually replace the old size() function for stdlib -# The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution. +# @summary +# **Deprecated:** A function to eventually replace the old size() function for stdlib # -# Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core -# will be used instead of this function. +# The original size() function did not handle Puppets new type capabilities, so this function +# is a Puppet 4 compatible solution. +# +# > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a +# built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function. # Puppet::Functions.create_function(:length) do + # @param value + # The value whose length is to be found + # + # @return [Integer] + # The length of the given object dispatch :length do param 'Variant[String,Array,Hash]', :value end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/merge.rb b/3rdparty/modules/stdlib/lib/puppet/functions/merge.rb new file mode 100644 index 000000000..dd65cbc4c --- /dev/null +++ b/3rdparty/modules/stdlib/lib/puppet/functions/merge.rb @@ -0,0 +1,110 @@ +# @summary +# Merges two or more hashes together or hashes resulting from iteration, and returns +# the resulting hash. +# +# @example Using merge() +# $hash1 = {'one' => 1, 'two', => 2} +# $hash2 = {'two' => 'dos', 'three', => 'tres'} +# $merged_hash = merge($hash1, $hash2) # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} +# +# When there is a duplicate key, the key in the rightmost hash will "win." +# +# Note that since Puppet 4.0.0 the same merge can be achieved with the + operator. +# `$merged_hash = $hash1 + $hash2` +# +# If merge is given a single Iterable (Array, Hash, etc.) it will call a given block with +# up to three parameters, and merge each resulting Hash into the accumulated result. All other types +# of values returned from the block (typically undef) are skipped (not merged). +# +# The codeblock can take 2 or three parameters: +# * with two, it gets the current hash (as built to this point), and each value (for hash the value is a [key, value] tuple) +# * with three, it gets the current hash (as built to this point), the key/index of each value, and then the value +# +# If the iterable is empty, or no hash was returned from the given block, an empty hash is returned. In the given block, a call to `next()` +# will skip that entry, and a call to `break()` will end the iteration. +# +# @example counting occurrences of strings in an array +# ['a', 'b', 'c', 'c', 'd', 'b'].merge | $hsh, $v | { { $v => $hsh[$v].lest || { 0 } + 1 } } # results in { a => 1, b => 2, c => 2, d => 1 } +# +# @example skipping values for entries that are longer than 1 char +# ['a', 'b', 'c', 'c', 'd', 'b', 'blah', 'blah'].merge | $hsh, $v | { if $v =~ String[1,1] { { $v => $hsh[$v].lest || { 0 } + 1 } } } # results in { a => 1, b => 2, c => 2, d => 1 } +# +# The iterative `merge()` has an advantage over doing the same with a general `reduce()` in that the constructed hash +# does not have to be copied in each iteration and thus will perform much better with large inputs. +Puppet::Functions.create_function(:merge) do + # @param args + # Repeated Param - The hashes that are to be merged + # + # @return + # The merged hash + dispatch :merge2hashes do + repeated_param 'Variant[Hash, Undef, String[0,0]]', :args # this strange type is backwards compatible + return_type 'Hash' + end + + # @param args + # Repeated Param - The hashes that are to be merged + # + # @param block + # A block placed on the repeatable param `args` + # + # @return + # The merged hash + dispatch :merge_iterable3 do + repeated_param 'Iterable', :args + block_param 'Callable[3,3]', :block + return_type 'Hash' + end + + # @param args + # Repeated Param - The hashes that are to be merged + # + # @param block + # A block placed on the repeatable param `args` + # + # @return + # The merged hash + dispatch :merge_iterable2 do + repeated_param 'Iterable', :args + block_param 'Callable[2,2]', :block + return_type 'Hash' + end + + def merge2hashes(*hashes) + accumulator = {} + hashes.each { |h| accumulator.merge!(h) if h.is_a?(Hash) } + accumulator + end + + def merge_iterable2(iterable) + accumulator = {} + enum = Puppet::Pops::Types::Iterable.asserted_iterable(self, iterable) + enum.each do |v| + r = yield(accumulator, v) + accumulator.merge!(r) if r.is_a?(Hash) + end + accumulator + end + + def merge_iterable3(iterable) + accumulator = {} + enum = Puppet::Pops::Types::Iterable.asserted_iterable(self, iterable) + if enum.hash_style? + enum.each do |entry| + r = yield(accumulator, *entry) + accumulator.merge!(r) if r.is_a?(Hash) + end + else + begin + index = 0 + loop do + r = yield(accumulator, index, enum.next) + accumulator.merge!(r) if r.is_a?(Hash) + index += 1 + end + rescue StopIteration # rubocop:disable Lint/HandleExceptions + end + end + accumulator + end +end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/os_version_gte.rb b/3rdparty/modules/stdlib/lib/puppet/functions/os_version_gte.rb index e3089a858..7ab095e82 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/os_version_gte.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/os_version_gte.rb @@ -1,11 +1,16 @@ -# Checks if the OS version is at least a certain version. Note that only the -# major version is taken into account. -# -# Example usage: +# @summary +# Checks if the OS version is at least a certain version. +# > *Note:* +# Only the major version is taken into account. # +# @example Example usage:# # if os_version_gte('Debian', '9') { } # if os_version_gte('Ubuntu', '18.04') { } Puppet::Functions.create_function(:os_version_gte) do + # @param os operating system + # @param version + # + # @return [Boolean] `true` or `false dispatch :os_version_gte do param 'String[1]', :os param 'String[1]', :version diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/seeded_rand_string.rb b/3rdparty/modules/stdlib/lib/puppet/functions/seeded_rand_string.rb index f3d1dcc4f..63cb2f83c 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/seeded_rand_string.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/seeded_rand_string.rb @@ -1,4 +1,5 @@ -# Generates a consistent random string of specific length based on provided seed. +# @summary +# Generates a consistent random string of specific length based on provided seed. # # @example Generate a consistently random string of length 8 with a seed: # seeded_rand_string(8, "${module_name}::redis_password") diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/sprintf_hash.rb b/3rdparty/modules/stdlib/lib/puppet/functions/sprintf_hash.rb index 732673a6f..ddf82b55b 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/sprintf_hash.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/sprintf_hash.rb @@ -1,4 +1,5 @@ -# Uses sprintf with named references. +# @summary +# Uses sprintf with named references. # # The first parameter is format string describing how the rest of the parameters in the hash # should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/extname.rb b/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/extname.rb index 3818ef85d..120b46b22 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/extname.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/extname.rb @@ -1,12 +1,12 @@ -# Returns the Extension (the Portion of Filename in Path starting from the -# last Period). +# @summary +# Returns the Extension (the Portion of Filename in Path starting from the +# last Period). # # If Path is a Dotfile, or starts with a Period, then the starting Dot is not # dealt with the Start of the Extension. # # An empty String will also be returned, when the Period is the last Character # in Path. - Puppet::Functions.create_function(:'stdlib::extname') do # @param filename The Filename # @return [String] The Extension starting from the last Period diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/ip_in_range.rb b/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/ip_in_range.rb new file mode 100644 index 000000000..46fc44548 --- /dev/null +++ b/3rdparty/modules/stdlib/lib/puppet/functions/stdlib/ip_in_range.rb @@ -0,0 +1,30 @@ +# @summary +# Returns true if the ipaddress is within the given CIDRs +# +# @example ip_in_range(, ) +# stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true +Puppet::Functions.create_function(:'stdlib::ip_in_range') do + # @param ipaddress The IP address to check + # @param range One CIDR or an array of CIDRs + # defining the range(s) to check against + # + # @return [Boolean] True or False + dispatch :ip_in_range do + param 'String', :ipaddress + param 'Variant[String, Array]', :range + return_type 'Boolean' + end + + require 'ipaddr' + def ip_in_range(ipaddress, range) + ip = IPAddr.new(ipaddress) + + if range.is_a? Array + ranges = range.map { |r| IPAddr.new(r) } + ranges.any? { |rng| rng.include?(ip) } + elsif range.is_a? String + ranges = IPAddr.new(range) + ranges.include?(ip) + end + end +end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/to_json.rb b/3rdparty/modules/stdlib/lib/puppet/functions/to_json.rb index 782d695bd..20d39e76f 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/to_json.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/to_json.rb @@ -1,4 +1,6 @@ -# Take a data structure and output it as JSON +require 'json' +# @summary +# Convert a data structure and output to JSON # # @example how to output JSON # # output json to a file @@ -7,10 +9,10 @@ # content => to_json($myhash), # } # -# -require 'json' - Puppet::Functions.create_function(:to_json) do + # @param data + # data structure which needs to be converted into JSON + # @return converted data to json dispatch :to_json do param 'Any', :data end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb b/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb index a7a145825..6a5a8222d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/to_json_pretty.rb @@ -1,14 +1,15 @@ -# Take a data structure and output it as pretty JSON +require 'json' +# @summary +# Convert data structure and output to pretty JSON # -# @example how to output pretty JSON -# # output pretty json to a file +# @example **Usage** +# * how to output pretty JSON to file # file { '/tmp/my.json': # ensure => file, # content => to_json_pretty($myhash), # } # -# @example how to output pretty JSON skipping over keys with undef values -# # output pretty JSON to a file skipping over undef values +# * how to output pretty JSON skipping over keys with undef values # file { '/tmp/my.json': # ensure => file, # content => to_json_pretty({ @@ -16,10 +17,13 @@ # param_two => undef, # }), # } -# -require 'json' - Puppet::Functions.create_function(:to_json_pretty) do + # @param data + # data structure which needs to be converted to pretty json + # @param skip_undef + # value `true` or `false` + # @return + # converted data to pretty json dispatch :to_json_pretty do param 'Variant[Hash, Array]', :data optional_param 'Boolean', :skip_undef diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/to_yaml.rb b/3rdparty/modules/stdlib/lib/puppet/functions/to_yaml.rb index fdd737045..d5fe2592e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/to_yaml.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/to_yaml.rb @@ -1,4 +1,6 @@ -# Take a data structure and output it as YAML +require 'yaml' +# @summary +# Convert a data structure and output it as YAML # # @example how to output YAML # # output yaml to a file @@ -6,11 +8,10 @@ # ensure => file, # content => to_yaml($myhash), # } -# -# -require 'yaml' - Puppet::Functions.create_function(:to_yaml) do + # @param data + # + # @return [String] dispatch :to_yaml do param 'Any', :data end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/type_of.rb b/3rdparty/modules/stdlib/lib/puppet/functions/type_of.rb index 5bed6d5a5..e74565932 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/type_of.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/type_of.rb @@ -1,4 +1,5 @@ -# Returns the type when passed a value. +# @summary +# Returns the type of the passed value. # # @example how to compare values' types # # compare the types of two values @@ -13,6 +14,10 @@ # The built-in type() function in puppet is generally preferred over this function # this function is provided for backwards compatibility. Puppet::Functions.create_function(:type_of) do + # @return [String] + # the type of the passed value + # + # @param value def type_of(value) Puppet::Pops::Types::TypeCalculator.infer_set(value) end diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb index 44f600fd9..ed7f07004 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_absolute_path.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the string represents an absolute path in the filesystem. Puppet::Functions.create_function(:validate_absolute_path) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb index 2bedd3fee..217df762f 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_array.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents an array. Puppet::Functions.create_function(:validate_array) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return + # A boolean value (`true` or `false`) returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb index 907eed371..85892ddad 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_bool.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents a boolean. Puppet::Functions.create_function(:validate_bool) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb index c6a61a4bd..5efa25fe7 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_hash.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents a hash. Puppet::Functions.create_function(:validate_hash) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return + # A boolean value (`true` or `false`) returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb index 487dcf725..7de789ece 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_integer.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents an integer. Puppet::Functions.create_function(:validate_integer) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb index 68e7f7f88..233f083d4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ip_address.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents an ip_address. Puppet::Functions.create_function(:validate_ip_address) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb index caeeacaa9..799f60894 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv4_address.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents an ipv4_address. Puppet::Functions.create_function(:validate_ipv4_address) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb index c0353571a..b51464254 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_ipv6_address.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents an ipv6_address. Puppet::Functions.create_function(:validate_ipv6_address) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb index 21646ade3..1e1621924 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_legacy.rb @@ -1,6 +1,16 @@ +# @summary +# Validate a value against both the target_type (new) and the previous_validation function (old). Puppet::Functions.create_function(:validate_legacy) do # The function checks a value against both the target_type (new) and the previous_validation function (old). - + # @param scope + # The main value that will be passed to the method + # @param target_type + # @param function_name + # @param value + # @param args + # Any additional values that are to be passed to the method + # @return + # A boolean value (`true` or `false`) returned from the called function. dispatch :validate_legacy do param 'Any', :scope param 'Type', :target_type @@ -9,6 +19,14 @@ Puppet::Functions.create_function(:validate_legacy) do repeated_param 'Any', :args end + # @param scope + # The main value that will be passed to the method + # @param type_string + # @param function_name + # @param value + # @param args Any additional values that are to be passed to the method + # @return Legacy validation method + # dispatch :validate_legacy_s do param 'Any', :scope param 'String', :type_string diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb index 3adb0a87b..f98fa7463 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_numeric.rb @@ -1,4 +1,14 @@ +# @summary +# Validate the passed value represents a numeric value. Puppet::Functions.create_function(:validate_numeric) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb index d357aab31..d1695df56 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_re.rb @@ -1,4 +1,19 @@ +# @summary +# Perform validation of a string against one or more regular +# expressions. +# Puppet::Functions.create_function(:validate_re) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # The first argument of this function should be a string to + # test, and the second argument should be a stringified regular expression + # (without the // delimiters) or an array of regular expressions + # + # @return [Boolean] + # `true` or `false` returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb index ad6f7b3ad..aa4143ba9 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_slength.rb @@ -1,4 +1,13 @@ +# Validate that a passed string has length less/equal with the passed value Puppet::Functions.create_function(:validate_slength) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb b/3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb index a908c1974..50b1dafbc 100644 --- a/3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb +++ b/3rdparty/modules/stdlib/lib/puppet/functions/validate_string.rb @@ -1,4 +1,14 @@ +# @summary +# Validate that all passed values are string data structures. Puppet::Functions.create_function(:validate_string) do + # @param scope + # The main value that will be passed to the method + # + # @param args + # Any additional values that are to be passed to the method + # + # @return [Boolean] `true` or `false` + # A boolean value returned from the called function. dispatch :deprecation_gen do param 'Any', :scope repeated_param 'Any', :args diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/abs.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/abs.rb index 59e468e98..5625b984c 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/abs.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/abs.rb @@ -3,11 +3,18 @@ # module Puppet::Parser::Functions newfunction(:abs, :type => :rvalue, :doc => <<-DOC - Returns the absolute value of a number, for example -34.56 becomes - 34.56. Takes a single integer and float value as an argument. + @summary + **Deprecated:** Returns the absolute value of a number + + For example -34.56 becomes 34.56. + Takes a single integer or float value as an argument. + + > *Note:* + **Deprected** from Puppet 6.0.0, the built-in + ['abs'](https://puppet.com/docs/puppet/6.4/function.html#abs)function will be used instead. + + @return The absolute value of the given number if it was an Integer - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb index 8358a6f64..b45e5b50b 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2array.rb @@ -3,26 +3,35 @@ # module Puppet::Parser::Functions newfunction(:any2array, :type => :rvalue, :doc => <<-DOC - This converts any object to an array containing that object. Empty argument - lists are converted to an empty array. Arrays are left untouched. Hashes are - converted to arrays of alternating keys and values. + @summary + This converts any object to an array containing that object. - Note that since Puppet 5.0.0 it is possible to create new data types for almost any - datatype using the type system and the built-in - [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) - function is used to create a new Array.. + Empty argument lists are converted to an empty array. Arrays are left + untouched. Hashes are converted to arrays of alternating keys and values. - $hsh = {'key' => 42, 'another-key' => 100} - notice(Array($hsh)) + > *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple) + function is used to create a new Array.. + + ``` + $hsh = {'key' => 42, 'another-key' => 100} + notice(Array($hsh)) + ``` Would notice `[['key', 42], ['another-key', 100]]` The Array data type also has a special mode to "create an array if not already an array" - notice(Array({'key' => 42, 'another-key' => 100}, true)) + ``` + notice(Array({'key' => 42, 'another-key' => 100}, true)) + ``` Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being transformed into an array. + + @return [Array] The new array containing the given object DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb index 8f6d5d81a..c4b20d674 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/any2bool.rb @@ -3,8 +3,10 @@ # module Puppet::Parser::Functions newfunction(:any2bool, :type => :rvalue, :doc => <<-DOC - This converts 'anything' to a boolean. In practise it does the following: + @summary + Converts 'anything' to a boolean. + In practise it does the following: * Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true * Strings such as 0,F,f,N,n,FALSE,no,'false' will return false * Booleans will just return their original value @@ -14,6 +16,8 @@ module Puppet::Parser::Functions Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean) function. + + @return [Boolean] The boolean value of the object that was given DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/assert_private.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/assert_private.rb index 9cdebb94e..4f1a5e26c 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/assert_private.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/assert_private.rb @@ -3,7 +3,12 @@ # module Puppet::Parser::Functions newfunction(:assert_private, :doc => <<-DOC - Sets the current class or definition as private. + @summary + Sets the current class or definition as private. + + @return + set the current class or definition as private. + Calling the class or definition from outside the current module will fail. DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb index d77db8bbf..45e1fdbc5 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/base64.rb @@ -1,27 +1,36 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. module Puppet::Parser::Functions - newfunction(:base64, :type => :rvalue, :doc => <<-'DOC') do |args| - Base64 encode or decode a string based on the command and the string submitted + newfunction(:base64, :type => :rvalue, :doc => <<-DOC) do |args| + @summary + Base64 encode or decode a string based on the command and the string submitted - Usage: + @example Example usage - $encodestring = base64('encode', 'thestring') - $decodestring = base64('decode', 'dGhlc3RyaW5n') + Encode and decode a string - # explicitly define encode/decode method: default, strict, urlsafe - $method = 'default' - $encodestring = base64('encode', 'thestring', $method) - $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) + $encodestring = base64('encode', 'thestring') + $decodestring = base64('decode', 'dGhlc3RyaW5n') - Note: Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings. - See the `new()` function for the Binary and String types for documentation. Also see `binary_file()` - function for reading a file with binary (non UTF-8) content. + Explicitly define encode/decode method: default, strict, urlsafe + + $method = 'default' + $encodestring = base64('encode', 'thestring', $method) + $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) + + Encode a string as if it was binary - # encode a string as if it was binary $encodestring = String(Binary('thestring', '%s')) - # decode a Binary assuming it is an UTF-8 String + + Decode a Binary assuming it is an UTF-8 String + $decodestring = String(Binary("dGhlc3RyaW5n"), "%s") + > **Note:* + Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings. + See the `new()` function for the Binary and String types for documentation. Also see `binary_file()` + function for reading a file with binary (non UTF-8) content. + + @return [String] The encoded/decoded value DOC require 'base64' diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/basename.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/basename.rb index b717fa19c..e247e566a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/basename.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/basename.rb @@ -3,7 +3,10 @@ # module Puppet::Parser::Functions newfunction(:basename, :type => :rvalue, :doc => <<-DOC - Strips directory (and optional suffix) from a filename + @summary + Strips directory (and optional suffix) from a filename + + @return [String] The stripped filename DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2num.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2num.rb index 115467e76..bafe0bd43 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2num.rb @@ -3,20 +3,29 @@ # module Puppet::Parser::Functions newfunction(:bool2num, :type => :rvalue, :doc => <<-DOC - Converts a boolean to a number. Converts the values: + @summary + Converts a boolean to a number. + + Converts the values: + ``` false, f, 0, n, and no to 0 true, t, 1, y, and yes to 1 + ``` Requires a single boolean or string as an input. - Note that since Puppet 5.0.0 it is possible to create new data types for almost any - datatype using the type system and the built-in - [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric), - [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and - [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float) - function are used to convert to numeric values. + > *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric), + [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and + [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float) + function are used to convert to numeric values. + ``` + notice(Integer(false)) # Notices 0 + notice(Float(true)) # Notices 1.0 + ``` - notice(Integer(false)) # Notices 0 - notice(Float(true)) # Notices 1.0 + @return [Integer] The converted value as a number DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2str.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2str.rb index be25e0a18..f55fcd835 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2str.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2str.rb @@ -3,29 +3,38 @@ # module Puppet::Parser::Functions newfunction(:bool2str, :type => :rvalue, :doc => <<-DOC - Converts a boolean to a string using optionally supplied arguments. The - optional second and third arguments represent what true and false will be + @summary + Converts a boolean to a string using optionally supplied arguments. + + The optional second and third arguments represent what true and false will be converted to respectively. If only one argument is given, it will be converted from a boolean to a string containing 'true' or 'false'. - *Examples:* + @return + The converted value to string of the given Boolean + + **Examples of usage** - bool2str(true) => 'true' - bool2str(true, 'yes', 'no') => 'yes' - bool2str(false, 't', 'f') => 'f' + ``` + bool2str(true) => 'true' + bool2str(true, 'yes', 'no') => 'yes' + bool2str(false, 't', 'f') => 'f' + ``` Requires a single boolean as an input. - Note that since Puppet 5.0.0 it is possible to create new data types for almost any - datatype using the type system and the built-in - [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string) - function is used to convert to String with many different format options. + > *Note:* + since Puppet 5.0.0 it is possible to create new data types for almost any + datatype using the type system and the built-in + [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string) + function is used to convert to String with many different format options. + ``` notice(String(false)) # Notices 'false' notice(String(true)) # Notices 'true' notice(String(false, '%y')) # Notices 'yes' notice(String(true, '%y')) # Notices 'no' - + ``` DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/camelcase.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/camelcase.rb index 3c887e26b..ad1068b3f 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/camelcase.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/camelcase.rb @@ -4,10 +4,16 @@ # module Puppet::Parser::Functions newfunction(:camelcase, :type => :rvalue, :doc => <<-DOC - Converts the case of a string or all strings in an array to camel case. + @summary + **Deprecated** Converts the case of a string or all strings in an array to camel case. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with + a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase) + function. + + @return [String] The converted String, if it was a String that was given + @return [Array[String]] The converted Array, if it was a Array that was given DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/capitalize.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/capitalize.rb index 2493bc838..ffc4d1386 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/capitalize.rb @@ -4,11 +4,18 @@ # module Puppet::Parser::Functions newfunction(:capitalize, :type => :rvalue, :doc => <<-DOC - Capitalizes the first letter of a string or array of strings. + @summary + **Deprecated** Capitalizes the first letter of a string or array of strings. + Requires either a single string or an array as an input. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* + **Deprecated** from Puppet 6.0.0, yhis function has been replaced with a + built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize) + function. + + @return [String] The converted String, if it was a String that was given + @return [Array[String]] The converted Array, if it was a Array that was given DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ceiling.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ceiling.rb index fe4b76836..ea50e880c 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ceiling.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ceiling.rb @@ -3,11 +3,15 @@ # module Puppet::Parser::Functions newfunction(:ceiling, :type => :rvalue, :doc => <<-DOC - Returns the smallest integer greater or equal to the argument. + @summary + **Deprecated** Returns the smallest integer greater or equal to the argument. Takes a single numeric value as an argument. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function. + + @return [Integer] The rounded value DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/chomp.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/chomp.rb index b7b309c07..c917d580a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/chomp.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/chomp.rb @@ -3,12 +3,18 @@ # module Puppet::Parser::Functions newfunction(:chomp, :type => :rvalue, :doc => <<-DOC - Removes the record separator from the end of a string or an array of - strings, for example `hello\n` becomes `hello`. + @summary + **Deprecated** Removes the record separator from the end of a string or an array of strings. + + For example `hello\n` becomes `hello`. Requires a single string or array as an input. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* + **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function. + + @return [String] The converted String, if it was a String that was given + @return [Array[String]] The converted Array, if it was a Array that was given DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/chop.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/chop.rb index 39a9ee774..69b5f3ffc 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/chop.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/chop.rb @@ -3,14 +3,18 @@ # module Puppet::Parser::Functions newfunction(:chop, :type => :rvalue, :doc => <<-DOC - Returns a new string with the last character removed. If the string ends - with `\r\n`, both characters are removed. Applying chop to an empty - string returns an empty string. If you wish to merely remove record - separators then you should use the `chomp` function. + @summary + **Deprecated** Returns a new string with the last character removed. + + If the string ends with `\r\n`, both characters are removed. Applying + chop to an empty string returns an empty string. If you wish to merely + remove record separators then you should use the `chomp` function. Requires a string or array of strings as input. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function. + + @return [String] The given String, sans the last character. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb index cbc67dc95..1b6e2d292 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/clamp.rb @@ -3,10 +3,24 @@ # module Puppet::Parser::Functions newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-DOC - Clamps value to a range. + @summary + Keeps value within the range [Min, X, Max] by sort based on integer value + (parameter order doesn't matter). - Note: From Puppet 6.0.0 this can be done with only core Puppet like this: - [$minval, $maxval, $value_to_clamp].sort[1] + Strings are converted and compared numerically. Arrays of values are flattened + into a list for further handling. + + @example Example usage + + clamp('24', [575, 187])` returns 187. + clamp(16, 88, 661)` returns 88. + clamp([4, 3, '99'])` returns 4. + + > *Note:* + From Puppet 6.0.0 this can be done with only core Puppet like this: + `[$minval, $maxval, $value_to_clamp].sort[1]` + + @return [Array[Integer]] The sorted Array DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/concat.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/concat.rb index 136f402a4..d3c2e2433 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/concat.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/concat.rb @@ -3,19 +3,23 @@ # module Puppet::Parser::Functions newfunction(:concat, :type => :rvalue, :doc => <<-DOC - Appends the contents of multiple arrays into array 1. + @summary + Appends the contents of multiple arrays into array 1. - *Example:* + @example Example usage - concat(['1','2','3'],['4','5','6'],['7','8','9']) + concat(['1','2','3'],'4') returns ['1','2','3','4'] + concat(['1','2','3'],'4',['5','6','7']) returns ['1','2','3','4','5','6','7'] - Would result in: + > *Note:* + Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and + merge of hashes, and the `<<`` operator for appending: - ['1','2','3','4','5','6','7','8','9'] + `['1','2','3'] + ['4','5','6'] + ['7','8','9']` returns `['1','2','3','4','5','6','7','8','9']` + `[1, 2, 3] << 4` returns `[1, 2, 3, 4]` + `[1, 2, 3] << [4, 5]` returns `[1, 2, 3, [4, 5]]` - Note: Since Puppet 4.0 concatenation of arrays and hashes can be done with the + operator. - - ['1','2','3'] + ['4','5','6'] + ['7','8','9'] + @return [Array] The single concatenated array DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb index da5ff2690..3e4c89fa8 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/convert_base.rb @@ -3,18 +3,28 @@ # module Puppet::Parser::Functions newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'DOC') do |args| - Converts a given integer or base 10 string representing an integer to a specified base, as a string. + @summary + Converts a given integer or base 10 string representing an integer to a + specified base, as a string. - Usage: + @return + converted value as a string - $binary_repr = convert_base(5, 2) # $binary_repr is now set to "101" - $hex_repr = convert_base("254", "16") # $hex_repr is now set to "fe" + @example Example usage - Note: Since Puppet 4.5.0 this can be done with String.new() and its many formatting options: + convert_base(5, 2)` results in: `'101'` + convert_base('254', '16')` results in: `'fe'` - $binary_repr = String(5, '%b') # results in "101" - $hex_repr = String(254, "%x") # results in "fe" - $hex_repr = String(254, "%#x") # results in "0xfe" + > *Note:* + Since Puppet 4.5.0 this can be done with the built-in + [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string) + function and its many formatting options: + + `$binary_repr = String(5, '%b')` return `"101"` + `$hex_repr = String(254, "%x")` return `"fe"` + `$hex_repr = String(254, "%#x")` return `"0xfe"` + + @return [String] The converted value as a String DOC raise Puppet::ParseError, 'convert_base(): First argument must be either a string or an integer' unless args[0].is_a?(Integer) || args[0].is_a?(String) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/count.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/count.rb index 71999a8cf..c302aa196 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/count.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/count.rb @@ -3,21 +3,26 @@ # module Puppet::Parser::Functions newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-DOC - Takes an array as first argument and an optional second argument. - Count the number of elements in array that is equal to the second argument. + @summary + Counts the number of elements in array. + + Takes an array as first argument and an optional second argument. Counts the number of elements in array that is equal to the second argument. If called with only an array, it counts the number of elements that are not nil/undef/empty-string. - Note: equality is tested with a Ruby method and it is therefore subject to what Ruby considers - to be equal. For strings this means that equality is case sensitive. + > *Note:* + equality is tested with a Ruby method and it is therefore subject to what Ruby considers + to be equal. For strings this means that equality is case sensitive. In Puppet core, counting can be done in general by using a combination of the core functions filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib). + Example below shows counting values that are not undef. - notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length) + ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)``` Would notice the value 2. + @return [Integer] The amount of elements counted within the array DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb index dd70c6178..bf62576cf 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb @@ -3,19 +3,23 @@ # module Puppet::Parser::Functions newfunction(:deep_merge, :type => :rvalue, :doc => <<-'DOC') do |args| - Recursively merges two or more hashes together and returns the resulting hash. + @summary + Recursively merges two or more hashes together and returns the resulting hash. - For example: + @example Example usage - $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } - $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } - $merged_hash = deep_merge($hash1, $hash2) - # The resulting hash is equivalent to: - # $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } + $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } + $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } + $merged_hash = deep_merge($hash1, $hash2) - When there is a duplicate key that is a hash, they are recursively merged. - When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." + The resulting hash is equivalent to: + $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } + + When there is a duplicate key that is a hash, they are recursively merged. + When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." + + @return [Hash] The merged hash DOC if args.length < 2 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb index fb0cd8c07..cc2b90a43 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb @@ -3,19 +3,25 @@ require 'puppet/parser/functions' Puppet::Parser::Functions.newfunction(:defined_with_params, :type => :rvalue, - :doc => <<-'DOC' - Takes a resource reference and an optional hash of attributes. + :doc => <<-DOC + @summary + Takes a resource reference and an optional hash of attributes. - Returns true if a resource with the specified attributes has already been added - to the catalog, and false otherwise. + Returns `true` if a resource with the specified attributes has already been added + to the catalog, and `false` otherwise. - user { 'dan': - ensure => present, - } + ``` + user { 'dan': + ensure => present, + } - if ! defined_with_params(User[dan], {'ensure' => 'present' }) { - user { 'dan': ensure => present, } - } + if ! defined_with_params(User[dan], {'ensure' => 'present' }) { + user { 'dan': ensure => present, } + } + ``` + + @return [Boolean] + returns `true` or `false` DOC ) do |vals| reference, params = vals diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete.rb index d3fddd85b..bf614f773 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete.rb @@ -3,38 +3,47 @@ # module Puppet::Parser::Functions newfunction(:delete, :type => :rvalue, :doc => <<-DOC - Deletes all instances of a given element from an array, substring from a - string, or key from a hash. + @summary + Deletes all instances of a given element from an array, substring from a + string, or key from a hash. - *Examples:* + @example Example usage - delete(['a','b','c','b'], 'b') - Would return: ['a','c'] + delete(['a','b','c','b'], 'b') + Would return: ['a','c'] - delete({'a'=>1,'b'=>2,'c'=>3}, 'b') - Would return: {'a'=>1,'c'=>3} + delete({'a'=>1,'b'=>2,'c'=>3}, 'b') + Would return: {'a'=>1,'c'=>3} - delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c']) - Would return: {'a'=>1} + delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c']) + Would return: {'a'=>1} - delete('abracadabra', 'bra') - Would return: 'acada' + delete('abracadabra', 'bra') + Would return: 'acada' - Note that from Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash: + ['a', 'b', 'c', 'b'] - 'b' + Would return: ['a', 'c'] - ['a', 'b', 'c', 'b'] - 'b' - # would return ['a', 'c'] + {'a'=>1,'b'=>2,'c'=>3} - ['b','c']) + Would return: {'a' => '1'} - {'a'=>1,'b'=>2,'c'=>3} - ['b','c']) - # would return {'a' => '1'} + 'abracadabra'.regsubst(/bra/, '', 'G') + Would return: 'acada' - A global delete from a string can be performed with the regsubst() function: + > *Note:* + From Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash + `{'a'=>1,'b'=>2,'c'=>3} - ['b','c'])` + > + A global delete from a string can be performed with the + [`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function: + `'abracadabra'.regsubst(/bra/, '', 'G')` - 'abracadabra'.regsubst(/bra/, '', 'G') - # would return 'acada' - - In general, the filter() function can filter out entries from arrays and hashes based on keys and/or values. + In general, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) + function can filter out entries from arrays and hashes based on keys and/or values. + @return [String] The filtered String, if one was given. + @return [Hash] The filtered Hash, if one was given. + @return [Array] The filtered Array, if one was given. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_at.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_at.rb index 0a1a9400b..992d7d8d6 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_at.rb @@ -2,27 +2,32 @@ # delete_at.rb # module Puppet::Parser::Functions - newfunction(:delete_at, :type => :rvalue, :doc => <<-DOC - Deletes a determined indexed value from an array. + newfunction(:delete_at, :type => :rvalue, :doc => <<-DOC) do |arguments| + @summary + Deletes a determined indexed value from an array. - *Examples:* + For example + ```delete_at(['a','b','c'], 1)``` - delete_at(['a','b','c'], 1) + Would return: `['a','c']` - Would return: ['a','c'] + > *Note:* + Since Puppet 4 this can be done in general with the built-in + [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: - Note that since Puppet 4 this can be done in general with the filter function: - - ['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 } + ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }``` Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]: + ``` + $array[0, -1] # the same as all the values + $array[2, -1] # all but the first 2 elements + $array[0, -3] # all but the last 2 elements + $array[1, -2] # all but the first and last element + ``` + + @return [Array] The given array, now missing the target value - $array[0, -1] # the same as all the values - $array[2, -1] # all but the first 2 elements - $array[0, -3] # all but the last 2 elements - $array[1, -2] # all but the first and last element DOC - ) do |arguments| raise(Puppet::ParseError, "delete_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb index 8093896f4..36451919d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_regex.rb @@ -4,30 +4,33 @@ # module Puppet::Parser::Functions newfunction(:delete_regex, :type => :rvalue, :doc => <<-DOC - deletes all instances of a given element that match a regular expression - from an array or key from a hash. Multiple regular expressions are assumed - to be matched as an OR. + @summary + Deletes all instances of a given element that match a regular expression + from an array or key from a hash. - *Examples:* + Multiple regular expressions are assumed to be matched as an OR. - delete_regex(['a','b','c','b'], 'b') - Would return: ['a','c'] + @example Example usage - delete_regex(['a','b','c','b'], ['b', 'c']) - Would return: ['a'] + delete_regex(['a','b','c','b'], 'b') + Would return: ['a','c'] - delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b') - Would return: {'a'=>1,'c'=>3} + delete_regex(['a','b','c','b'], ['b', 'c']) + Would return: ['a'] - delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$') - Would return: {'b'=>2,'c'=>3} + delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b') + Would return: {'a'=>1,'c'=>3} - Note that since Puppet 4 this can be done in general with the filter function: - - ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ } - # Would return: ['aaa', 'aca'] + delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$') + Would return: {'b'=>2,'c'=>3} + > *Note:* + Since Puppet 4 this can be done in general with the built-in + [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: + ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ } + Would return: ['aaa', 'aca'] + @return [Array] The given array now missing all targeted values. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb index 9e0408299..b00f5e4d4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb @@ -3,24 +3,26 @@ # module Puppet::Parser::Functions newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-DOC - Returns a copy of input hash or array with all undefs deleted. + @summary + Returns a copy of input hash or array with all undefs deleted. - *Examples:* + @example Example usage - $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) + $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) + Would return: {a => 'A', b => '', d => false} - Would return: {a => 'A', b => '', d => false} + While: + $array = delete_undef_values(['A','',undef,false]) + Would return: ['A','',false] - $array = delete_undef_values(['A','',undef,false]) + > *Note:* + Since Puppet 4.0.0 the equivalent can be performed with the built-in + [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: + $array.filter |$val| { $val =~ NotUndef } + $hash.filter |$key, $val| { $val =~ NotUndef } - Would return: ['A','',false] - - Note that since Puppet 4.0.0 the equivalent can be performed with the filter() function in Puppet: - - $array.filter |$val| { $val =~ NotUndef } - $hash.filter |$key, $val| { $val =~ NotUndef } - - DOC + @return [Array] The given array now issing of undefined values. + DOC ) do |args| raise(Puppet::ParseError, "delete_undef_values(): Wrong number of arguments given (#{args.size})") if args.empty? diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_values.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_values.rb index f98f247f9..f1625228a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_values.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/delete_values.rb @@ -3,20 +3,22 @@ # module Puppet::Parser::Functions newfunction(:delete_values, :type => :rvalue, :doc => <<-DOC - Deletes all instances of a given value from a hash. + @summary + Deletes all instances of a given value from a hash. - *Examples:* + @example Example usage - delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B') + delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B') + Would return: {'a'=>'A','c'=>'C','B'=>'D'} - Would return: {'a'=>'A','c'=>'C','B'=>'D'} + > *Note:* + Since Puppet 4.0.0 the equivalent can be performed with the + built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function: + $array.filter |$val| { $val != 'B' } + $hash.filter |$key, $val| { $val != 'B' } - Note that since Puppet 4.0.0 the equivalent can be performed with the filter() function in Puppet: - - $array.filter |$val| { $val != 'B' } - $hash.filter |$key, $val| { $val != 'B' } - - DOC + @return [Hash] The given hash now missing all instances of the targeted value + DOC ) do |arguments| raise(Puppet::ParseError, "delete_values(): Wrong number of arguments given (#{arguments.size} of 2)") if arguments.size != 2 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb index 01f0deb1c..2a39cc379 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/deprecation.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:deprecation, :doc => <<-DOC - Function to print deprecation warnings (this is the 3.X version of it), The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method.). + @summary + Function to print deprecation warnings (this is the 3.X version of it). + + The uniqueness key - can appear once. The msg is the message text including any positional + information that is formatted by the user/caller of the method.). + + @return [String] + return deprecation warnings DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/difference.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/difference.rb index 360c1e307..49e867371 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/difference.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/difference.rb @@ -3,20 +3,24 @@ # module Puppet::Parser::Functions newfunction(:difference, :type => :rvalue, :doc => <<-DOC - This function returns the difference between two arrays. + @summary + This function returns the difference between two arrays. + The returned array is a copy of the original array, removing any items that also appear in the second array. - *Examples:* - - difference(["a","b","c"],["b","c","d"]) + @example Example usage - Would return: ["a"] + difference(["a","b","c"],["b","c","d"]) + Would return: `["a"]` - Note: Since Puppet 4 the minus (-) operator in the Puppet language does the same thing: + > *Note:* + Since Puppet 4 the minus (-) operator in the Puppet language does the same thing: + ['a', 'b', 'c'] - ['b', 'c', 'd'] + Would return: `['a']` - ['a', 'b', 'c'] - ['b', 'c', 'd'] - # would return ['a'] + @return [Array] + The difference between the two given arrays DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb index 75e83aa7e..b6addb40f 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig.rb @@ -3,7 +3,49 @@ # module Puppet::Parser::Functions newfunction(:dig, :type => :rvalue, :doc => <<-DOC - DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version. + @summary + **DEPRECATED** Retrieves a value within multiple layers of hashes and arrays via an + array of keys containing a path. + + @return + The function goes through the structure by each path component and tries to return + the value at the end of the path. + + In addition to the required path argument, the function accepts the default argument. + It is returned if the path is not correct, if no value was found, or if any other error + has occurred. + + ```ruby + $data = { + 'a' => { + 'b' => [ + 'b1', + 'b2', + 'b3', + ] + } + } + + $value = dig($data, ['a', 'b', 2]) + # $value = 'b3' + + # with all possible options + $value = dig($data, ['a', 'b', 2], 'not_found') + # $value = 'b3' + + # using the default value + $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found') + # $value = 'not_found' + ``` + + 1. `$data` The data structure we are working with. + 2. `['a', 'b', 2]` The path array. + 3. `not_found` The default value. It is returned if nothing is found. + + > **Note:* + **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version. DOC ) do |arguments| warning('dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.') diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb index 91724f43c..ff1d9df65 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dig44.rb @@ -7,14 +7,14 @@ module Puppet::Parser::Functions :type => :rvalue, :arity => -2, :doc => <<-DOC - DEPRECATED: This function has been replaced in Puppet 4.5.0. - - Looks up into a complex structure of arrays and hashes and returns a value - or the default value if nothing was found. + @summary + **DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value + or the default value if nothing was found. Key can contain slashes to describe path components. The function will go down the structure and try to extract the required value. + ``` $data = { 'a' => { 'b' => [ @@ -25,19 +25,24 @@ module Puppet::Parser::Functions } } - $value = dig44($data, ['a', 'b', '2'], 'not_found') - => $value = 'b3' + $value = dig44($data, ['a', 'b', 2]) + # $value = 'b3' + + # with all possible options + $value = dig44($data, ['a', 'b', 2], 'not_found') + # $value = 'b3' - a -> first hash key - b -> second hash key - 2 -> array index starting with 0 + # using the default value + $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found') + # $value = 'not_found' + ``` - not_found -> (optional) will be returned if there is no value or the path - did not match. Defaults to nil. + > **Note:* **Deprecated** This function has been replaced with a built-in + [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of + Puppet 4.5.0. - In addition to the required "key" argument, the function accepts a default - argument. It will be returned if no value was found or a path component is - missing. And the fourth argument can set a variable path separator. + @return [String] 'not_found' will be returned if nothing is found + @return [Any] the value that was searched for DOC ) do |arguments| # Two arguments are required diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dirname.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dirname.rb index 54bd9b6f2..ae579e20e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dirname.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dirname.rb @@ -3,7 +3,10 @@ # module Puppet::Parser::Functions newfunction(:dirname, :type => :rvalue, :doc => <<-DOC - Returns the dirname of a path. + @summary + Returns the dirname of a path. + + @return [String] the given path's dirname DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb index 32722ba50..e741aa8dd 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/dos2unix.rb @@ -1,8 +1,12 @@ # Custom Puppet function to convert dos to unix format module Puppet::Parser::Functions newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-DOC - Returns the Unix version of the given string. + @summary + Returns the Unix version of the given string. + Takes a single string argument. + + @return The retrieved version DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/downcase.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/downcase.rb index 0c763752e..a0717ff61 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/downcase.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/downcase.rb @@ -4,10 +4,17 @@ # module Puppet::Parser::Functions newfunction(:downcase, :type => :rvalue, :doc => <<-DOC - Converts the case of a string or all strings in an array to lower case. + @summary + **Deprecated:** Converts the case of a string or all strings in an array to lower case. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function. + > + This function is an implementation of a Ruby class and might not be UTF8 compatible. + To ensure compatibility, use this function with Ruby 2.4.0 or greater. + + @return [String] The converted String, if it was a String that was given + @return [Array[String]] The converted Array, if it was a Array that was given DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/empty.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/empty.rb index e0b9838e2..907ecb196 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/empty.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/empty.rb @@ -3,10 +3,15 @@ # module Puppet::Parser::Functions newfunction(:empty, :type => :rvalue, :doc => <<-DOC - Returns true if the variable is empty. + @summary + **Deprecated:** Returns true if the variable is empty. - Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core - will be used instead of this function. + @return + Returns `true` if the argument is an array or hash that contains no elements, + or an empty string. Returns `false` when the argument is a numerical value. + + > *Note*: **Deprecated** from Puppet 5.5.0, the built-in + [`empty`](https://puppet.com/docs/puppet/6.4/function.html#empty) function will be used instead. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb index f412b018b..b55f76b30 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/enclose_ipv6.rb @@ -3,7 +3,12 @@ # module Puppet::Parser::Functions newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-DOC - Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. + @summary + Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. + + @return + encloses the ipv6 addresses with square brackets. + DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb index f91e3e1ca..f255c036e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb @@ -3,9 +3,14 @@ # module Puppet::Parser::Functions newfunction(:ensure_packages, :type => :statement, :doc => <<-DOC - Takes a list of packages and only installs them if they don't already exist. + @summary + Takes a list of packages and only installs them if they don't already exist. + It optionally takes a hash as a second parameter that will be passed as the third argument to the ensure_resource() function. + + @return + install the passed packages DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb index d28ed9db7..e4fa771f2 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb @@ -3,17 +3,23 @@ require 'puppet/parser/functions' Puppet::Parser::Functions.newfunction(:ensure_resource, :type => :statement, - :doc => <<-'DOC' + :doc => <<-DOC + @summary Takes a resource type, title, and a list of attributes that describe a resource. - user { 'dan': - ensure => present, - } + user { 'dan': + ensure => present, + } - This example only creates the resource if it does not already exist: + @return + created or recreated the passed resource with the passed type and attributes - ensure_resource('user', 'dan', {'ensure' => 'present' }) + @example Example usage + + Creates the resource if it does not already exist: + + ensure_resource('user', 'dan', {'ensure' => 'present' }) If the resource already exists but does not match the specified parameters, this function will attempt to recreate the resource leading to a duplicate @@ -22,7 +28,7 @@ Puppet::Parser::Functions.newfunction(:ensure_resource, An array of resources can also be passed in and each will be created with the type and parameters specified if it doesn't already exist. - ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) + ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) DOC ) do |vals| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb index 642247c9c..c7032caa2 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/ensure_resources.rb @@ -2,10 +2,16 @@ require 'puppet/parser/functions' Puppet::Parser::Functions.newfunction(:ensure_resources, :type => :statement, - :doc => <<-'DOC' + :doc => <<-DOC + @summary Takes a resource type, title (only hash), and a list of attributes that describe a resource. + @return + created resources with the passed type and attributes + + @example Example usage + user { 'dan': gid => 'mygroup', ensure => present, @@ -14,7 +20,7 @@ Puppet::Parser::Functions.newfunction(:ensure_resources, An hash of resources should be passed in and each will be created with the type and parameters specified if it doesn't already exist. - ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } , 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) + ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'}) From Hiera Backend: diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/flatten.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/flatten.rb index 6be5962b2..7344201fd 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/flatten.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/flatten.rb @@ -3,17 +3,19 @@ # module Puppet::Parser::Functions newfunction(:flatten, :type => :rvalue, :doc => <<-DOC - This function flattens any deeply nested arrays and returns a single flat array - as a result. + @summary + This function flattens any deeply nested arrays and returns a single flat array + as a result. - *Examples:* + @return + convert nested arrays into a single flat array - flatten(['a', ['b', ['c']]]) + @example Example usage - Would return: ['a','b','c'] + flatten(['a', ['b', ['c']]])` returns: `['a','b','c'] - Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > **Note:** **Deprecated** from Puppet 5.5.0, this function has been replaced with a + built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/floor.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/floor.rb index df132fc38..3a6f3c805 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/floor.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/floor.rb @@ -3,11 +3,15 @@ # module Puppet::Parser::Functions newfunction(:floor, :type => :rvalue, :doc => <<-DOC - Returns the largest integer less or equal to the argument. + @summary + Returns the largest integer less or equal to the argument. + + @return + the largest integer less or equal to the argument. Takes a single numeric value as an argument. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with + a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb index ee45236b3..9bfba73d6 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rand_string.rb @@ -2,17 +2,25 @@ Puppet::Parser::Functions.newfunction( :fqdn_rand_string, :arity => -2, :type => :rvalue, - :doc => "Usage: `fqdn_rand_string(LENGTH, [CHARSET], [SEED])`. LENGTH is - required and must be a positive integer. CHARSET is optional and may be - `undef` or a string. SEED is optional and may be any number or string. - - Generates a random string LENGTH characters long using the character set - provided by CHARSET, combining the `$fqdn` fact and the value of SEED for - repeatable randomness. (That is, each node will get a different random - string from this function, but a given node's result will be the same every - time unless its hostname changes.) Adding a SEED can be useful if you need - more than one unrelated string. CHARSET will default to alphanumeric if - `undef` or an empty string.", + :doc => <<-DOC + @summary + Generates a random alphanumeric string. Combining the `$fqdn` fact and an + optional seed for repeatable randomness. + + Optionally, you can specify a character set for the function (defaults to alphanumeric). + + Arguments + * An integer, specifying the length of the resulting string. + * Optionally, a string specifying the character set. + * Optionally, a string specifying the seed for repeatable randomness. + + @return [String] + + @example Example Usage: + fqdn_rand_string(10) + fqdn_rand_string(10, 'ABCDEF!@$%^') + fqdn_rand_string(10, '', 'custom seed') + DOC ) do |args| raise(ArgumentError, 'fqdn_rand_string(): wrong number of arguments (0 for 1)') if args.empty? Puppet::Parser::Functions.function('is_integer') diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb index 879e44bbc..c86ea6829 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb @@ -4,15 +4,19 @@ Puppet::Parser::Functions.newfunction( :fqdn_rotate, :type => :rvalue, - :doc => "Usage: `fqdn_rotate(VALUE, [SEED])`. VALUE is required and - must be an array or a string. SEED is optional and may be any number - or string. - - Rotates VALUE a random number of times, combining the `$fqdn` fact and - the value of SEED for repeatable randomness. (That is, each node will - get a different random rotation from this function, but a given node's - result will be the same every time unless its hostname changes.) Adding - a SEED can be useful if you need more than one unrelated rotation.", + :doc => <<-DOC + @summary + Rotates an array or string a random number of times, combining the `$fqdn` fact + and an optional seed for repeatable randomness. + + @return + rotated array or string + + @example Example Usage: + fqdn_rotate(['a', 'b', 'c', 'd']) + fqdn_rotate('abcd') + fqdn_rotate([1, 2, 3], 'custom seed') + DOC ) do |args| raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments given (#{args.size} for 1)") if args.empty? diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb index 5080e8ebf..e325fe732 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/fqdn_uuid.rb @@ -4,34 +4,16 @@ require 'digest/sha1' # module Puppet::Parser::Functions newfunction(:fqdn_uuid, :type => :rvalue, :doc => <<-DOC) do |args| - Creates a UUID based on a given string, assumed to be the FQDN + @summary + Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based + on an FQDN string under the DNS namespace - For example, to generate a UUID based on the FQDN of a system: + @return + Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID - Usage: - - $uuid = fqdn_uuid($::fqdn) - - The generated UUID will be the same for the given hostname - - The resulting UUID is returned on the form: - - 1d839dea-5e10-5243-88eb-e66815bd7d5c - - (u.e. without any curly braces.) - - The generated UUID is a version 5 UUID with the V5 DNS namespace: - - 6ba7b810-9dad-11d1-80b4-00c04fd430c8 - - This only supports a the V5 SHA-1 hash, using the DNS namespace. - - Please consult http://www.ietf.org/rfc/rfc4122.txt for the details on - UUID generation and example implementation. - - No verification is present at the moment as whether the domain name given - is in fact a correct fully-qualified domain name. Therefore any arbitrary - string and/or alpha-numeric value can subside for a domain name. + @example Example Usage: + fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c' + fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09c8' DOC raise(ArgumentError, 'fqdn_uuid: No arguments given') if args.empty? diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb index 3ec6ccd3c..ac787c652 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb @@ -3,14 +3,22 @@ # module Puppet::Parser::Functions newfunction(:get_module_path, :type => :rvalue, :doc => <<-DOC - Returns the absolute path of the specified module for the current - environment. + @summary + Returns the absolute path of the specified module for the current + environment. - Example: + @return + Returns the absolute path of the specified module for the current + environment. + + @example Example Usage: $module_path = get_module_path('stdlib') - Note that since Puppet 5.4.0 the function `module_directory()` in Puppet does the same thing and will return - the path to the first found module if given multiple values or an array. + > *Note:* + that since Puppet 5.4.0 the built-in + [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory) + function in Puppet does the same thing and will return the path to the first found module + if given multiple values or an array. DOC ) do |args| raise(Puppet::ParseError, 'get_module_path(): Wrong number of arguments, expects one') unless args.size == 1 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/getparam.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/getparam.rb index 95981b360..59ef7691a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/getparam.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/getparam.rb @@ -4,38 +4,43 @@ require 'puppet/parser/functions' Puppet::Parser::Functions.newfunction(:getparam, :type => :rvalue, :doc => <<-'DOC' + @summary + Returns the value of a resource's parameter. + + @return + value of a resource's parameter. + Takes a resource reference and name of the parameter and returns value of resource's parameter. Note that user defined resource types are evaluated lazily. - *Examples:* + @example Example Usage: - # define a resource type with a parameter - define example_resource($param) { - } + # define a resource type with a parameter + define example_resource($param) { + } - # declare an instance of that type - example_resource { "example_resource_instance": - param => "'the value we are getting in this example''" - } + # declare an instance of that type + example_resource { "example_resource_instance": + param => "'the value we are getting in this example''" + } - # Because of order of evaluation, a second definition is needed - # that will be evaluated after the first resource has been declared - # - define example_get_param { - # This will notice the value of the parameter - notice(getparam(Example_resource["example_resource_instance"], "param")) - } + # Because of order of evaluation, a second definition is needed + # that will be evaluated after the first resource has been declared + # + define example_get_param { + # This will notice the value of the parameter + notice(getparam(Example_resource["example_resource_instance"], "param")) + } - # Declare an instance of the second resource type - this will call notice - example_get_param { 'show_notify': } + # Declare an instance of the second resource type - this will call notice + example_get_param { 'show_notify': } Would notice: 'the value we are getting in this example' - Note that since Puppet 4.0.0 it is possible to get a parameter value by using its data type + > **Note** that since Puppet 4.0.0 it is possible to get a parameter value by using its data type and the [ ] operator. The example below is equivalent to a call to getparam(): - - Example_resource['example_resource_instance']['param'] + ```Example_resource['example_resource_instance']['param']`` DOC ) do |vals| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb index fddbd82f0..41d3c4f41 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/getvar.rb @@ -3,21 +3,20 @@ # module Puppet::Parser::Functions newfunction(:getvar, :type => :rvalue, :doc => <<-'DOC') do |args| - Lookup a variable in a given namespace. - Returns undef if variable does not exist. + @summary + Lookup a variable in a given namespace. - For example: + @return + undef - if variable does not exist - $foo = getvar('site::data::foo') - # Equivalent to $foo = $site::data::foo + @example Example usage + $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo - This is useful if the namespace itself is stored in a string: + @example Where namespace is stored in a string + $datalocation = 'site::data' + $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar - $datalocation = 'site::data' - $bar = getvar("${datalocation}::bar") - # Equivalent to $bar = $site::data::bar - - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core + > **Note:** from Puppet 6.0.0, the compatible function with the same name in Puppet core will be used instead of this function. The new function also has support for digging into a structured value. See the built-in [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) function diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb index e9d35b282..5475b74b3 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/glob.rb @@ -2,9 +2,15 @@ # glob.rb # module Puppet::Parser::Functions - newfunction(:glob, :type => :rvalue, :doc => <<-'DOC' - Returns an Array of file entries of a directory or an Array of directories. - Uses same patterns as Dir#glob + newfunction(:glob, :type => :rvalue, :doc => <<-DOC + @summary + Uses same patterns as Dir#glob. + + @return + Returns an Array of file entries of a directory or an Array of directories. + + @example Example Usage: + $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf']) DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/grep.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/grep.rb index b6881bf36..2d274838e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/grep.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/grep.rb @@ -3,20 +3,19 @@ # module Puppet::Parser::Functions newfunction(:grep, :type => :rvalue, :doc => <<-DOC - This function searches through an array and returns any elements that match - the provided regular expression. - - *Examples:* - - grep(['aaa','bbb','ccc','aaaddd'], 'aaa') - - Would return: - - ['aaa','aaaddd'] - - Note that since Puppet 4.0.0, the filter() function in Puppet can do the same: - - ['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' } + @summary + This function searches through an array and returns any elements that match + the provided regular expression. + + @return + array of elements that match the provided regular expression. + @example Example Usage: + grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd'] + + > **Note:** that since Puppet 4.0.0, the built-in + [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does + the "same" - as any logic can be used to filter, as opposed to just regular expressions: + ```['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }``` DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb index 44005d0a0..fb9af42eb 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb @@ -3,18 +3,20 @@ # module Puppet::Parser::Functions newfunction(:has_interface_with, :type => :rvalue, :doc => <<-DOC - Returns boolean based on kind and value: - * macaddress - * netmask - * ipaddress - * network + @summary + Returns boolean based on kind and value. - has_interface_with("macaddress", "x:x:x:x:x:x") - has_interface_with("ipaddress", "127.0.0.1") => true - etc. + @return + boolean values `true` or `false` - If no "kind" is given, then the presence of the interface is checked: - has_interface_with("lo") => true + Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`. + + @example **Usage** + has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false` + has_interface_with("ipaddress", "127.0.0.1") # Returns `true` + + @example If no "kind" is given, then the presence of the interface is checked: + has_interface_with("lo") # Returns `true` DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb index 5f14ee203..4004681ca 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb @@ -3,7 +3,11 @@ # module Puppet::Parser::Functions newfunction(:has_ip_address, :type => :rvalue, :doc => <<-DOC - Returns true if the client has the requested IP address on some interface. + @summary + Returns true if the client has the requested IP address on some interface. + + @return [Boolean] + `true` or `false` This function iterates through the 'interfaces' fact and checks the 'ipaddress_IFACE' facts, performing a simple string comparison. diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb index 65f278900..b4a3bad25 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb @@ -3,7 +3,11 @@ # module Puppet::Parser::Functions newfunction(:has_ip_network, :type => :rvalue, :doc => <<-DOC - Returns true if the client has an IP address within the requested network. + @summary + Returns true if the client has an IP address within the requested network. + + @return + Boolean value, `true` if the client has an IP address within the requested network. This function iterates through the 'interfaces' fact and checks the 'network_IFACE' facts, performing a simple string comparision. diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_key.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_key.rb index 8bf74f049..50dde53e3 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_key.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/has_key.rb @@ -3,24 +3,29 @@ # module Puppet::Parser::Functions newfunction(:has_key, :type => :rvalue, :doc => <<-'DOC') do |args| - Determine if a hash has a certain key value. + @summary + **Deprecated:** Determine if a hash has a certain key value. - Example: + @return + Boolean value - $my_hash = {'key_one' => 'value_one'} - if has_key($my_hash, 'key_two') { - notice('we will not reach here') - } - if has_key($my_hash, 'key_one') { - notice('this will be printed') - } + @example Example Usage: - Note: Since Puppet 4.0.0 this can be achieved in the Puppet language with the following equivalent expression: + $my_hash = {'key_one' => 'value_one'} + if has_key($my_hash, 'key_two') { + notice('we will not reach here') + } + if has_key($my_hash, 'key_one') { + notice('this will be printed') + } + + > **Note:** **Deprecated** since Puppet 4.0.0, this can now be achieved in the Puppet + language with the following equivalent expression: + $my_hash = {'key_one' => 'value_one'} + if 'key_one' in $my_hash { + notice('this will be printed') + } - $my_hash = {'key_one' => 'value_one'} - if 'key_one' in $my_hash { - notice('this will be printed') - } DOC unless args.length == 2 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/hash.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/hash.rb index 0162e8327..484cb59bf 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/hash.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/hash.rb @@ -3,20 +3,22 @@ # module Puppet::Parser::Functions newfunction(:hash, :type => :rvalue, :doc => <<-DOC - This function converts an array into a hash. + @summary + **Deprecated:** This function converts an array into a hash. - *Examples:* + @return + the converted array as a hash + @example Example Usage: + hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3} - hash(['a',1,'b',2,'c',3]) - - Would return: {'a'=>1,'b'=>2,'c'=>3} - - Note: Since Puppet 5.0.0 type conversions can in general be performed by using the Puppet Type System. - See the function new() in Puppet for a wide range of available type conversions. + > **Note:** This function has been replaced with the built-in ability to create a new value of almost any + data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function + in Puppet. This example shows the equivalent expression in the Puppet language: - - Hash(['a',1,'b',2,'c',3]) - Hash([['a',1],['b',2],['c',3]]) + ``` + Hash(['a',1,'b',2,'c',3]) + Hash([['a',1],['b',2],['c',3]]) + ``` DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/intersection.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/intersection.rb index 0c16722ee..b46ca58a0 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/intersection.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/intersection.rb @@ -3,12 +3,15 @@ # module Puppet::Parser::Functions newfunction(:intersection, :type => :rvalue, :doc => <<-DOC - This function returns an array of the intersection of two. + @summary + This function returns an array of the intersection of two. - *Examples:* + @return + an array of the intersection of two. - intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"] - intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) + @example Example Usage: + intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"] + intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb index 06e9465d3..9913dbaab 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_absolute_path.rb @@ -3,28 +3,33 @@ # module Puppet::Parser::Functions newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'DOC') do |args| - Returns boolean true if the string represents an absolute path in the filesystem. This function works - for windows and unix style paths. + @summary + **Deprecated:** Returns boolean true if the string represents an absolute path in the filesystem. - The following values will return true: + This function works for windows and unix style paths. - $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' - is_absolute_path($my_path) - $my_path2 = '/var/lib/puppet' - is_absolute_path($my_path2) - $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet'] - is_absolute_path($my_path3) - $my_path4 = ['/var/lib/puppet'] - is_absolute_path($my_path4) + @example The following values will return true: + $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' + is_absolute_path($my_path) + $my_path2 = '/var/lib/puppet' + is_absolute_path($my_path2) + $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet'] + is_absolute_path($my_path3) + $my_path4 = ['/var/lib/puppet'] + is_absolute_path($my_path4) - The following values will return false: + @example The following values will return false: + is_absolute_path(true) + is_absolute_path('../var/lib/puppet') + is_absolute_path('var/lib/puppet') + $undefined = undef + is_absolute_path($undefined) - is_absolute_path(true) - is_absolute_path('../var/lib/puppet') - is_absolute_path('var/lib/puppet') - $undefined = undef - is_absolute_path($undefined) + @return [Boolean] + Returns `true` or `false` + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC function_deprecation([:is_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_array.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_array.rb index 620f4f796..1df57b2fa 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_array.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_array.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_array, :type => :rvalue, :doc => <<-DOC - Returns true if the variable passed to this function is an array. + @summary + **Deprecated:** Returns true if the variable passed to this function is an array. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_bool.rb index d0e002616..cf5cb32c0 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_bool.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_bool, :type => :rvalue, :doc => <<-DOC - Returns true if the variable passed to this function is a boolean. + @summary + **Deprecated:** Returns true if the variable passed to this function is a boolean. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb index d80689a68..390a86894 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb @@ -3,7 +3,15 @@ # module Puppet::Parser::Functions newfunction(:is_domain_name, :type => :rvalue, :doc => <<-DOC - Returns true if the string passed to this function is a syntactically correct domain name. + @summary + **Deprecated:** Returns true if the string passed to this function is + a syntactically correct domain name. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb index f656468eb..1c41b86be 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_email_address.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_email_address, :type => :rvalue, :doc => <<-DOC - Returns true if the string passed to this function is a valid email address. + @summary + **Deprecated:** Returns true if the string passed to this function is a valid email address. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| if arguments.size != 1 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_float.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_float.rb index 89994d29d..583793d01 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_float.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_float.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_float, :type => :rvalue, :doc => <<-DOC - Returns true if the variable passed to this function is a float. + @summary + **Deprecated:** Returns true if the variable passed to this function is a float. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb index e02aa536d..e931225c4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb @@ -3,9 +3,16 @@ # module Puppet::Parser::Functions newfunction(:is_function_available, :type => :rvalue, :doc => <<-DOC - This function accepts a string as an argument, determines whether the - Puppet runtime has access to a function by that name. It returns a - true if the function exists, false if not. + @summary + **Deprecated:** Determines whether the Puppet runtime has access to a function by that name. + + This function accepts a string as an argument. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_hash.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_hash.rb index dc036530c..f85b9eeaa 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_hash.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_hash, :type => :rvalue, :doc => <<-DOC - Returns true if the variable passed to this function is a hash. + @summary + **Deprecated:** Returns true if the variable passed to this function is a hash. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_integer.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_integer.rb index 7444cace7..a86b5cddc 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_integer.rb @@ -3,12 +3,20 @@ # module Puppet::Parser::Functions newfunction(:is_integer, :type => :rvalue, :doc => <<-DOC - Returns true if the variable passed to this function is an Integer or - a decimal (base 10) integer in String form. The string may - start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not - be followed by other digits as this indicates that the value is octal (base 8). + @summary + **Deprecated:** Returns true if the variable passed to this function is an Integer or + a decimal (base 10) integer in String form. + + The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0' + digit may not be followed by other digits as this indicates that the value is octal (base 8). If given any other argument `false` is returned. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb index 6ce993a3c..61f84a13e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_ip_address, :type => :rvalue, :doc => <<-DOC - Returns true if the string passed to this function is a valid IP address. + @summary + **Deprecated:** Returns true if the string passed to this function is a valid IP address. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb index 7f2241b74..5064f4890 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv4_address.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_ipv4_address, :type => :rvalue, :doc => <<-DOC - Returns true if the string passed to this function is a valid IPv4 address. + @summary + **Deprecated:** Returns true if the string passed to this function is a valid IPv4 address. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb index 35be02625..a4de14fd2 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_ipv6_address.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_ipv6_address, :type => :rvalue, :doc => <<-DOC - Returns true if the string passed to this function is a valid IPv6 address. + @summary + **Deprecated:** Returns true if the string passed to this function is a valid IPv6 address. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb index 597c928f4..ef1fc2059 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_mac_address, :type => :rvalue, :doc => <<-DOC - Returns true if the string passed to this function is a valid mac address. + @summary + **Deprecated:** Returns true if the string passed to this function is a valid mac address. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb index e127705df..8b42119ae 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb @@ -3,6 +3,9 @@ # module Puppet::Parser::Functions newfunction(:is_numeric, :type => :rvalue, :doc => <<-DOC + @summary + **Deprecated:** Returns true if the given value is numeric. + Returns true if the given argument is a Numeric (Integer or Float), or a String containing either a valid integer in decimal base 10 form, or a valid floating point string representation. @@ -13,13 +16,11 @@ module Puppet::Parser::Functions The string representation may start with a '-' (minus). If a decimal '.' is used, it must be followed by at least one digit. - Valid examples: + @return [Boolean] + Returns `true` or `false` - 77435 - 10e-12 - -8475 - 0.2343 - -23.561e3 + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_string.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_string.rb index f7b1b145b..7410d32a4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_string.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/is_string.rb @@ -3,7 +3,14 @@ # module Puppet::Parser::Functions newfunction(:is_string, :type => :rvalue, :doc => <<-DOC - Returns true if the variable passed to this function is a string. + @summary + **Deprecated:** Returns true if the variable passed to this function is a string. + + @return [Boolean] + Returns `true` or `false` + + > **Note:* **Deprecated** Will be removed in a future version of stdlib. See + [`validate_legacy`](#validate_legacy). DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/join.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/join.rb index d2d7019f2..266ad65b9 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/join.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/join.rb @@ -3,16 +3,17 @@ # module Puppet::Parser::Functions newfunction(:join, :type => :rvalue, :doc => <<-DOC - This function joins an array into a string using a separator. + @summary + **Deprecated:** This function joins an array into a string using a separator. - *Examples:* + @example Example Usage: + join(['a','b','c'], ",") # Results in: "a,b,c" - join(['a','b','c'], ",") + @return [String] + The String containing each of the array values - Would result in: "a,b,c" - - Note: from Puppet 5.4.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > **Note:** **Deprecated** from Puppet 5.4.0 this function has been replaced + with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb index 99876d023..73d4a1ff0 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb @@ -3,22 +3,22 @@ # module Puppet::Parser::Functions newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-DOC - This function joins each key of a hash to that key's corresponding value with a - separator. Keys are cast to strings. If values are arrays, multiple keys + @summary + This function joins each key of a hash to that key's corresponding value with a + separator. + + Keys are cast to strings. If values are arrays, multiple keys are added for each element. The return value is an array in which each element is one joined key/value pair. - *Examples:* - - join_keys_to_values({'a'=>1,'b'=>2}, " is ") - - Would result in: ["a is 1","b is 2"] - - join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") + @example Example Usage: + join_keys_to_values({'a'=>1,'b'=>2}, " is ") # Results in: ["a is 1","b is 2"] + join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") # Results in: ["a is 1","b is 2","b is 3"] - Would result in: ["a is 1","b is 2","b is 3"] + @return [Hash] + The joined hash - Note: Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and + > **Note:** Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual formatting of values in the array) - see the `new` function for `String` and its formatting options for `Array` and `Hash`. diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/keys.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/keys.rb index f3663b7b0..80d080c65 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/keys.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/keys.rb @@ -3,10 +3,14 @@ # module Puppet::Parser::Functions newfunction(:keys, :type => :rvalue, :doc => <<-DOC - Returns the keys of a hash as an array. + @summary + **Deprecated:** Returns the keys of a hash as an array. - Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core - will be used instead of this function. + @return [Array] + An array containing each of the hashes key values. + + > **Note:** **Deprecated** from Puppet 5.5.0, the built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys) + function will be used instead of this function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb index f9a39de95..79d98cdd8 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb @@ -3,7 +3,15 @@ # module Puppet::Parser::Functions newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-DOC - This function loads the metadata of a given module. + @summary + This function loads the metadata of a given module. + + @example Example USage: + $metadata = load_module_metadata('archive') + notify { $metadata['author']: } + + @return + The modules metadata DOC ) do |args| raise(Puppet::ParseError, 'load_module_metadata(): Wrong number of arguments, expects one or two') unless [1, 2].include?(args.size) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb index f022bcdda..3c6087855 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadjson.rb @@ -4,18 +4,22 @@ module Puppet::Parser::Functions newfunction(:loadjson, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args| - Load a JSON file containing an array, string, or hash, and return the data - in the corresponding native data type. + @summary + Load a JSON file containing an array, string, or hash, and return the data + in the corresponding native data type. + The first parameter can be a file path or a URL. The second parameter is the default value. It will be returned if the file was not found or could not be parsed. - For example: + @return [Array|String|Hash] + The data stored in the JSON file, the type depending on the type of data that was stored. - $myhash = loadjson('/etc/puppet/data/myhash.json') - $myhash = loadjson('https://example.local/my_hash.json') - $myhash = loadjson('https://username:password@example.local/my_hash.json') - $myhash = loadjson('no-file.json', {'default' => 'value'}) + @example Example Usage: + $myhash = loadjson('/etc/puppet/data/myhash.json') + $myhash = loadjson('https://example.local/my_hash.json') + $myhash = loadjson('https://username:password@example.local/my_hash.json') + $myhash = loadjson('no-file.json', {'default' => 'value'}) DOC raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb index a49ae2c0c..f84f5300d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb @@ -3,14 +3,18 @@ # module Puppet::Parser::Functions newfunction(:loadyaml, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args| - Load a YAML file containing an array, string, or hash, and return the data - in the corresponding native data type. + @summary + Load a YAML file containing an array, string, or hash, and return the data + in the corresponding native data type. + The first parameter can be a file path or a URL. The second parameter is the default value. It will be returned if the file was not found or could not be parsed. - For example: + @return [Array|String|Hash] + The data stored in the YAML file, the type depending on the type of data that was stored. + @example Example Usage: $myhash = loadyaml('/etc/puppet/data/myhash.yaml') $myhash = loadyaml('https://example.local/my_hash.yaml') $myhash = loadyaml('https://username:password@example.local/my_hash.yaml') diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/lstrip.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/lstrip.rb index 99874e468..2fd31a226 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/lstrip.rb @@ -3,10 +3,14 @@ # module Puppet::Parser::Functions newfunction(:lstrip, :type => :rvalue, :doc => <<-DOC - Strips leading spaces to the left of a string. + @summary + **Deprecated:** Strips leading spaces to the left of a string. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + @return [String] + The stripped string + + > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/max.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/max.rb index 4715dcd4e..00a183aba 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/max.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/max.rb @@ -3,11 +3,16 @@ # module Puppet::Parser::Functions newfunction(:max, :type => :rvalue, :doc => <<-DOC - Returns the highest value of all arguments. + @summary + **Deprecated:** Returns the highest value of all arguments. + Requires at least one argument. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + @return + The highest value among those passed in + + > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function. DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb index 8154f3b03..7efcb1f63 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/member.rb @@ -5,39 +5,34 @@ # module Puppet::Parser::Functions newfunction(:member, :type => :rvalue, :doc => <<-DOC - This function determines if a variable is a member of an array. - The variable can be a string, fixnum, or array. - - *Examples:* - - member(['a','b'], 'b') - - Would return: true - - member(['a', 'b', 'c'], ['a', 'b']) - - would return: true - - member(['a','b'], 'c') + @summary + This function determines if a variable is a member of an array. - Would return: false - - member(['a', 'b', 'c'], ['d', 'b']) - - would return: false - - Note: Since Puppet 4.0.0 the same can be performed in the Puppet language. For single values - the operator `in` can be used: - - 'a' in ['a', 'b'] # true - - And for arrays by using operator `-` to compute a diff: - - ['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted - ['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted + The variable can be a string, fixnum, or array. - Also note that since Puppet 5.2.0 the general form of testing content of an array or hash is to use the built-in - `any` and `all` functions. + > **Note**: This function does not support nested arrays. If the first argument contains + nested arrays, it will not recurse through them. + + @example **Usage** + member(['a','b'], 'b') # Returns: true + member(['a', 'b', 'c'], ['a', 'b']) # Returns: true + member(['a','b'], 'c') # Returns: false + member(['a', 'b', 'c'], ['d', 'b']) # Returns: false + + > *Note:* + Since Puppet 4.0.0 the same can be performed in the Puppet language. + For single values the operator `in` can be used: + `'a' in ['a', 'b'] # true` + For arrays by using operator `-` to compute a diff: + `['d', 'b'] - ['a', 'b', 'c'] == [] # false because 'd' is not subtracted` + `['a', 'b'] - ['a', 'b', 'c'] == [] # true because both 'a' and 'b' are subtracted` + + @return + Returns whether the given value was a member of the array + + > **Note** that since Puppet 5.2.0, the general form to test the content of an array or + hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any) + and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/merge.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/merge.rb index 1ca825751..9a0e8c1f0 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/merge.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/merge.rb @@ -3,21 +3,21 @@ # module Puppet::Parser::Functions newfunction(:merge, :type => :rvalue, :doc => <<-'DOC') do |args| - Merges two or more hashes together and returns the resulting hash. + @summary + Merges two or more hashes together and returns the resulting hash. - For example: - - $hash1 = {'one' => 1, 'two', => 2} - $hash2 = {'two' => 'dos', 'three', => 'tres'} - $merged_hash = merge($hash1, $hash2) - # The resulting hash is equivalent to: - # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} + @example **Usage** + $hash1 = {'one' => 1, 'two', => 2} + $hash2 = {'two' => 'dos', 'three', => 'tres'} + $merged_hash = merge($hash1, $hash2) # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'} When there is a duplicate key, the key in the rightmost hash will "win." - Note that since Puppet 4.0.0 the same merge can be achieved with the + operator. + @return [Hash] + The merged hash - $merged_hash = $hash1 + $hash2 + Note that since Puppet 4.0.0 the same merge can be achieved with the + operator. + `$merged_hash = $hash1 + $hash2` DOC if args.length < 2 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/min.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/min.rb index ed4be5b20..c211a9e24 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/min.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/min.rb @@ -3,11 +3,16 @@ # module Puppet::Parser::Functions newfunction(:min, :type => :rvalue, :doc => <<-DOC - Returns the lowest value of all arguments. + @summary + **Deprecated:** Returns the lowest value of all arguments. + Requires at least one argument. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + @return + The lowest value among the given arguments + + > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a + built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function. DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb index 5e0f49424..6e530db9a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb @@ -3,15 +3,16 @@ # module Puppet::Parser::Functions newfunction(:num2bool, :type => :rvalue, :doc => <<-DOC - This function converts a number or a string representation of a number into a - true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0 - become true. + @summary + This function converts a number or a string representation of a number into a + true boolean. - Note that since Puppet 5.0.0 the same can be achieved with the Puppet Type System. + > *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System. See the new() function in Puppet for the many available type conversions. - Boolean(0) # false - Boolean(1) # true + @return [Boolean] + Boolean(0) # false for any zero or negative number + Boolean(1) # true for any positive number DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/parsejson.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/parsejson.rb index 4cc43e677..76b392fb1 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/parsejson.rb @@ -3,11 +3,16 @@ # module Puppet::Parser::Functions newfunction(:parsejson, :type => :rvalue, :doc => <<-DOC - This function accepts JSON as a string and converts it into the correct - Puppet structure. + @summary + This function accepts JSON as a string and converts it into the correct + Puppet structure. - The optional second argument can be used to pass a default value that will - be returned if the parsing of YAML string have failed. + @return + convert JSON into Puppet structure + + > *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. DOC ) do |arguments| raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb index 7f857ca8d..5d081e6a6 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb @@ -3,11 +3,16 @@ # module Puppet::Parser::Functions newfunction(:parseyaml, :type => :rvalue, :doc => <<-DOC - This function accepts YAML as a string and converts it into the correct - Puppet structure. + @summary + This function accepts YAML as a string and converts it into the correct + Puppet structure. - The optional second argument can be used to pass a default value that will - be returned if the parsing of YAML string have failed. + @return + converted YAML into Puppet structure + + > *Note:* + The optional second argument can be used to pass a default value that will + be returned if the parsing of YAML string have failed. DOC ) do |arguments| raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick.rb index 38ce5cd99..e31dc95de 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick.rb @@ -2,19 +2,25 @@ # pick.rb # module Puppet::Parser::Functions - newfunction(:pick, :type => :rvalue, :doc => <<-DOC - This function is similar to a coalesce function in SQL in that it will return - the first value in a list of values that is not undefined or an empty string. + newfunction(:pick, :type => :rvalue, :doc => <<-EOS + @summary + This function is similar to a coalesce function in SQL in that it will return + the first value in a list of values that is not undefined or an empty string. + + @return + the first value in a list of values that is not undefined or an empty string. + Typically, this function is used to check for a value in the Puppet Dashboard/Enterprise Console, and failover to a default value like the following: - $real_jenkins_version = pick($::jenkins_version, '1.449') + ```$real_jenkins_version = pick($::jenkins_version, '1.449')``` - The value of $real_jenkins_version will first look for a top-scope variable - called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ - Enterprise Console are brought into Puppet as top-scope variables), and, - failing that, will use a default value of 1.449. -DOC + > *Note:* + The value of $real_jenkins_version will first look for a top-scope variable + called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ + Enterprise Console are brought into Puppet as top-scope variables), and, + failing that, will use a default value of 1.449. + EOS ) do |args| args = args.compact args.delete(:undef) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick_default.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick_default.rb index 0d499fba4..d94bb52aa 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick_default.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pick_default.rb @@ -3,9 +3,13 @@ # module Puppet::Parser::Functions newfunction(:pick_default, :type => :rvalue, :doc => <<-DOC - This function is similar to a coalesce function in SQL in that it will return - the first value in a list of values that is not undefined or an empty string - If no value is found, it will return the last argument. + @summary + This function will return the first value in a list of values that is not undefined or an empty string. + + @return + This function is similar to a coalesce function in SQL in that it will return + the first value in a list of values that is not undefined or an empty string + If no value is found, it will return the last argument. Typically, this function is used to check for a value in the Puppet Dashboard/Enterprise Console, and failover to a default value like the @@ -13,15 +17,16 @@ module Puppet::Parser::Functions $real_jenkins_version = pick_default($::jenkins_version, '1.449') - The value of $real_jenkins_version will first look for a top-scope variable - called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ - Enterprise Console are brought into Puppet as top-scope variables), and, - failing that, will use a default value of 1.449. + > *Note:* + The value of $real_jenkins_version will first look for a top-scope variable + called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ + Enterprise Console are brought into Puppet as top-scope variables), and, + failing that, will use a default value of 1.449. - Note that, contrary to the pick() function, the pick_default does not fail if - all arguments are empty. This allows pick_default to use an empty value as - default. -DOC + Contrary to the pick() function, the pick_default does not fail if + all arguments are empty. This allows pick_default to use an empty value as + default. + DOC ) do |args| raise 'Must receive at least one argument.' if args.empty? default = args.last diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/prefix.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/prefix.rb index f1e1234b3..b5e96416d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/prefix.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/prefix.rb @@ -3,18 +3,19 @@ # module Puppet::Parser::Functions newfunction(:prefix, :type => :rvalue, :doc => <<-DOC - This function applies a prefix to all elements in an array or a hash. + @summary + This function applies a prefix to all elements in an array or a hash. - *Examples:* + @example **Usage** - prefix(['a','b','c'], 'p') + prefix(['a','b','c'], 'p') + Will return: ['pa','pb','pc'] - Will return: ['pa','pb','pc'] - - Note that since Puppet 4.0.0 the general way to modify values is in array is by using the map + > *Note:* since Puppet 4.0.0 the general way to modify values is in array is by using the map function in Puppet. This example does the same as the example above: + ['a', 'b', 'c'].map |$x| { "p${x}" } - ['a', 'b', 'c'].map |$x| { "p${x}" } + @return [Hash] or [Array] The passed values now contains the passed prefix DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/private.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/private.rb index 5e0b7c560..11a9451f9 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/private.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/private.rb @@ -3,8 +3,12 @@ # module Puppet::Parser::Functions newfunction(:private, :doc => <<-'DOC' - DEPRECATED: Sets the current class or definition as private. + @summary + **Deprecated:** Sets the current class or definition as private. Calling the class or definition from outside the current module will fail. + + @return + Sets the current class or definition as private DOC ) do |args| warning("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Cannot shorten this line diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb index 17b3bc7cb..c6333cc41 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pry.rb @@ -3,11 +3,17 @@ # module Puppet::Parser::Functions newfunction(:pry, :type => :statement, :doc => <<-DOC - This function invokes a pry debugging session in the current scope object. This is useful for debugging manifest code at specific points during a compilation. + @summary + This function invokes a pry debugging session in the current scope object. + This is useful for debugging manifest code at specific points during a compilation. - *Examples:* + @return + debugging information + + @example **Usage** + + `pry()` - pry() DOC ) do |arguments| begin diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb index eaf1d7478..ee008dd3e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/pw_hash.rb @@ -1,10 +1,14 @@ -# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. +# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. +# To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. +# Puppet::Parser::Functions.newfunction( :pw_hash, :type => :rvalue, :arity => 3, - :doc => "Hashes a password using the crypt function. Provides a hash - usable on most POSIX systems. + :doc => <<-DOC + @summary + Hashes a password using the crypt function. Provides a hash usable + on most POSIX systems. The first argument to this function is the password to hash. If it is undef or an empty string, this function returns undef. @@ -21,9 +25,13 @@ Puppet::Parser::Functions.newfunction( The third argument to this function is the salt to use. - Note: this uses the Puppet Master's implementation of crypt(3). If your - environment contains several different operating systems, ensure that they - are compatible before using this function.", + @return [Hash] + Provides a hash usable on most POSIX systems. + + > *Note:*: this uses the Puppet Master's implementation of crypt(3). If your + environment contains several different operating systems, ensure that they + are compatible before using this function. + DOC ) do |args| raise ArgumentError, "pw_hash(): wrong number of arguments (#{args.size} for 3)" if args.size != 3 args.map! do |arg| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/range.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/range.rb index 31baee51c..a309b78c3 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/range.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/range.rb @@ -4,39 +4,43 @@ # TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ... module Puppet::Parser::Functions newfunction(:range, :type => :rvalue, :doc => <<-DOC - When given range in the form of (start, stop) it will extrapolate a range as - an array. + @summary + When given range in the form of (start, stop) it will extrapolate a range as + an array. - *Examples:* + @return + the range is extrapolated as an array - range("0", "9") + @example **Usage** + range("0", "9") + Will return: [0,1,2,3,4,5,6,7,8,9] - Will return: [0,1,2,3,4,5,6,7,8,9] + range("00", "09") + Will return: [0,1,2,3,4,5,6,7,8,9] + (Zero padded strings are converted to integers automatically) - range("00", "09") + range("a", "c") + Will return: ["a","b","c"] - Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to - integers automatically) + range("host01", "host10") + Will return: ["host01", "host02", ..., "host09", "host10"] - range("a", "c") + range("0", "9", "2") + Will return: [0,2,4,6,8] - Will return: ["a","b","c"] - - range("host01", "host10") - Will return: ["host01", "host02", ..., "host09", "host10"] NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail. - Passing a third argument will cause the generated range to step by that - interval, e.g. - - range("0", "9", "2") - - Will return: [0,2,4,6,8] + > *Note:* + Passing a third argument will cause the generated range to step by that + interval, e.g. The Puppet Language support Integer and Float ranges by using the type system. Those are suitable for - iterating a given number of times. Also see the step() function in Puppet for skipping values. + iterating a given number of times. + + @see + the step() function in Puppet for skipping values. - Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9 + Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9 DOC ) do |arguments| @@ -80,7 +84,7 @@ module Puppet::Parser::Functions when '...' then (start...stop) # Exclusive of last element end - result = range.step(step).to_a + result = range.step(step).first(1_000_000).to_a return result end diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb index 647d865f9..43b729ea8 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/regexpescape.rb @@ -3,8 +3,11 @@ # module Puppet::Parser::Functions newfunction(:regexpescape, :type => :rvalue, :doc => <<-DOC - Regexp escape a string or array of strings. - Requires either a single string or an array as an input. + @summary + Regexp escape a string or array of strings. + Requires either a single string or an array as an input. + @return [String] + A string of characters with metacharacters converted to their escaped form. DOC ) do |arguments| # rubocop:disable Layout/ClosingParenthesisIndentation raise(Puppet::ParseError, "regexpescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/reject.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/reject.rb index 392f62eb9..6342db6e4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/reject.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/reject.rb @@ -3,21 +3,22 @@ # module Puppet::Parser::Functions newfunction(:reject, :type => :rvalue, :doc => <<-DOC) do |args| - This function searches through an array and rejects all elements that match - the provided regular expression. + @summary + This function searches through an array and rejects all elements that match + the provided regular expression. - *Examples:* + @return + an array containing all the elements which doesn'' match the provided regular expression - reject(['aaa','bbb','ccc','aaaddd'], 'aaa') + @example **Usage** - Would return: + reject(['aaa','bbb','ccc','aaaddd'], 'aaa') - ['bbb','ccc'] + Would return: ['bbb','ccc'] - Note that since Puppet 4.0.0 the same is in general done with the filter function. Here is the - equivalence of the reject() function: - - ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ } + > *Note:* + Since Puppet 4.0.0 the same is in general done with the filter function. Here is the equivalence of the reject() function: + ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~ /aaa/ } DOC if args.size != 2 diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/reverse.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/reverse.rb index 9f7db8b2f..8b97a9731 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/reverse.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/reverse.rb @@ -3,9 +3,13 @@ # module Puppet::Parser::Functions newfunction(:reverse, :type => :rvalue, :doc => <<-DOC - Reverses the order of a string or array. + @summary + Reverses the order of a string or array. - Note that the same can be done with the reverse_each() function in Puppet. + @return + reversed string or array + + > *Note:* that the same can be done with the reverse_each() function in Puppet. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb index aaef51a25..12067bad9 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/round.rb @@ -3,20 +3,20 @@ # module Puppet::Parser::Functions newfunction(:round, :type => :rvalue, :doc => <<-DOC - Rounds a number to the nearest integer + @summary + Rounds a number to the nearest integer - *Examples:* + @return + the rounded value as integer - round(2.9) + @example - returns: 3 + ```round(2.9)``` returns ```3``` - round(2.4) + ```round(2.4)``` returns ```2``` - returns: 2 - - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core - will be used instead of this function. + > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core + will be used instead of this function. DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/rstrip.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/rstrip.rb index e2cee40bd..fc809c8bf 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/rstrip.rb @@ -3,9 +3,13 @@ # module Puppet::Parser::Functions newfunction(:rstrip, :type => :rvalue, :doc => <<-DOC - Strips leading spaces to the right of the string. + @summary + Strips leading spaces to the right of the string. - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core + @return + the string with leading spaces removed + + > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core will be used instead of this function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb index 0120b87b4..c51e248f4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/seeded_rand.rb @@ -6,7 +6,15 @@ Puppet::Parser::Functions.newfunction( :arity => 2, :type => :rvalue, :doc => <<-DOC - Usage: `seeded_rand(MAX, SEED)`. MAX must be a positive integer; SEED is any string. + @summary + Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness. + + @return + random number greater than or equal to 0 and less than MAX + + @example **Usage:** + seeded_rand(MAX, SEED). + MAX must be a positive integer; SEED is any string. Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness. If SEED diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb index 96fea2088..0cf07e59e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_escape.rb @@ -4,9 +4,13 @@ require 'shellwords' # module Puppet::Parser::Functions newfunction(:shell_escape, :type => :rvalue, :doc => <<-DOC - Escapes a string so that it can be safely used in a Bourne shell command line. + @summary + Escapes a string so that it can be safely used in a Bourne shell command line. - Note that the resulting string should be used unquoted and is not intended for use in double quotes nor in single + @return + A string of characters with metacharacters converted to their escaped form. + + >* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single quotes. This function behaves the same as ruby's Shellwords.shellescape() function. diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb index 0a037c1f9..e498f55e1 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_join.rb @@ -5,10 +5,13 @@ require 'shellwords' # module Puppet::Parser::Functions newfunction(:shell_join, :type => :rvalue, :doc => <<-DOC - Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are - then joined together, with a single space in between. - + @summary + Builds a command line string from the given array of strings. + Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between. This function behaves the same as ruby's Shellwords.shelljoin() function + + @return + a command line string DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb index 9dcf95884..7c9f12375 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb @@ -4,7 +4,11 @@ require 'shellwords' # module Puppet::Parser::Functions newfunction(:shell_split, :type => :rvalue, :doc => <<-DOC - Splits a string into an array of tokens in the same way the Bourne shell does. + @summary + Splits a string into an array of tokens in the same way the Bourne shell does. + + @return + array of tokens This function behaves the same as ruby's Shellwords.shellsplit() function DOC diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shuffle.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shuffle.rb index 5e6d93b6f..3e10739a5 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shuffle.rb @@ -3,7 +3,11 @@ # module Puppet::Parser::Functions newfunction(:shuffle, :type => :rvalue, :doc => <<-DOC + @summary Randomizes the order of a string or array elements. + + @return + randomized string or array DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb index 2002a3df5..39b856c1b 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/size.rb @@ -3,9 +3,13 @@ # module Puppet::Parser::Functions newfunction(:size, :type => :rvalue, :doc => <<-DOC - Returns the number of elements in a string, an array or a hash + @summary + Returns the number of elements in a string, an array or a hash - Note that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions + @return + the number of elements in a string, an array or a hash + + > *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions of Puppet < 5.4.0 use the stdlib length() function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb index 65308da5e..a6e0509dc 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/sort.rb @@ -4,7 +4,11 @@ # module Puppet::Parser::Functions newfunction(:sort, :type => :rvalue, :doc => <<-DOC - Sorts strings and arrays lexically. + @summary + Sorts strings and arrays lexically. + + @return + sorted string or array Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this. DOC diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/squeeze.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/squeeze.rb index eaa140414..548c93313 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/squeeze.rb @@ -3,7 +3,11 @@ # module Puppet::Parser::Functions newfunction(:squeeze, :type => :rvalue, :doc => <<-DOC - Returns a new string where runs of the same character that occur in this set are replaced by a single character. + @summary + Returns a new string where runs of the same character that occur in this set are replaced by a single character. + + @return + a new string where runs of the same character that occur in this set are replaced by a single character. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2bool.rb index 5f8b8fecd..165cf5d64 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2bool.rb @@ -3,11 +3,14 @@ # module Puppet::Parser::Functions newfunction(:str2bool, :type => :rvalue, :doc => <<-DOC - This converts a string to a boolean. This attempt to convert strings that - contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things - like: 0, F,f, N,n, false, FALSE, no to 'false'. + @summary + This converts a string to a boolean. - Note that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value. + @return + This attempt to convert to boolean strings that contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things + like: 0, F,f, N,n, false, FALSE, no to 'false'. + + > *Note:* that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value. See the function new() in Puppet for details what the Boolean data type supports. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb index 4d62008b7..8b1c2c997 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb @@ -4,8 +4,14 @@ # module Puppet::Parser::Functions newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-DOC - This converts a string to a salted-SHA512 password hash (which is used for - OS X versions >= 10.7). Given any simple string, you will get a hex version + @summary + This converts a string to a salted-SHA512 password hash (which is used for + OS X versions >= 10.7). + + @return + converted string as a hex version of a salted-SHA512 password hash + + Given any simple string, you will get a hex version of a salted-SHA512 password hash that can be inserted into your Puppet manifests as a valid password attribute. DOC diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/strftime.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/strftime.rb index 045d25681..50ee4bc33 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/strftime.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/strftime.rb @@ -4,22 +4,21 @@ # module Puppet::Parser::Functions newfunction(:strftime, :type => :rvalue, :doc => <<-DOC - This function returns formatted time. + @summary + This function returns formatted time. - Note that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this - function. It also supports the Timestamp and Timespan data types in the Puppet language. - - *Examples:* + @return + converted time according to the directives in the given format string - To return the time since epoch: - - strftime("%s") + > *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this + function. It also supports the Timestamp and Timespan data types in the Puppet language. - To return the date: + @example **Usage** - strftime("%Y-%m-%d") + To return the time since epoch: strftime("%s") + To return the date: strftime("%Y-%m-%d") - *Format meaning:* + **Format meaning:** %a - The abbreviated weekday name (``Sun'') %A - The full weekday name (``Sunday'') diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb index 59d15a33a..067af001d 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/strip.rb @@ -3,16 +3,19 @@ # module Puppet::Parser::Functions newfunction(:strip, :type => :rvalue, :doc => <<-DOC - This function removes leading and trailing whitespace from a string or from - every string inside an array. + @summary + This function removes leading and trailing whitespace from a string or from + every string inside an array. - *Examples:* + @return + String or Array converted - strip(" aaa ") + @example **Usage** - Would result in: "aaa" + strip(" aaa ") + Would result in: "aaa" - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core + > *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core will be used instead of this function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/suffix.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/suffix.rb index 72ff08dd7..643d7223a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/suffix.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/suffix.rb @@ -3,19 +3,22 @@ # module Puppet::Parser::Functions newfunction(:suffix, :type => :rvalue, :doc => <<-DOC - This function applies a suffix to all elements in an array, or to the keys - in a hash. + @summary + This function applies a suffix to all elements in an array, or to the keys + in a hash. - *Examples:* + @return + Array or Hash with updated elements containing the passed suffix - suffix(['a','b','c'], 'p') + @example **Usage** - Will return: ['ap','bp','cp'] + suffix(['a','b','c'], 'p') + Will return: ['ap','bp','cp'] - Note that since Puppet 4.0.0 the general way to modify values is in array is by using the map + > *Note:* that since Puppet 4.0.0 the general way to modify values is in array is by using the map function in Puppet. This example does the same as the example above: - ['a', 'b', 'c'].map |$x| { "${x}p" } + ```['a', 'b', 'c'].map |$x| { "${x}p" }``` DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/swapcase.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/swapcase.rb index e8a5d9a8f..dd17330b3 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/swapcase.rb @@ -4,13 +4,16 @@ # module Puppet::Parser::Functions newfunction(:swapcase, :type => :rvalue, :doc => <<-DOC - This function will swap the existing case of a string. + @summary + This function will swap the existing case of a string. - *Examples:* + @return + string with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase - swapcase("aBcD") + @example **Usage** - Would result in: "AbCd" + swapcase("aBcD") + Would result in: "AbCd" DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/time.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/time.rb index 9f2e3c8c7..d123cf68a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/time.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/time.rb @@ -3,19 +3,22 @@ # module Puppet::Parser::Functions newfunction(:time, :type => :rvalue, :doc => <<-DOC - This function will return the current time since epoch as an integer. + @summary + This function will return the current time since epoch as an integer. - *Examples:* + @return + the current time since epoch as an integer. - time() + @example **Usage** - Will return something like: 1311972653 + time() + Will return something like: 1311972653 - Note that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and + > *Note:* that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and Timespan (a duration). The following example is equivalent to calling time() without any arguments: - Timestamp() + ```Timestamp()``` DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb index bff24b070..b7de587ff 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb @@ -3,7 +3,12 @@ # module Puppet::Parser::Functions newfunction(:to_bytes, :type => :rvalue, :doc => <<-DOC - Converts the argument into bytes, for example 4 kB becomes 4096. + @summary + Converts the argument into bytes, for example 4 kB becomes 4096. + + @return + converted value into bytes + Takes a single string value as an argument. These conversions reflect a layperson's understanding of 1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB. diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb index 34f94762e..26c0b2d77 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/try_get_value.rb @@ -7,14 +7,16 @@ module Puppet::Parser::Functions :type => :rvalue, :arity => -2, :doc => <<-DOC - DEPRECATED: this function is deprecated, please use dig() instead. + @summary + **DEPRECATED:** this function is deprecated, please use dig() instead. - Looks up into a complex structure of arrays and hashes and returns a value - or the default value if nothing was found. + @return + Looks up into a complex structure of arrays and hashes and returns a value + or the default value if nothing was found. Key can contain slashes to describe path components. The function will go down the structure and try to extract the required value. - + `` $data = { 'a' => { 'b' => [ @@ -27,13 +29,15 @@ module Puppet::Parser::Functions $value = try_get_value($data, 'a/b/2', 'not_found', '/') => $value = 'b3' - + ``` + ``` a -> first hash key b -> second hash key 2 -> array index starting with 0 not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil. / -> (optional) path delimiter. Defaults to '/'. + ``` In addition to the required "key" argument, "try_get_value" accepts default argument. It will be returned if no value was found or a path component is diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/type.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/type.rb index 9fcae7a89..6b0140827 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/type.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/type.rb @@ -3,7 +3,18 @@ # module Puppet::Parser::Functions newfunction(:type, :type => :rvalue, :doc => <<-DOC - DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system. + @summary + **DEPRECATED:** This function will cease to function on Puppet 4; + please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system. + + @return the type when passed a value. Type can be one of: + + * string + * array + * hash + * float + * integer + * boolean DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb index 950171d38..e8d90d838 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb @@ -3,9 +3,10 @@ # module Puppet::Parser::Functions newfunction(:type3x, :type => :rvalue, :doc => <<-DOC - DEPRECATED: This function will be removed when Puppet 3 support is dropped; please migrate to the new parser's typing system. + @summary + **DEPRECATED:** This function will be removed when Puppet 3 support is dropped; please migrate to the new parser's typing system. - Returns the type when passed a value. Type can be one of: + @return the type when passed a value. Type can be one of: * string * array diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/union.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/union.rb index ed57bc5d9..ac521e55c 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/union.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/union.rb @@ -3,13 +3,15 @@ # module Puppet::Parser::Functions newfunction(:union, :type => :rvalue, :doc => <<-DOC - This function returns a union of two or more arrays. + @summary + This function returns a union of two or more arrays. - *Examples:* + @return + a unionized array of two or more arrays + @example **Usage** - union(["a","b","c"],["b","c","d"]) - - Would return: ["a","b","c","d"] + union(["a","b","c"],["b","c","d"]) + Would return: ["a","b","c","d"] DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/unique.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/unique.rb index 301f6a410..c9eaa08ef 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/unique.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/unique.rb @@ -3,23 +3,22 @@ # module Puppet::Parser::Functions newfunction(:unique, :type => :rvalue, :doc => <<-DOC - This function will remove duplicates from strings and arrays. + @summary + This function will remove duplicates from strings and arrays. - *Examples:* + @return + String or array with duplicates removed - unique("aabbcc") + @example **Usage** - Will return: + unique("aabbcc") + Will return: abc - abc + You can also use this with arrays: - You can also use this with arrays: + unique(["a","a","b","b","c","c"]) + This returns: ["a","b","c"] - unique(["a","a","b","b","c","c"]) - - This returns: - - ["a","b","c"] DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb index 8123797f4..91b259672 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/unix2dos.rb @@ -1,7 +1,12 @@ # Custom Puppet function to convert unix to dos format module Puppet::Parser::Functions newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-DOC - Returns the DOS version of the given string. + @summary + Returns the DOS version of the given string. + + @return + the DOS version of the given string. + Takes a single string argument. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/upcase.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/upcase.rb index 563efe4b5..de0797039 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/upcase.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/upcase.rb @@ -4,17 +4,18 @@ # module Puppet::Parser::Functions newfunction(:upcase, :type => :rvalue, :doc => <<-DOC - Converts a string or an array of strings to uppercase. + @summary + Converts a string or an array of strings to uppercase. - *Examples:* + @return + converted string ot array of strings to uppercase - upcase("abcd") + @example **Usage** - Will return: + upcase("abcd") + Will return ABCD - ABCD - - Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core + > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core will be used instead of this function. DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/uriescape.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/uriescape.rb index 8bcd586cf..4078b86c4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/uriescape.rb @@ -5,8 +5,13 @@ require 'uri' # module Puppet::Parser::Functions newfunction(:uriescape, :type => :rvalue, :doc => <<-DOC - Urlencodes a string or array of strings. - Requires either a single string or an array as an input. + @summary + Urlencodes a string or array of strings. + Requires either a single string or an array as an input. + + @return [String] + a string that contains the converted value + DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb index 0db10c3f5..7d794452f 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb @@ -2,31 +2,36 @@ # validate_absolute_path.rb # module Puppet::Parser::Functions - newfunction(:validate_absolute_path, :doc => <<-'DOC') do |args| - Validate the string represents an absolute path in the filesystem. This function works - for windows and unix style paths. - - The following values will pass: - - $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' - validate_absolute_path($my_path) - $my_path2 = '/var/lib/puppet' - validate_absolute_path($my_path2) - $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] - validate_absolute_path($my_path3) - $my_path4 = ['/var/lib/puppet','/usr/share/puppet'] - validate_absolute_path($my_path4) - - The following values will fail, causing compilation to abort: - - validate_absolute_path(true) - validate_absolute_path('../var/lib/puppet') - validate_absolute_path('var/lib/puppet') - validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) - validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) - $undefined = undef - validate_absolute_path($undefined) - + newfunction(:validate_absolute_path, :doc => <<-DOC) do |args| + @summary + Validate the string represents an absolute path in the filesystem. This function works + for windows and unix style paths. + + @return + passes when the string is an absolute path or raise an error when it is not and fails compilation + + @example **Usage** + + The following values will pass: + + $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet' + validate_absolute_path($my_path) + $my_path2 = '/var/lib/puppet' + validate_absolute_path($my_path2) + $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet'] + validate_absolute_path($my_path3) + $my_path4 = ['/var/lib/puppet','/usr/share/puppet'] + validate_absolute_path($my_path4) + + The following values will fail, causing compilation to abort: + + validate_absolute_path(true) + validate_absolute_path('../var/lib/puppet') + validate_absolute_path('var/lib/puppet') + validate_absolute_path([ 'var/lib/puppet', '/var/foo' ]) + validate_absolute_path([ '/var/lib/puppet', 'var/foo' ]) + $undefined = undef + validate_absolute_path($undefined) DOC require 'puppet/util' diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_array.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_array.rb index 1120ce8bb..d24f75e48 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_array.rb @@ -2,23 +2,27 @@ # validate_array.rb # module Puppet::Parser::Functions - newfunction(:validate_array, :doc => <<-'DOC') do |args| - Validate that all passed values are array data structures. Abort catalog - compilation if any value fails this check. + newfunction(:validate_array, :doc => <<-DOC) do |args| + @summary + Validate that all passed values are array data structures. Abort catalog + compilation if any value fails this check. - The following values will pass: + @return + validate array - $my_array = [ 'one', 'two' ] - validate_array($my_array) + @example **Usage** + The following values will pass: - The following values will fail, causing compilation to abort: + $my_array = [ 'one', 'two' ] + validate_array($my_array) - validate_array(true) - validate_array('some_string') - $undefined = undef - validate_array($undefined) + The following values will fail, causing compilation to abort: - DOC + validate_array(true) + validate_array('some_string') + $undefined = undef + validate_array($undefined) + DOC function_deprecation([:validate_array, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb index 97f3127e3..26e51e8ff 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb @@ -4,8 +4,10 @@ require 'tempfile' # validate_augaes.rb # module Puppet::Parser::Functions - newfunction(:validate_augeas, :doc => <<-'DOC') do |args| - Perform validation of a string using an Augeas lens + newfunction(:validate_augeas, :doc => <<-DOC + @summary + Perform validation of a string using an Augeas lens + The first argument of this function should be a string to test, and the second argument should be the name of the Augeas lens to use. If Augeas fails to parse the string with the lens, the compilation will @@ -15,24 +17,30 @@ module Puppet::Parser::Functions not be found in the file. The `$file` variable points to the location of the temporary file being tested in the Augeas tree. - For example, if you want to make sure your passwd content never contains - a user `foo`, you could write: + @return + validate string using an Augeas lens + + @example **Usage** + + If you want to make sure your passwd content never contains + a user `foo`, you could write: validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo']) - Or if you wanted to ensure that no users used the '/bin/barsh' shell, - you could use: + If you wanted to ensure that no users used the '/bin/barsh' shell, + you could use: validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]'] - If a fourth argument is specified, this will be the error message raised and - seen by the user. + If a fourth argument is specified, this will be the error message raised and + seen by the user. - A helpful error message can be returned like this: + A helpful error message can be returned like this: validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') DOC + ) do |args| unless Puppet.features.augeas? raise Puppet::ParseError, 'validate_augeas(): this function requires the augeas feature. See http://docs.puppetlabs.com/guides/augeas.html#pre-requisites for how to activate it.' end diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb index d3bf3d021..d6f07af00 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb @@ -2,25 +2,30 @@ # validate_bool.rb # module Puppet::Parser::Functions - newfunction(:validate_bool, :doc => <<-'DOC') do |args| - Validate that all passed values are either true or false. Abort catalog - compilation if any value fails this check. + newfunction(:validate_bool, :doc => <<-DOC + @summary + Validate that all passed values are either true or false. Abort catalog + compilation if any value fails this check. - The following values will pass: + @return + validate boolean - $iamtrue = true - validate_bool(true) - validate_bool(true, true, false, $iamtrue) + @example **Usage** - The following values will fail, causing compilation to abort: + The following values will pass: - $some_array = [ true ] - validate_bool("false") - validate_bool("true") - validate_bool($some_array) + $iamtrue = true + validate_bool(true) + validate_bool(true, true, false, $iamtrue) - DOC + The following values will fail, causing compilation to abort: + $some_array = [ true ] + validate_bool("false") + validate_bool("true") + validate_bool($some_array) + DOC + ) do |args| if args.empty? raise Puppet::ParseError, "validate_bool(): wrong number of arguments (#{args.length}; must be > 0)" end diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb index dbea604df..592d0ee32 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb @@ -5,28 +5,33 @@ require 'tempfile' # validate_cmd.rb # module Puppet::Parser::Functions - newfunction(:validate_cmd, :doc => <<-'DOC') do |args| - Perform validation of a string with an external command. + newfunction(:validate_cmd, :doc => <<-DOC + @summary + Perform validation of a string with an external command. + The first argument of this function should be a string to test, and the second argument should be a path to a test command taking a % as a placeholder for the file path (will default to the end). If the command, launched against a tempfile containing the passed string, returns a non-null value, compilation will abort with a parse error. - If a third argument is specified, this will be the error message raised and seen by the user. + @return + validate of a string with an external command + A helpful error message can be returned like this: - Example: + @example **Usage** - # Defaults to end of path + Defaults to end of path validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content') - # % as file location + % as file location validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') DOC + ) do |args| if (args.length < 2) || (args.length > 3) raise Puppet::ParseError, "validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)" end diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb index c479dfb43..f3dc1d5f1 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_domain_name.rb @@ -3,23 +3,28 @@ # module Puppet::Parser::Functions newfunction(:validate_domain_name, :doc => <<-DOC - Validate that all values passed are syntactically correct domain names. - Fail compilation if any value fails this check. + @summary + Validate that all values passed are syntactically correct domain names. + Fail compilation if any value fails this check. - The following values will pass: + @return + passes when the given values are syntactically correct domain names or raise an error when they are not and fails compilation - $my_domain_name = 'server.domain.tld' - validate_domain_name($my_domain_name) - validate_domain_name('domain.tld', 'puppet.com', $my_domain_name) + @example **Usage** - The following values will fail, causing compilation to abort: + The following values will pass: - validate_domain_name(1) - validate_domain_name(true) - validate_domain_name('invalid domain') - validate_domain_name('-foo.example.com') - validate_domain_name('www.example.2com') + $my_domain_name = 'server.domain.tld' + validate_domain_name($my_domain_name) + validate_domain_name('domain.tld', 'puppet.com', $my_domain_name) + The following values will fail, causing compilation to abort: + + validate_domain_name(1) + validate_domain_name(true) + validate_domain_name('invalid domain') + validate_domain_name('-foo.example.com') + validate_domain_name('www.example.2com') DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb index a039f5105..5ad983a30 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_email_address.rb @@ -3,16 +3,25 @@ # module Puppet::Parser::Functions newfunction(:validate_email_address, :doc => <<-DOC - Validate that all values passed are valid email addresses. - Fail compilation if any value fails this check. - The following values will pass: - $my_email = "waldo@gmail.com" - validate_email_address($my_email) - validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) - - The following values will fail, causing compilation to abort: - $some_array = [ 'bad_email@/d/efdf.com' ] - validate_email_address($some_array) + @summary + Validate that all values passed are valid email addresses. + Fail compilation if any value fails this check. + + @return + Fail compilation if any value fails this check. + + @example **Usage** + + The following values will pass: + + $my_email = "waldo@gmail.com" + validate_email_address($my_email) + validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) + + The following values will fail, causing compilation to abort: + + $some_array = [ 'bad_email@/d/efdf.com' ] + validate_email_address($some_array) DOC ) do |args| rescuable_exceptions = [ArgumentError] diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb index 0460cf35b..c3b0dfdc6 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb @@ -2,23 +2,29 @@ # validate_hash.rb # module Puppet::Parser::Functions - newfunction(:validate_hash, :doc => <<-'DOC') do |args| - Validate that all passed values are hash data structures. Abort catalog - compilation if any value fails this check. + newfunction(:validate_hash, :doc => <<-DOC + @summary + Validate that all passed values are hash data structures. Abort catalog + compilation if any value fails this check. - The following values will pass: + @return + validate hash - $my_hash = { 'one' => 'two' } - validate_hash($my_hash) + @example **Usage** - The following values will fail, causing compilation to abort: + The following values will pass: - validate_hash(true) - validate_hash('some_string') - $undefined = undef - validate_hash($undefined) + $my_hash = { 'one' => 'two' } + validate_hash($my_hash) + The following values will fail, causing compilation to abort: + + validate_hash(true) + validate_hash('some_string') + $undefined = undef + validate_hash($undefined) DOC + ) do |args| function_deprecation([:validate_hash, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb index fc50bdc92..6a56d5c71 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_integer.rb @@ -2,59 +2,63 @@ # validate_interger.rb # module Puppet::Parser::Functions - newfunction(:validate_integer, :doc => <<-'DOC') do |args| - Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail. + newfunction(:validate_integer, :doc => <<-DOC + @summary + Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail. The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. - The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check if (all elements of) the first argument are greater or equal to the given minimum. - It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer. - The following values will pass: - - validate_integer(1) - validate_integer(1, 2) - validate_integer(1, 1) - validate_integer(1, 2, 0) - validate_integer(2, 2, 2) - validate_integer(2, '', 0) - validate_integer(2, undef, 0) - $foo = undef - validate_integer(2, $foo, 0) - validate_integer([1,2,3,4,5], 6) - validate_integer([1,2,3,4,5], 6, 0) - - Plus all of the above, but any combination of values passed as strings ('1' or "1"). - Plus all of the above, but with (correct) combinations of negative integer values. - - The following values will not: - - validate_integer(true) - validate_integer(false) - validate_integer(7.0) - validate_integer({ 1 => 2 }) - $foo = undef - validate_integer($foo) - validate_integer($foobaridontexist) - - validate_integer(1, 0) - validate_integer(1, true) - validate_integer(1, '') - validate_integer(1, undef) - validate_integer(1, , 0) - validate_integer(1, 2, 3) - validate_integer(1, 3, 2) - validate_integer(1, 3, true) - - Plus all of the above, but any combination of values passed as strings ('false' or "false"). - Plus all of the above, but with incorrect combinations of negative integer values. - Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. + @return + Validate that the first argument is an integer (or an array of integers). Fail compilation if any of the checks fail. + + @example **Usage** + + The following values will pass: + + validate_integer(1) + validate_integer(1, 2) + validate_integer(1, 1) + validate_integer(1, 2, 0) + validate_integer(2, 2, 2) + validate_integer(2, '', 0) + validate_integer(2, undef, 0) + $foo = undef + validate_integer(2, $foo, 0) + validate_integer([1,2,3,4,5], 6) + validate_integer([1,2,3,4,5], 6, 0) + + Plus all of the above, but any combination of values passed as strings ('1' or "1"). + Plus all of the above, but with (correct) combinations of negative integer values. + + The following values will not: + + validate_integer(true) + validate_integer(false) + validate_integer(7.0) + validate_integer({ 1 => 2 }) + $foo = undef + validate_integer($foo) + validate_integer($foobaridontexist) + + validate_integer(1, 0) + validate_integer(1, true) + validate_integer(1, '') + validate_integer(1, undef) + validate_integer(1, , 0) + validate_integer(1, 2, 3) + validate_integer(1, 3, 2) + validate_integer(1, 3, true) + + Plus all of the above, but any combination of values passed as strings ('false' or "false"). + Plus all of the above, but with incorrect combinations of negative integer values. + Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. DOC - + ) do |args| function_deprecation([:validate_integer, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb index af835adf0..3fd582b0e 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ip_address.rb @@ -3,22 +3,30 @@ # module Puppet::Parser::Functions newfunction(:validate_ip_address, :doc => <<-DOC - Validate that all values passed are valid IP addresses, - regardless they are IPv4 or IPv6 - Fail compilation if any value fails this check. - The following values will pass: - $my_ip = "1.2.3.4" - validate_ip_address($my_ip) - validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip) - - $my_ip = "3ffe:505:2" - validate_ip_address(1) - validate_ip_address($my_ip) - validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip) - - The following values will fail, causing compilation to abort: - $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] - validate_ip_address($some_array) + @summary + Validate that all values passed are valid IP addresses, + regardless they are IPv4 or IPv6 + Fail compilation if any value fails this check. + + @return + passes when the given values are valid IP addresses or raise an error when they are not and fails compilation + + @example **Usage** + The following values will pass: + + $my_ip = "1.2.3.4" + validate_ip_address($my_ip) + validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip) + + $my_ip = "3ffe:505:2" + validate_ip_address(1) + validate_ip_address($my_ip) + validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip) + + The following values will fail, causing compilation to abort: + + $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] + validate_ip_address($some_array) DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb index 1ac303f10..1f3223fab 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb @@ -3,20 +3,24 @@ # module Puppet::Parser::Functions newfunction(:validate_ipv4_address, :doc => <<-DOC - Validate that all values passed are valid IPv4 addresses. - Fail compilation if any value fails this check. + @summary + Validate that all values passed are valid IPv4 addresses. + Fail compilation if any value fails this check. - The following values will pass: + @return + passes when the given values are valid IPv4 addresses or raise an error when they are not and fails compilation - $my_ip = "1.2.3.4" - validate_ipv4_address($my_ip) - validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip) + @example **Usage** + The following values will pass: - The following values will fail, causing compilation to abort: + $my_ip = "1.2.3.4" + validate_ipv4_address($my_ip) + validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip) - $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] - validate_ipv4_address($some_array) + The following values will fail, causing compilation to abort: + $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] + validate_ipv4_address($some_array) DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb index 88c133cd2..b1f33fedc 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb @@ -3,20 +3,25 @@ # module Puppet::Parser::Functions newfunction(:validate_ipv6_address, :doc => <<-DOC - Validate that all values passed are valid IPv6 addresses. - Fail compilation if any value fails this check. + @summary + Validate that all values passed are valid IPv6 addresses. + Fail compilation if any value fails this check. - The following values will pass: + @return + passes when the given values are valid IPv6 addresses or raise an error when they are not and fails compilation - $my_ip = "3ffe:505:2" - validate_ipv6_address(1) - validate_ipv6_address($my_ip) - validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip) + @example **Usage** + The following values will pass: - The following values will fail, causing compilation to abort: + $my_ip = "3ffe:505:2" + validate_ipv6_address(1) + validate_ipv6_address($my_ip) + validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip) - $some_array = [ true, false, "garbage string", "1.2.3.4" ] - validate_ipv6_address($some_array) + The following values will fail, causing compilation to abort: + + $some_array = [ true, false, "garbage string", "1.2.3.4" ] + validate_ipv6_address($some_array) DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb index 803e6f01a..6ccdb0e96 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_numeric.rb @@ -2,21 +2,23 @@ # validate_numeric.rb # module Puppet::Parser::Functions - newfunction(:validate_numeric, :doc => <<-'DOC') do |args| - Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail. + newfunction(:validate_numeric, :doc => <<-DOC + @summary + Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail. The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. - The third argument is optional and passes a minimum. (All elements of) the first argument has to be greater or equal to this min. If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check if (all elements of) the first argument are greater or equal to the given minimum. - It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric. + @return + Validate that the first argument is a numeric value (or an array of numeric values). Fail compilation if any of the checks fail. + For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too. DOC - + ) do |args| function_deprecation([:validate_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_re.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_re.rb index 88f23fcc7..14ad7abd4 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_re.rb @@ -2,17 +2,23 @@ # validate.rb # module Puppet::Parser::Functions - newfunction(:validate_re, :doc => <<-'DOC') do |args| + newfunction(:validate_re, :doc => <<-DOC + @summary Perform simple validation of a string against one or more regular - expressions. The first argument of this function should be a string to - test, and the second argument should be a stringified regular expression - (without the // delimiters) or an array of regular expressions. If none - of the regular expressions match the string passed in, compilation will - abort with a parse error. + expressions. - If a third argument is specified, this will be the error message raised and - seen by the user. + The first argument of this function should be a string to + test, and the second argument should be a stringified regular expression + (without the // delimiters) or an array of regular expressions. If none + of the regular expressions match the string passed in, compilation will + abort with a parse error. + If a third argument is specified, this will be the error message raised and + seen by the user. + @return + validation of a string against one or more regular expressions. + + @example **Usage** The following strings will validate against the regular expressions: validate_re('one', '^one$') @@ -26,13 +32,12 @@ module Puppet::Parser::Functions validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7') - Note: Compilation will also abort, if the first argument is not a String. Always use - quotes to force stringification: - - validate_re("${::operatingsystemmajrelease}", '^[57]$') - - DOC - + > *Note:* + Compilation will also abort, if the first argument is not a String. Always use + quotes to force stringification: + validate_re("${::operatingsystemmajrelease}", '^[57]$') + DOC + ) do |args| function_deprecation([:validate_re, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Re. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb index db5010e2a..c28650fcd 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb @@ -2,27 +2,29 @@ # validate_slength.rb # module Puppet::Parser::Functions - newfunction(:validate_slength, :doc => <<-'DOC') do |args| - Validate that the first argument is a string (or an array of strings), and - less/equal to than the length of the second argument. An optional third - parameter can be given the minimum length. It fails if the first - argument is not a string or array of strings, and if arg 2 and arg 3 are - not convertable to a number. + newfunction(:validate_slength, :doc => <<-DOC + @summary + Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. + An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings, + and if arg 2 and arg 3 are not convertable to a number. - The following values will pass: + @return + validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. Fail compilation if any of the checks fail. - validate_slength("discombobulate",17) - validate_slength(["discombobulate","moo"],17) - validate_slength(["discombobulate","moo"],17,3) + @example **Usage** + The following values will pass: - The following valueis will not: + validate_slength("discombobulate",17) + validate_slength(["discombobulate","moo"],17) + validate_slength(["discombobulate","moo"],17,3) - validate_slength("discombobulate",1) - validate_slength(["discombobulate","thermometer"],5) - validate_slength(["discombobulate","moo"],17,10) + The following valueis will not: + validate_slength("discombobulate",1) + validate_slength(["discombobulate","thermometer"],5) + validate_slength(["discombobulate","moo"],17,10) DOC - + ) do |args| function_deprecation([:validate_slength, 'This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_string.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_string.rb index c2847b648..f6c52a711 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_string.rb @@ -2,29 +2,34 @@ # validate_String.rb # module Puppet::Parser::Functions - newfunction(:validate_string, :doc => <<-'DOC') do |args| - Validate that all passed values are string data structures. Abort catalog - compilation if any value fails this check. + newfunction(:validate_string, :doc => <<-DOC + @summary + Validate that all passed values are string data structures - The following values will pass: + @return + Validate that all passed values are string data structures. Failed + compilation if any value fails this check. - $my_string = "one two" - validate_string($my_string, 'three') + @example **Usage** + The following values will pass: - The following values will fail, causing compilation to abort: + $my_string = "one two" + validate_string($my_string, 'three') - validate_string(true) - validate_string([ 'some', 'array' ]) + The following values will fail, causing compilation to abort: - Note: validate_string(undef) will not fail in this version of the + validate_string(true) + validate_string([ 'some', 'array' ]) + > *Note:* + Validate_string(undef) will not fail in this version of the functions API (incl. current and future parser). Instead, use: - - if $var == undef { - fail('...') + ``` + if $var == undef { + fail('...') } - + ``` DOC - + ) do |args| function_deprecation([:validate_string, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.']) diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb index ea69dc4be..93388e0d0 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb @@ -3,13 +3,15 @@ # module Puppet::Parser::Functions newfunction(:validate_x509_rsa_key_pair, :doc => <<-DOC - Validates a PEM-formatted X.509 certificate and RSA private key using - OpenSSL. Verifies that the certficate's signature was created from the - supplied key. + @summary + Validates a PEM-formatted X.509 certificate and RSA private key using + OpenSSL. Verifies that the certficate's signature was created from the + supplied key. - Fail compilation if any value fails this check. + @return + Fail compilation if any value fails this check. - validate_x509_rsa_key_pair($cert, $key) + ```validate_x509_rsa_key_pair($cert, $key)``` DOC ) do |args| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/values.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/values.rb index 91a0cb9ad..434ce6c91 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/values.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/values.rb @@ -3,24 +3,27 @@ # module Puppet::Parser::Functions newfunction(:values, :type => :rvalue, :doc => <<-DOC - When given a hash this function will return the values of that hash. + @summary + When given a hash this function will return the values of that hash. - *Examples:* + @return + array of values - $hash = { - 'a' => 1, - 'b' => 2, - 'c' => 3, - } - values($hash) + @example **Usage** + $hash = { + 'a' => 1, + 'b' => 2, + 'c' => 3, + } + values($hash) - This example would return: + This example would return: ```[1,2,3]``` - [1,2,3] - - Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core + > *Note:* + From Puppet 5.5.0, the compatible function with the same name in Puppet core will be used instead of this function. - DOC + + DOC ) do |arguments| raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb index cf53fa060..337104207 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb @@ -3,7 +3,8 @@ # module Puppet::Parser::Functions newfunction(:values_at, :type => :rvalue, :doc => <<-DOC - Finds value inside an array based on location. + @summary + Finds value inside an array based on location. The first argument is the array you want to analyze, and the second element can be a combination of: @@ -12,26 +13,28 @@ module Puppet::Parser::Functions * A range in the form of 'start-stop' (eg. 4-9) * An array combining the above - *Examples*: + @return + an array of values identified by location - values_at(['a','b','c'], 2) + @example **Usage** - Would return ['c']. + values_at(['a','b','c'], 2) + Would return ['c'] - values_at(['a','b','c'], ["0-1"]) + values_at(['a','b','c'], ["0-1"]) + Would return ['a','b'] - Would return ['a','b']. + values_at(['a','b','c','d','e'], [0, "2-3"]) + Would return ['a','c','d'] - values_at(['a','b','c','d','e'], [0, "2-3"]) - - Would return ['a','c','d']. - - Note that since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language. + > *Note:* + Since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language. A negative value is taken to be "from the end" of the array: - ['a', 'b', 'c', 'd'][1, 2] # results in ['b', 'c'] - ['a', 'b', 'c', 'd'][2, -1] # results in ['c', 'd'] - ['a', 'b', 'c', 'd'][1, -2] # results in ['b', 'c'] + `['a', 'b', 'c', 'd'][1, 2]` results in `['b', 'c']` + `['a', 'b', 'c', 'd'][2, -1]` results in `['c', 'd']` + `['a', 'b', 'c', 'd'][1, -2]` results in `['b', 'c']` + DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/zip.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/zip.rb index 87a89f824..120d09720 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/zip.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/zip.rb @@ -3,15 +3,15 @@ # module Puppet::Parser::Functions newfunction(:zip, :type => :rvalue, :doc => <<-DOC - Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments. + @summary + Takes one element from first array and merges corresponding elements from second array. - *Example:* + @return + This generates a sequence of n-element arrays, where n is one more than the count of arguments. - zip(['1','2','3'],['4','5','6']) - - Would result in: - - ["1", "4"], ["2", "5"], ["3", "6"] + @example + zip(['1','2','3'],['4','5','6']) + Would result in: ["1", "4"], ["2", "5"], ["3", "6"] DOC ) do |arguments| diff --git a/3rdparty/modules/stdlib/lib/puppet/provider/file_line/ruby.rb b/3rdparty/modules/stdlib/lib/puppet/provider/file_line/ruby.rb index 84233003f..f85ae85f8 100644 --- a/3rdparty/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +++ b/3rdparty/modules/stdlib/lib/puppet/provider/file_line/ruby.rb @@ -1,4 +1,13 @@ Puppet::Type.type(:file_line).provide(:ruby) do + desc <<-DOC + @summary + This type allows puppet to manage small config files. + + The implementation matches the full line, including whitespace at the + beginning and end. If the line is not contained in the given file, Puppet + will append the line to the end of the file to ensure the desired state. + Multiple resources may be declared to manage multiple lines in the same file. + DOC def exists? found = false lines_count = 0 diff --git a/3rdparty/modules/stdlib/lib/puppet/type/anchor.rb b/3rdparty/modules/stdlib/lib/puppet/type/anchor.rb index 60cfa6451..7458a4b98 100644 --- a/3rdparty/modules/stdlib/lib/puppet/type/anchor.rb +++ b/3rdparty/modules/stdlib/lib/puppet/type/anchor.rb @@ -1,6 +1,7 @@ Puppet::Type.newtype(:anchor) do - desc <<-'DESCRIPTION' - A simple resource type intended to be used as an anchor in a composite class. + desc <<-DOC + @summary + A simple resource type intended to be used as an anchor in a composite class. In Puppet 2.6, when a class declares another class, the resources in the interior class are not contained by the exterior class. This interacts badly @@ -12,32 +13,35 @@ Puppet::Type.newtype(:anchor) do classes between two no-op resources that _are_ contained by the exterior class, you can ensure that all resources in the module are contained. - class ntp { - # These classes will have the correct order relationship with each - # other. However, without anchors, they won't have any order - # relationship to Class['ntp']. - class { 'ntp::package': } - -> class { 'ntp::config': } - -> class { 'ntp::service': } - - # These two resources "anchor" the composed classes within the ntp - # class. - anchor { 'ntp::begin': } -> Class['ntp::package'] - Class['ntp::service'] -> anchor { 'ntp::end': } - } + ``` + class ntp { + # These classes will have the correct order relationship with each + # other. However, without anchors, they won't have any order + # relationship to Class['ntp']. + class { 'ntp::package': } + -> class { 'ntp::config': } + -> class { 'ntp::service': } + + # These two resources "anchor" the composed classes within the ntp + # class. + anchor { 'ntp::begin': } -> Class['ntp::package'] + Class['ntp::service'] -> anchor { 'ntp::end': } + } + ``` This allows the end user of the ntp module to establish require and before relationships with Class['ntp']: - class { 'ntp': } -> class { 'mcollective': } - class { 'mcollective': } -> class { 'ntp': } + ``` + class { 'ntp': } -> class { 'mcollective': } + class { 'mcollective': } -> class { 'ntp': } + ``` - DESCRIPTION + DOC newparam :name do desc 'The name of the anchor resource.' end - def refresh # We don't do anything with them, but we need this to # show that we are "refresh aware" and not break the diff --git a/3rdparty/modules/stdlib/lib/puppet/type/file_line.rb b/3rdparty/modules/stdlib/lib/puppet/type/file_line.rb index 14650fe06..ead6b1033 100644 --- a/3rdparty/modules/stdlib/lib/puppet/type/file_line.rb +++ b/3rdparty/modules/stdlib/lib/puppet/type/file_line.rb @@ -1,51 +1,57 @@ Puppet::Type.newtype(:file_line) do desc <<-DOC - Ensures that a given line is contained within a file. The implementation - matches the full line, including whitespace at the beginning and end. If - the line is not contained in the given file, Puppet will append the line to - the end of the file to ensure the desired state. Multiple resources may - be declared to manage multiple lines in the same file. - - Example: - - file_line { 'sudo_rule': - path => '/etc/sudoers', - line => '%sudo ALL=(ALL) ALL', - } - - file_line { 'sudo_rule_nopw': - path => '/etc/sudoers', - line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', - } - + @summary + Ensures that a given line is contained within a file. + + The implementation matches the full line, including whitespace at the + beginning and end. If the line is not contained in the given file, Puppet + will append the line to the end of the file to ensure the desired state. + Multiple resources may be declared to manage multiple lines in the same file. + + * Ensure Example + ``` + file_line { 'sudo_rule': + path => '/etc/sudoers', + line => '%sudo ALL=(ALL) ALL', + } + + file_line { 'sudo_rule_nopw': + path => '/etc/sudoers', + line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', + } + ``` In this example, Puppet will ensure both of the specified lines are contained in the file /etc/sudoers. - Match Example: + * Match Example - file_line { 'bashrc_proxy': - ensure => present, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - match => '^export\ HTTP_PROXY\=', - } + ``` + file_line { 'bashrc_proxy': + ensure => present, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + match => '^export\ HTTP_PROXY\=', + } + ``` In this code example match will look for a line beginning with export followed by HTTP_PROXY and replace it with the value in line. - Examples With `ensure => absent`: + * Examples With `ensure => absent`: This type has two behaviors when `ensure => absent` is set. One possibility is to set `match => ...` and `match_for_absence => true`, as in the following example: - file_line { 'bashrc_proxy': - ensure => absent, - path => '/etc/bashrc', - match => '^export\ HTTP_PROXY\=', - match_for_absence => true, - } + ``` + file_line { 'bashrc_proxy': + ensure => absent, + path => '/etc/bashrc', + match => '^export\ HTTP_PROXY\=', + match_for_absence => true, + } + ``` In this code example match will look for a line beginning with export followed by HTTP_PROXY and delete it. If multiple lines match, an @@ -57,25 +63,30 @@ Puppet::Type.newtype(:file_line) do The second way of using `ensure => absent` is to specify a `line => ...`, and no match: - file_line { 'bashrc_proxy': - ensure => absent, - path => '/etc/bashrc', - line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', - } + ``` + file_line { 'bashrc_proxy': + ensure => absent, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + } + ``` - Note that when ensuring lines are absent this way, the default behavior + > *Note:* + When ensuring lines are absent this way, the default behavior this time is to always remove all lines matching, and this behavior can't be disabled. - Encoding example: + * Encoding example: - file_line { "XScreenSaver": - ensure => present, - path => '/root/XScreenSaver', - line => "*lock: 10:00:00", - match => '^*lock:', - encoding => "iso-8859-1", - } + ``` + file_line { "XScreenSaver": + ensure => present, + path => '/root/XScreenSaver', + line => "*lock: 10:00:00", + match => '^*lock:', + encoding => "iso-8859-1", + } + ``` Files with special characters that are not valid UTF-8 will give the error message "invalid byte sequence in UTF-8". In this case, determine @@ -88,6 +99,7 @@ Puppet::Type.newtype(:file_line) do DOC ensurable do + desc 'Manage the state of this type.' defaultvalues defaultto :present end @@ -97,30 +109,30 @@ Puppet::Type.newtype(:file_line) do end newparam(:match) do - desc 'An optional ruby regular expression to run against existing lines in the file.' \ - ' If a match is found, we replace that line rather than adding a new line.' \ - ' A regex comparison is performed against the line value and if it does not' \ - ' match an exception will be raised.' + desc 'An optional ruby regular expression to run against existing lines in the file. + If a match is found, we replace that line rather than adding a new line. + A regex comparison is performed against the line value and if it does not + match an exception will be raised.' end newparam(:match_for_absence) do - desc 'An optional value to determine if match should be applied when ensure => absent.' \ - ' If set to true and match is set, the line that matches match will be deleted.' \ - ' If set to false (the default), match is ignored when ensure => absent.' \ - ' When `ensure => present`, match_for_absence is ignored.' + desc 'An optional value to determine if match should be applied when ensure => absent. + If set to true and match is set, the line that matches match will be deleted. + If set to false (the default), match is ignored when ensure => absent. + When `ensure => present`, match_for_absence is ignored.' newvalues(true, false) defaultto false end newparam(:multiple) do - desc 'An optional value to determine if match can change multiple lines.' \ - ' If set to false, an exception will be raised if more than one line matches' + desc 'An optional value to determine if match can change multiple lines. + If set to false, an exception will be raised if more than one line matches' newvalues(true, false) end newparam(:after) do - desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)' \ - ' This is also takes a regex.' + desc 'An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place) + This is also takes a regex.' end # The line property never changes; the type only ever performs a create() or @@ -172,7 +184,6 @@ Puppet::Type.newtype(:file_line) do autorequire(:file) do self[:path] end - validate do if self[:replace_all_matches_not_matching_line].to_s == 'true' && self[:multiple].to_s == 'false' raise(Puppet::Error, 'multiple must be true when replace_all_matches_not_matching_line is true') diff --git a/3rdparty/modules/stdlib/manifests/init.pp b/3rdparty/modules/stdlib/manifests/init.pp index 9ea22a737..01776d08d 100644 --- a/3rdparty/modules/stdlib/manifests/init.pp +++ b/3rdparty/modules/stdlib/manifests/init.pp @@ -1,17 +1,11 @@ -# Class: stdlib -# -# This module manages stdlib. Most of stdlib's features are automatically -# loaded by Puppet, but this class should be declared in order to use the -# standardized run stages. -# -# Parameters: none -# -# Actions: -# -# Declares all other classes in the stdlib module. Currently, this consists -# of stdlib::stages. -# -# Requires: nothing +# @summary +# This module manages stdlib. +# +# Most of stdlib's features are automatically loaded by Puppet, but this class should be +# declared in order to use the standardized run stages. +# +# Declares all other classes in the stdlib module. Currently, this consists +# of stdlib::stages. # class stdlib { include ::stdlib::stages diff --git a/3rdparty/modules/stdlib/manifests/stages.pp b/3rdparty/modules/stdlib/manifests/stages.pp index 7de254c71..63297fb53 100644 --- a/3rdparty/modules/stdlib/manifests/stages.pp +++ b/3rdparty/modules/stdlib/manifests/stages.pp @@ -1,10 +1,11 @@ -# Class: stdlib::stages -# -# This class manages a standard set of run stages for Puppet. It is managed by -# the stdlib class, and should not be declared independently. +# @summary +# This class manages a standard set of run stages for Puppet. It is managed by +# the stdlib class, and should not be declared independently. # +# Declares various run-stages for deploying infrastructure, +# language runtimes, and application layers. +# # The high level stages are (in order): -# # * setup # * main # * runtime @@ -14,21 +15,11 @@ # * deploy_app # * deploy # -# Parameters: none -# -# Actions: -# -# Declares various run-stages for deploying infrastructure, -# language runtimes, and application layers. -# -# Requires: nothing -# -# Sample Usage: -# -# node default { -# include ::stdlib -# class { java: stage => 'runtime' } -# } +# @example +# node default { +# include ::stdlib +# class { java: stage => 'runtime' } +# } # class stdlib::stages { diff --git a/3rdparty/modules/stdlib/metadata.json b/3rdparty/modules/stdlib/metadata.json index 48a794bb9..cd4b4c08c 100644 --- a/3rdparty/modules/stdlib/metadata.json +++ b/3rdparty/modules/stdlib/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "5.2.0", + "version": "6.1.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", @@ -17,7 +17,8 @@ "operatingsystemrelease": [ "5", "6", - "7" + "7", + "8" ] }, { @@ -55,7 +56,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "8", - "9" + "9", + "10" ] }, { @@ -81,6 +83,7 @@ "2012", "2012 R2", "2016", + "2019", "7", "8.1", "10" @@ -98,11 +101,11 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 2.7.20 < 7.0.0" + "version_requirement": ">= 5.5.10 < 7.0.0" } ], "description": "Standard Library for Puppet Modules", - "pdk-version": "1.7.1", - "template-url": "https://github.com/puppetlabs/pdk-templates/", - "template-ref": "heads/master-0-g6814a87" + "pdk-version": "1.12.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#master", + "template-ref": "1.12.0-0-g55d9ae2" } diff --git a/3rdparty/modules/stdlib/provision.yaml b/3rdparty/modules/stdlib/provision.yaml new file mode 100644 index 000000000..75fd0d076 --- /dev/null +++ b/3rdparty/modules/stdlib/provision.yaml @@ -0,0 +1,16 @@ +--- +default: + provisioner: docker + images: ['waffleimage/centos7'] +waffle_debian: + provisioner: docker + images: ['waffleimage/debian8', 'waffleimage/debian9', 'waffleimage/ubuntu14.04', 'waffleimage/ubuntu16.04', 'waffleimage/ubuntu18.04'] +waffle_el6: + provisioner: docker + images: ['waffleimage/centos6', 'waffleimage/scientificlinux6'] +waffle_el7: + provisioner: docker + images: ['waffleimage/centos7', 'waffleimage/oraclelinux7', 'waffleimage/scientificlinux7'] +release_checks: + provisioner: vmpooler + images: ['redhat-5-x86_64', 'redhat-6-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'centos-5-x86_64', 'centos-6-x86_64', 'centos-7-x86_64', 'oracle-5-x86_64', 'oracle-6-x86_64', 'oracle-7-x86_64', 'scientific-6-x86_64', 'scientific-7-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'sles-11-x86_64', 'sles-12-x86_64', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'win-2008-x86_64', 'win-2008r2-x86_64', 'win-2012-x86_64', 'win-2012r2-x86_64', 'win-2016-x86_64', 'win-2019-x86_64', 'win-7-x86_64', 'win-81-x86_64', 'win-10-pro-x86_64'] diff --git a/3rdparty/modules/stdlib/readmes/README_ja_JP.md b/3rdparty/modules/stdlib/readmes/README_ja_JP.md index 21aee1221..0e5c71fb8 100644 --- a/3rdparty/modules/stdlib/readmes/README_ja_JP.md +++ b/3rdparty/modules/stdlib/readmes/README_ja_JP.md @@ -887,7 +887,7 @@ bool2str(false, 't', 'f') => 'f' 引数: ブーリアン。 Since Puppet 5.0.0, you can create new values for almost any -data type using the type system — you can use the built-in +data type using the type system - you can use the built-in [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string) function to convert to String, with many different format options: diff --git a/3rdparty/modules/stdlib/spec/acceptance/abs_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/abs_spec.rb deleted file mode 100644 index e3d904a07..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/abs_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'abs function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $input = '-34.56' - $output = abs($input) - notify { "$output": } - DOC - it 'accepts a string' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: 34.56}) - end - end - - pp2 = <<-DOC - $input = -35.46 - $output = abs($input) - notify { "$output": } - DOC - it 'accepts a float' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: 35.46}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb index 3cf0c929e..fda167425 100644 --- a/3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb +++ b/3rdparty/modules/stdlib/spec/acceptance/anchor_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper_acceptance' describe 'anchor type' do - describe 'success' do - pp = <<-DOC + let(:pp) do + <<-MANIFEST class anchored { anchor { 'anchored::begin': } ~> anchor { 'anchored::end': } @@ -15,11 +15,12 @@ describe 'anchor type' do } include anchorrefresh - DOC - it 'effects proper chaining of resources' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Anchor\[final\]: Triggered 'refresh'}) - end + MANIFEST + end + + it 'applies manifest, anchors resources in correct order' do + apply_manifest(pp) do |r| + expect(r.stdout).to match(%r{Anchor\[final\]: Triggered 'refresh'}) end end end diff --git a/3rdparty/modules/stdlib/spec/acceptance/any2array_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/any2array_spec.rb deleted file mode 100644 index 2f1ae4e09..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/any2array_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'any2array function' do - describe 'success' do - pp1 = <<-DOC - $input = '' - $output = any2array($input) - validate_array($output) - notify { "Output: ${output}": } - DOC - it 'creates an empty array' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: Output: }) - end - end - - pp2 = <<-DOC - $input = ['array', 'test'] - $output = any2array($input) - validate_array($output) - notify { "Output: ${output}": } - DOC - it 'leaves arrays modified' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: Output: (\[|)array(,\s|)test(\]|)}) - end - end - - pp3 = <<-DOC - $input = {'test' => 'array'} - $output = any2array($input) - - validate_array($output) - # Check each element of the array is a plain string. - validate_string($output[0]) - validate_string($output[1]) - notify { "Output: ${output}": } - DOC - it 'turns a hash into an array' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: Output: (\[|)test(,\s|)array(\]|)}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/base64_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/base64_spec.rb deleted file mode 100644 index 5cc4d62c6..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/base64_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'base64 function' do - describe 'success' do - pp = <<-DOC - $encodestring = base64('encode', 'thestring') - $decodestring = base64('decode', $encodestring) - notify { $decodestring: } - DOC - it 'encodes then decode a string' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{thestring}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb deleted file mode 100644 index bf6611e2b..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'bool2num function' do - describe 'success' do - ['false', 'f', '0', 'n', 'no'].each do |bool| - pp1 = <<-DOC - $input = "#{bool}" - $output = bool2num($input) - notify { "$output": } - DOC - it "should convert a given boolean, #{bool}, to 0" do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: 0}) - end - end - end - - ['true', 't', '1', 'y', 'yes'].each do |bool| - pp2 = <<-DOC - $input = "#{bool}" - $output = bool2num($input) - notify { "$output": } - DOC - it "should convert a given boolean, #{bool}, to 1" do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: 1}) - end - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/build_csv.rb b/3rdparty/modules/stdlib/spec/acceptance/build_csv.rb deleted file mode 100644 index 9059858d8..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/build_csv.rb +++ /dev/null @@ -1,89 +0,0 @@ -# vim: set sw=2 sts=2 et tw=80 : -require 'rspec' - -# XXX Super ugly hack to keep from starting beaker nodes -module Kernel - # make an alias of the original require - alias original_require require - # rewrite require - def require(name) - original_require name if name != 'spec_helper_acceptance' - end -end -UNSUPPORTED_PLATFORMS = [].freeze -def fact(*_args) - [] -end -# XXX End hax - -# Get a list of functions for test coverage -function_list = Dir[File.join(File.dirname(__FILE__), '..', '..', 'lib', 'puppet', 'parser', 'functions', '*.rb')].map do |function_rb| - File.basename(function_rb, '.rb') -end - -## Configure rspec to parse tests -options = RSpec::Core::ConfigurationOptions.new(['spec/acceptance']) -configuration = RSpec.configuration -world = RSpec.world -options.parse_options -options.configure(configuration) -configuration.load_spec_files - -## Collect up tests and example groups into a hash -def get_tests(children) - children.each_with_object({}) do |c, memo| - memo[c.description] = {} - memo[c.description]['groups'] = get_tests(c.children) unless c.children.empty? - unless c.examples.empty? - memo[c.description]['tests'] = c.examples.map { |e| - e.description unless e.pending? - }.compact - end - next if c.examples.empty? - memo[c.description]['pending_tests'] = c.examples.map { |e| - e.description if e.pending? - }.compact - end -end - -def count_test_types_in(type, group) - return 0 if group.nil? - group.reduce(0) do |m, (k, v)| - m += v.length if k == type - m += count_tests_in(v) if v.is_a?(Hash) - m - end -end - -def count_tests_in(group) - count_test_types_in('tests', group) -end - -def count_pending_tests_in(group) - count_test_types_in('pending_tests', group) -end - -# Convert tests hash to csv format -def to_csv(function_list, tests) - function_list.map { |function_name| - v = tests["#{function_name} function"] - if v - positive_tests = count_tests_in(v['groups']['success']) - negative_tests = count_tests_in(v['groups']['failure']) - pending_tests = - count_pending_tests_in(v['groups']['failure']) + - count_pending_tests_in(v['groups']['failure']) - else - positive_tests = 0 - negative_tests = 0 - pending_tests = 0 - end - '%-25s, %-9d, %-9d, %-9d' % [function_name, positive_tests, negative_tests, pending_tests] - }.compact -end - -tests = get_tests(world.example_groups) -csv = to_csv(function_list, tests) -percentage_tested = "#{tests.count * 100 / function_list.count}%" -printf("%-25s, %-9s, %-9s, %-9s\n", "#{percentage_tested} have tests.", 'Positive', 'Negative', 'Pending') -puts csv diff --git a/3rdparty/modules/stdlib/spec/acceptance/capitalize_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/capitalize_spec.rb deleted file mode 100644 index e3081e34c..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/capitalize_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'capitalize function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $input = 'this is a string' - $output = capitalize($input) - notify { $output: } - DOC - it 'capitalizes the first letter of a string' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: This is a string}) - end - end - - pp2 = <<-DOC - $input = ['this', 'is', 'a', 'string'] - $output = capitalize($input) - notify { $output: } - DOC - regex_array = [%r{Notice: This}, %r{Notice: Is}, %r{Notice: A}, %r{Notice: String}] - it 'capitalizes the first letter of an array of strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - regex_array.each do |i| - expect(r.stdout).to match(i) - end - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/ceiling_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/ceiling_spec.rb deleted file mode 100644 index 782096a5f..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/ceiling_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'ceiling function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = 12.8 - $b = 13 - $o = ceiling($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'ceilings floats' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = 7 - $b = 7 - $o = ceiling($a) - if $o == $b { - notify { 'output is correct': } - } - DOC - it 'ceilings integers' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output is correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/chomp_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/chomp_spec.rb deleted file mode 100644 index 7fe9b1bb5..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/chomp_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'chomp function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp = <<-DOC - $input = "test\n" - if size($input) != 5 { - fail("Size of ${input} is not 5.") - } - $output = chomp($input) - if size($output) != 4 { - fail("Size of ${input} is not 4.") - } - DOC - it 'eats the newline' do - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/chop_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/chop_spec.rb deleted file mode 100644 index 4def10bae..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/chop_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'chop function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $input = "test" - if size($input) != 4 { - fail("Size of ${input} is not 4.") - } - $output = chop($input) - if size($output) != 3 { - fail("Size of ${input} is not 3.") - } - DOC - it 'eats the last character' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-'DOC' - $input = "test\r\n" - if size($input) != 6 { - fail("Size of ${input} is not 6.") - } - $output = chop($input) - if size($output) != 4 { - fail("Size of ${input} is not 4.") - } - DOC - it 'eats the last two characters of \r\n' do - apply_manifest(pp2, :catch_failures => true) - end - - pp3 = <<-DOC - $input = "" - $output = chop($input) - DOC - it 'does not fail on empty strings' do - apply_manifest(pp3, :catch_failures => true) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb deleted file mode 100644 index 9885f563d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/clamp_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'clamp function' do - describe 'success' do - pp1 = <<-DOC - $x = 17 - $y = 225 - $z = 155 - $o = clamp($x, $y, $z) - if $o == $z { - notify { 'output correct': } - } - DOC - it 'clamps list of values' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = [7, 19, 66] - $b = 19 - $o = clamp($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'clamps array of values' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/concat_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/concat_spec.rb deleted file mode 100644 index 391b84898..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/concat_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'concat function' do - describe 'success' do - pp1 = <<-DOC - $output = concat(['1','2','3'],['4','5','6']) - validate_array($output) - if size($output) != 6 { - fail("${output} should have 6 elements.") - } - DOC - it 'concats one array to another' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $output = concat(['1','2','3'],'4','5','6',['7','8','9']) - validate_array($output) - if size($output) != 9 { - fail("${output} should have 9 elements.") - } - DOC - it 'concats arrays and primitives to array' do - apply_manifest(pp2, :catch_failures => true) - end - - pp3 = <<-DOC - $output = concat(['1','2','3'],['4','5','6'],['7','8','9']) - validate_array($output) - if size($output) != 9 { - fail("${output} should have 9 elements.") - } - DOC - it 'concats multiple arrays to one' do - apply_manifest(pp3, :catch_failures => true) - end - - pp4 = <<-DOC - $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"}) - validate_array($output) - if size($output) != 2 { - fail("${output} should have 2 elements.") - } - if $output[1] != {"c" => "d", "e" => "f"} { - fail("${output} does not have the expected hash for the second element.") - } - DOC - it 'concats hash arguments' do - apply_manifest(pp4, :catch_failures => true) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/count_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/count_spec.rb deleted file mode 100644 index c134836e3..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/count_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'count function' do - describe 'success' do - pp1 = <<-DOC - $input = [1,2,3,4] - $output = count($input) - notify { "$output": } - DOC - it 'counts elements in an array' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: 4}) - end - end - - pp2 = <<-DOC - $input = [1,1,1,2] - $output = count($input, 1) - notify { "$output": } - DOC - it 'counts elements in an array that match a second argument' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: 3}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/deep_merge_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/deep_merge_spec.rb deleted file mode 100644 index 29a2c7960..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/deep_merge_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'deep_merge function' do - describe 'success' do - pp = <<-DOC - $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } - $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } - $merged_hash = deep_merge($hash1, $hash2) - - if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } { - fail("Hash was incorrectly merged.") - } - DOC - it 'deeps merge two hashes' do - apply_manifest(pp, :catch_failures => true) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/defined_with_params_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/defined_with_params_spec.rb deleted file mode 100644 index d8e5c8c7f..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/defined_with_params_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'defined_with_params function' do - describe 'success' do - pp1 = <<-DOC - user { 'dan': - ensure => present, - } - - if defined_with_params(User[dan], {'ensure' => 'present' }) { - notify { 'User defined with ensure=>present': } - } - DOC - it 'successfullies checks a type' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: User defined with ensure=>present}) - end - end - - pp2 = <<-DOC - class foo ( - $bar, - ) {} - - class { 'foo': - bar => 'baz', - } - - if defined_with_params(Class[foo], { 'bar' => 'baz' }) { - notify { 'Class foo defined with bar=>baz': } - } - DOC - it 'successfullies checks a class' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: Class foo defined with bar=>baz}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/delete_at_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/delete_at_spec.rb deleted file mode 100644 index 6a34e2185..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/delete_at_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'delete_at function' do - describe 'success' do - pp = <<-DOC - $output = delete_at(['a','b','c','b'], 1) - if $output == ['a','c','b'] { - notify { 'output correct': } - } - DOC - it 'deletes elements of the array' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/delete_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/delete_spec.rb deleted file mode 100644 index 70877cb84..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/delete_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'delete function' do - pp = <<-DOC - $output = delete(['a','b','c','b'], 'b') - if $output == ['a','c'] { - notify { 'output correct': } - } - DOC - describe 'success' do - it 'deletes elements of the array' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb deleted file mode 100644 index 418c959a8..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'delete_undef_values function' do - describe 'success' do - pp = <<-DOC - $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) - if $output == { a => 'A', b => '', d => false } { - notify { 'output correct': } - } - DOC - it 'deletes elements of the array' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/delete_values_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/delete_values_spec.rb deleted file mode 100644 index 634d31958..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/delete_values_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'delete_values function' do - describe 'success' do - pp = <<-DOC - $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' } - $b = { 'a' => 'A', 'B' => 'C' } - $o = delete_values($a, 'B') - if $o == $b { - notify { 'output correct': } - } - DOC - it 'deletes elements of the hash' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles non-hash arguments' - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb deleted file mode 100644 index 9f2544940..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/deprecation_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'deprecation function' do - test_file = if fact('operatingsystem') == 'windows' - 'C:/deprecation' - else - '/tmp/deprecation' - end - - # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format - add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\"" - remove_file_manifest = "file { '#{test_file}': ensure => absent }" - - before :all do - apply_manifest(remove_file_manifest) - end - - context 'with --strict=error', :if => return_puppet_version =~ %r{^4} do - let(:result) { on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) } - - after :all do - apply_manifest(remove_file_manifest) - end - - it 'returns an error' do - expect(result.exit_code).to eq(1) - end - - it 'shows the error message' do - expect(result.stderr).to match(%r{deprecation. key. message}) - end - - describe file(test_file.to_s) do - it { is_expected.not_to be_file } - end - end - - context 'with --strict=warning', :if => return_puppet_version =~ %r{^4} do - let(:result) { on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) } - - after :all do - apply_manifest(remove_file_manifest) - end - - it 'does not return an error' do - expect(result.exit_code).to eq(0) - end - - it 'shows the error message' do - expect(result.stderr).to match(%r{Warning: message}) - end - - describe file(test_file.to_s) do - it { is_expected.to be_file } - end - end - - context 'with --strict=off', :if => return_puppet_version =~ %r{^4} do - let(:result) { on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) } - - after :all do - apply_manifest(remove_file_manifest) - end - - it 'does not return an error' do - expect(result.exit_code).to eq(0) - end - - it 'does not show the error message' do - expect(result.stderr).not_to match(%r{Warning: message}) - end - - describe file(test_file.to_s) do - it { is_expected.to be_file } - end - end - - context 'puppet 3 test', :if => return_puppet_version =~ %r{^3} do - let(:result) { on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) } - - after :all do - apply_manifest(remove_file_manifest) - end - - it 'returns a deprecation error' do - expect(result.stderr).to match(%r{Warning: message}) - end - it 'passes without error' do - expect(result.exit_code).to eq(0) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/difference_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/difference_spec.rb deleted file mode 100644 index 7988f69f1..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/difference_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'difference function' do - describe 'success' do - pp = <<-DOC - $a = ['a','b','c'] - $b = ['b','c','d'] - $c = ['a'] - $o = difference($a, $b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'returns non-duplicates in the first array' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles non-array arguments' - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/dirname_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/dirname_spec.rb deleted file mode 100644 index a532e11ce..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/dirname_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'dirname function' do - describe 'success' do - context 'with absolute path' do - pp1 = <<-DOC - $a = '/path/to/a/file.txt' - $b = '/path/to/a' - $o = dirname($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'returns the dirname' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - context 'with relative path' do - pp2 = <<-DOC - $a = 'path/to/a/file.txt' - $b = 'path/to/a' - $o = dirname($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'returns the dirname' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/downcase_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/downcase_spec.rb deleted file mode 100644 index 053a16fed..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/downcase_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'downcase function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = 'AOEU' - $b = 'aoeu' - $o = downcase($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'returns the downcase' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = 'aoeu aoeu' - $b = 'aoeu aoeu' - $o = downcase($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'doesn\'t affect lowercase words' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/empty_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/empty_spec.rb deleted file mode 100644 index c5c63c043..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/empty_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'empty function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = '' - $b = true - $o = empty($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'recognizes empty strings' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = 'aoeu' - $b = false - $o = empty($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'recognizes non-empty strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = 7 - $b = false - $o = empty($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'handles numerical values' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/ensure_resource_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/ensure_resource_spec.rb deleted file mode 100644 index 21e73d3d8..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/ensure_resource_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'ensure_resource function' do - describe 'success' do - pp1 = <<-DOC - notify { "test": loglevel => 'err' } - ensure_resource('notify', 'test', { 'loglevel' => 'err' }) - DOC - it 'ensures a resource already declared' do - apply_manifest('') - - apply_manifest(pp1, :expect_changes => true) - end - - pp2 = <<-DOC - ensure_resource('notify', 'test', { 'loglevel' => 'err' }) - DOC - it 'ensures a undeclared resource' do - apply_manifest('') - - apply_manifest(pp2, :expect_changes => true) - end - it 'takes defaults arguments' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/file_line_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/file_line_spec.rb new file mode 100644 index 000000000..009889dfb --- /dev/null +++ b/3rdparty/modules/stdlib/spec/acceptance/file_line_spec.rb @@ -0,0 +1,89 @@ +require 'spec_helper_acceptance' + +test_file = (os[:family] == 'windows') ? 'C:\Users\Administrator\file_line_test.txt' : '/tmp/file_line_test.txt' + +describe 'file_line type' do + before(:each) do + pp_test_file = <<-MANIFEST + file { '#{test_file}': + ensure => present, + content => 'a wild test file has appeared!', + } + MANIFEST + apply_manifest(pp_test_file) + end + + context 'ensure line' do + let(:pp) do + <<-MANIFEST + file_line { 'test_ensure': + path => '#{test_file}', + line => 'test file uses attack!', + } + MANIFEST + end + + it 'applies manifest, adds line' do + idempotent_apply(pp) + expect(file(test_file)).to be_file + expect(file(test_file).content).to match(%r{test file uses attack!}) + end + end + + context 'matches and replaces line' do + let(:pp) do + <<-MANIFEST + file_line { 'test_match': + path => '#{test_file}', + line => 'a tame test file has appeared!', + match => '^a wild', + } + MANIFEST + end + + it 'applies manifest, replaces line' do + idempotent_apply(pp) + expect(file(test_file)).to be_file + expect(file(test_file).content).to match(%r{a tame test file has appeared!}) + end + end + + context 'remove line' do + context 'using match' do + let(:pp) do + <<-MANIFEST + file_line { 'test_absent_match': + ensure => absent, + path => '#{test_file}', + match => '^a wild', + match_for_absence => true, + } + MANIFEST + end + + it 'applies manifest, removes line' do + idempotent_apply(pp) + expect(file(test_file)).to be_file + expect(file(test_file).content).to be_empty + end + end + + context 'using line' do + let(:pp) do + <<-MANIFEST + file_line { 'test_absent_line': + ensure => absent, + path => '#{test_file}', + line => 'a wild test file has appeared!', + } + MANIFEST + end + + it 'applies manifest, removes line' do + idempotent_apply(pp) + expect(file(test_file)).to be_file + expect(file(test_file).content).to be_empty + end + end + end +end diff --git a/3rdparty/modules/stdlib/spec/acceptance/flatten_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/flatten_spec.rb deleted file mode 100644 index 79d4854d8..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/flatten_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'flatten function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = ["a","b",["c",["d","e"],"f","g"]] - $b = ["a","b","c","d","e","f","g"] - $o = flatten($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'flattens arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = ["a","b","c","d","e","f","g"] - $b = ["a","b","c","d","e","f","g"] - $o = flatten($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'does not affect flat arrays' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/floor_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/floor_spec.rb deleted file mode 100644 index fde6d8eb9..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/floor_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'floor function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = 12.8 - $b = 12 - $o = floor($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'floors floats' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = 7 - $b = 7 - $o = floor($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'floors integers' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb deleted file mode 100644 index 591655337..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'fqdn_rand_string function' do - describe 'success' do - include_context 'with faked facts' - context "when the FQDN is 'fakehost.localdomain'" do - before :each do - fake_fact('fqdn', 'fakehost.localdomain') - end - - pp1 = <<-PUPPETCODE - $l = 10 - $o = fqdn_rand_string($l) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - PUPPETCODE - it 'generates random alphanumeric strings' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"}) - end - end - - pp2 = <<-PUPPETCODE - $l = 10 - $c = '0123456789' - $o = fqdn_rand_string($l, $c) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - PUPPETCODE - it 'generates random alphanumeric strings with custom charsets' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rand_string is "(7203048515|2383756694)"}) - end - end - - pp3 = <<-PUPPETCODE - $l = 10 - $s = 'seed' - $o = fqdn_rand_string($l, undef, $s) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - PUPPETCODE - it 'generates random alphanumeric strings with custom seeds' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"}) - end - end - - pp4 = <<-PUPPETCODE - $l = 10 - $c = '0123456789' - $s = 'seed' - $o = fqdn_rand_string($l, $c, $s) - notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - PUPPETCODE - it 'generates random alphanumeric strings with custom charsets and seeds' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rand_string is "(3104058232|7100592312)"}) - end - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers for length argument' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb deleted file mode 100644 index 99f315e8d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'fqdn_rotate function' do - describe 'success' do - include_context 'with faked facts' - context "when the FQDN is 'fakehost.localdomain'" do - before :each do - fake_fact('fqdn', 'fakehost.localdomain') - end - - pp1 = <<-DOC - $a = ['a','b','c','d'] - $o = fqdn_rotate($a) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - DOC - it 'rotates arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rotate is \["d", "a", "b", "c"\]}) - end - end - - pp2 = <<-DOC - $a = ['a','b','c','d'] - $s = 'seed' - $o = fqdn_rotate($a, $s) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - DOC - it 'rotates arrays with custom seeds' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rotate is \["c", "d", "a", "b"\]}) - end - end - - pp3 = <<-DOC - $a = 'abcd' - $o = fqdn_rotate($a) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - DOC - it 'rotates strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rotate is "dabc"}) - end - end - - pp4 = <<-DOC - $a = 'abcd' - $s = 'seed' - $o = fqdn_rotate($a, $s) - notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - DOC - it 'rotates strings with custom seeds' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{fqdn_rotate is "cdab"}) - end - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles invalid arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/get_module_path_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/get_module_path_spec.rb deleted file mode 100644 index f9b169c40..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/get_module_path_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'get_module_path function' do - describe 'success' do - pp = <<-DOC - $a = $::is_pe ? { - 'true' => '/etc/puppetlabs/puppet/modules/dne', - 'false' => '/etc/puppet/modules/dne', - } - $o = get_module_path('dne') - if $o == $a { - notify { 'output correct': } - } else { - notify { "failed; module path is '$o'": } - } - DOC - it 'get_module_paths dne' do - apply_manifest(pp, :expect_failures => true) - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/getparam_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/getparam_spec.rb deleted file mode 100644 index 6ed225741..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/getparam_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'getparam function' do - describe 'success' do - pp = <<-DOC - notify { 'rspec': - message => 'custom rspec message', - } - $o = getparam(Notify['rspec'], 'message') - notice(inline_template('getparam is <%= @o.inspect %>')) - DOC - it 'getparam a notify' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{getparam is "custom rspec message"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/getvar_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/getvar_spec.rb deleted file mode 100644 index 0b14afb0b..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/getvar_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'getvar function' do - describe 'success' do - pp = <<-DOC - class a::data { $foo = 'aoeu' } - include a::data - $b = 'aoeu' - $o = getvar("a::data::foo") - if $o == $b { - notify { 'output correct': } - } - DOC - it 'getvars from classes' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-numbers' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/grep_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/grep_spec.rb deleted file mode 100644 index 1fe20277a..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/grep_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'grep function' do - describe 'success' do - pp = <<-DOC - $a = ['aaabbb','bbbccc','dddeee'] - $b = 'bbb' - $c = ['aaabbb','bbbccc'] - $o = grep($a,$b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'greps arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/has_interface_with_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/has_interface_with_spec.rb deleted file mode 100644 index d16dc1ddd..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/has_interface_with_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do - describe 'success' do - pp1 = <<-DOC - $a = $::ipaddress - $o = has_interface_with('ipaddress', $a) - notice(inline_template('has_interface_with is <%= @o.inspect %>')) - DOC - it 'has_interface_with existing ipaddress' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_interface_with is true}) - end - end - - pp2 = <<-DOC - $a = '128.0.0.1' - $o = has_interface_with('ipaddress', $a) - notice(inline_template('has_interface_with is <%= @o.inspect %>')) - DOC - it 'has_interface_with absent ipaddress' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_interface_with is false}) - end - end - - pp3 = <<-DOC - if $osfamily == 'Solaris' or $osfamily == 'Darwin' { - $a = 'lo0' - }elsif $osfamily == 'windows' { - $a = $::kernelmajversion ? { - /6\.(2|3|4)/ => 'Ethernet0', - /6\.(0|1)/ => 'Local_Area_Connection', - /5\.(1|2)/ => undef, #Broken current in facter - } - }else { - $a = 'lo' - } - $o = has_interface_with($a) - notice(inline_template('has_interface_with is <%= @o.inspect %>')) - DOC - it 'has_interface_with existing interface' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_interface_with is true}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/has_ip_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/has_ip_address_spec.rb deleted file mode 100644 index 13cdd77c0..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/has_ip_address_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do - describe 'success' do - pp1 = <<-DOC - $a = '127.0.0.1' - $o = has_ip_address($a) - notice(inline_template('has_ip_address is <%= @o.inspect %>')) - DOC - it 'has_ip_address existing ipaddress' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_ip_address is true}) - end - end - - pp2 = <<-DOC - $a = '128.0.0.1' - $o = has_ip_address($a) - notice(inline_template('has_ip_address is <%= @o.inspect %>')) - DOC - it 'has_ip_address absent ipaddress' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_ip_address is false}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/has_ip_network_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/has_ip_network_spec.rb deleted file mode 100644 index e18f0506d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/has_ip_network_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do - describe 'success' do - pp1 = <<-DOC - $a = '127.0.0.0' - $o = has_ip_network($a) - notice(inline_template('has_ip_network is <%= @o.inspect %>')) - DOC - it 'has_ip_network existing ipaddress' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_ip_network is true}) - end - end - - pp2 = <<-DOC - $a = '128.0.0.0' - $o = has_ip_network($a) - notice(inline_template('has_ip_network is <%= @o.inspect %>')) - DOC - it 'has_ip_network absent ipaddress' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{has_ip_network is false}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/has_key_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/has_key_spec.rb deleted file mode 100644 index 9da69c29d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/has_key_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'has_key function' do - describe 'success' do - pp1 = <<-DOC - $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' } - $b = 'bbb' - $c = true - $o = has_key($a,$b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'has_keys in hashes' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' } - $b = 'ccc' - $c = false - $o = has_key($a,$b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'has_keys not in hashes' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-hashes' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/hash_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/hash_spec.rb deleted file mode 100644 index 82e924589..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/hash_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'hash function' do - describe 'success' do - pp = <<-DOC - $a = ['aaa','bbb','bbb','ccc','ddd','eee'] - $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' } - $o = hash($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'hashs arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - it 'handles odd-length arrays' - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/intersection_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/intersection_spec.rb deleted file mode 100644 index 75dfe871c..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/intersection_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'intersection function' do - describe 'success' do - pp = <<-DOC - $a = ['aaa','bbb','ccc'] - $b = ['bbb','ccc','ddd','eee'] - $c = ['bbb','ccc'] - $o = intersection($a,$b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'intersections arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - it 'intersections empty arrays' - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb deleted file mode 100644 index 449e3e78c..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_a_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper_acceptance' - -if return_puppet_version =~ %r{^4} - describe 'is_a function' do - pp1 = <<-DOC - if 'hello world'.is_a(String) { - notify { 'output correct': } - } - DOC - it 'matches a string' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - if 5.is_a(String) { - notify { 'output wrong': } - } - DOC - it 'does not match a integer as string' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).not_to match(%r{Notice: output wrong}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_array_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_array_spec.rb deleted file mode 100644 index 408ff1ece..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_array_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_array function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa','bbb','ccc'] - $b = true - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_arrays arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = [] - $b = true - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_arrays empty arrays' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "aoeu" - $b = false - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_arrays strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = {'aaa'=>'bbb'} - $b = false - $o = is_array($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_arrays hashes' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_bool_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_bool_spec.rb deleted file mode 100644 index e9dab73c6..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_bool_spec.rb +++ /dev/null @@ -1,79 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_bool function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa','bbb','ccc'] - $b = false - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_bools arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = true - $b = true - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_bools true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = false - $b = true - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_bools false' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = "true" - $b = false - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_bools strings' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp5 = <<-DOC - $a = {'aaa'=>'bbb'} - $b = false - $o = is_bool($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_bools hashes' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_domain_name_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_domain_name_spec.rb deleted file mode 100644 index b33eb7a9b..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_domain_name_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_domain_name function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa.com','bbb','ccc'] - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - DOC - it 'is_domain_names arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_domain_name is false}) - end - end - - pp2 = <<-DOC - $a = true - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - DOC - it 'is_domain_names true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_domain_name is false}) - end - end - - pp3 = <<-DOC - $a = false - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - DOC - it 'is_domain_names false' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_domain_name is false}) - end - end - - pp4 = <<-DOC - $a = "3foo-bar.2bar-fuzz.com" - $b = true - $o = is_domain_name($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_domain_names strings with hyphens' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp5 = <<-DOC - $a = "-bar.2bar-fuzz.com" - $b = false - $o = is_domain_name($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_domain_names strings beginning with hyphens' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp6 = <<-DOC - $a = {'aaa'=>'www.com'} - $o = is_domain_name($a) - notice(inline_template('is_domain_name is <%= @o.inspect %>')) - DOC - it 'is_domain_names hashes' do - apply_manifest(pp6, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_domain_name is false}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_float_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_float_spec.rb deleted file mode 100644 index 524f338d0..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_float_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_float function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa.com','bbb','ccc'] - $o = is_float($a) - notice(inline_template('is_float is <%= @o.inspect %>')) - DOC - it 'is_floats arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_float is false}) - end - end - - pp2 = <<-DOC - $a = true - $o = is_float($a) - notice(inline_template('is_float is <%= @o.inspect %>')) - DOC - it 'is_floats true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_float is false}) - end - end - - pp3 = <<-DOC - $a = "3.5" - $b = true - $o = is_float($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_floats strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = 3.5 - $b = true - $o = is_float($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_floats floats' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp5 = <<-DOC - $a = 3 - $b = false - $o = is_float($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_floats integers' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp6 = <<-DOC - $a = {'aaa'=>'www.com'} - $o = is_float($a) - notice(inline_template('is_float is <%= @o.inspect %>')) - DOC - it 'is_floats hashes' do - apply_manifest(pp6, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_float is false}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_function_available_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_function_available_spec.rb deleted file mode 100644 index 8bb63f2dd..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_function_available_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_function_available function' do - describe 'success' do - pp1 = <<-DOC - $a = ['fail','include','require'] - $o = is_function_available($a) - notice(inline_template('is_function_available is <%= @o.inspect %>')) - DOC - it 'is_function_availables arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_function_available is false}) - end - end - - pp2 = <<-DOC - $a = true - $o = is_function_available($a) - notice(inline_template('is_function_available is <%= @o.inspect %>')) - DOC - it 'is_function_availables true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_function_available is false}) - end - end - - pp3 = <<-DOC - $a = "fail" - $b = true - $o = is_function_available($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_function_availables strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = "is_function_available" - $o = is_function_available($a) - notice(inline_template('is_function_available is <%= @o.inspect %>')) - DOC - it 'is_function_availables function_availables' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_function_available is true}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_hash_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_hash_spec.rb deleted file mode 100644 index c5f6b2ecf..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_hash_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_hash function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa','bbb','ccc'] - $o = is_hash($a) - notice(inline_template('is_hash is <%= @o.inspect %>')) - DOC - it 'is_hashs arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_hash is false}) - end - end - - pp2 = <<-DOC - $a = {} - $b = true - $o = is_hash($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_hashs empty hashs' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "aoeu" - $b = false - $o = is_hash($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_hashs strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = {'aaa'=>'bbb'} - $b = true - $o = is_hash($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_hashs hashes' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_integer_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_integer_spec.rb deleted file mode 100644 index 45a8c2b01..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_integer_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_integer function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa.com','bbb','ccc'] - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_integers arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = true - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_integers true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "3" - $b = true - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_integers strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = 3.5 - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_integers floats' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp5 = <<-DOC - $a = 3 - $b = true - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_integers integers' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp6 = <<-DOC - $a = {'aaa'=>'www.com'} - $b = false - $o = is_integer($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_integers hashes' do - apply_manifest(pp6, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_ip_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_ip_address_spec.rb deleted file mode 100644 index e528fe5c2..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_ip_address_spec.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_ip_address function' do - describe 'success' do - pp1 = <<-DOC - $a = '1.2.3.4' - $b = true - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ip_addresss ipv4' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74" - $b = true - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ip_addresss ipv6' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "fe00::1" - $b = true - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ip_addresss ipv6 compressed' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = "aoeu" - $b = false - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ip_addresss strings' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp5 = <<-DOC - $a = '1.2.3.400' - $b = false - $o = is_ip_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ip_addresss ipv4 out of range' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb deleted file mode 100644 index 04cb45f72..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_ipv4_address function' do - describe 'success' do - pp1 = <<-DOC - $a = '1.2.3.4' - $b = true - $o = is_ipv4_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv4_addresss' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = "aoeu" - $b = false - $o = is_ipv4_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv4_addresss strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = '1.2.3.400' - $b = false - $o = is_ipv4_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv4_addresss ipv4 out of range' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb deleted file mode 100644 index 03e5dd117..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_ipv6_address function' do - describe 'success' do - pp1 = <<-DOC - $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74" - $b = true - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv6_addresss' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = "fe00::1" - $b = true - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv6_addresss ipv6 compressed' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "aoeu" - $b = false - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv6_addresss strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg' - $b = false - $o = is_ipv6_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_ipv6_addresss ip out of range' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_mac_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_mac_address_spec.rb deleted file mode 100644 index 8e96abffd..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_mac_address_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_mac_address function' do - describe 'success' do - pp1 = <<-DOC - $a = '00:a0:1f:12:7f:a0' - $b = true - $o = is_mac_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_mac_addresss a mac' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = '00:a0:1f:12:7f:g0' - $b = false - $o = is_mac_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_mac_addresss a mac out of range' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = '80:00:02:09:fe:80:00:00:00:00:00:00:00:24:65:ff:ff:91:a3:12' - $b = true - $o = is_mac_address($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_mac_addresss a 20-octet mac' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_numeric_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_numeric_spec.rb deleted file mode 100644 index 4ec7f0c64..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_numeric_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_numeric function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa.com','bbb','ccc'] - $b = false - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_numerics arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = true - $b = false - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_numerics true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "3" - $b = true - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_numerics strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp4 = <<-DOC - $a = 3.5 - $b = true - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_numerics floats' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp5 = <<-DOC - $a = 3 - $b = true - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_numerics integers' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp6 = <<-DOC - $a = {'aaa'=>'www.com'} - $b = false - $o = is_numeric($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_numerics hashes' do - apply_manifest(pp6, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - it 'handles non-arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/is_string_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/is_string_spec.rb deleted file mode 100644 index e3ab31a44..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/is_string_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'is_string function' do - describe 'success' do - pp1 = <<-DOC - $a = ['aaa.com','bbb','ccc'] - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_strings arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp2 = <<-DOC - $a = true - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_strings true' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp3 = <<-DOC - $a = "aoeu" - $o = is_string($a) - notice(inline_template('is_string is <%= @o.inspect %>')) - DOC - it 'is_strings strings' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_string is true}) - end - end - - pp4 = <<-DOC - $a = "3" - $o = is_string($a) - notice(inline_template('is_string is <%= @o.inspect %>')) - DOC - it 'is_strings number strings' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_string is false}) - end - end - - pp5 = <<-DOC - $a = 3.5 - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_strings floats' do - apply_manifest(pp5, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp6 = <<-DOC - $a = 3 - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_strings integers' do - apply_manifest(pp6, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp7 = <<-DOC - $a = {'aaa'=>'www.com'} - $b = false - $o = is_string($a) - if $o == $b { - notify { 'output correct': } - } - DOC - it 'is_strings hashes' do - apply_manifest(pp7, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - pp8 = <<-DOC - $a = undef - $o = is_string($a) - notice(inline_template('is_string is <%= @o.inspect %>')) - DOC - it 'is_strings undef' do - apply_manifest(pp8, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{is_string is true}) - end - end - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb deleted file mode 100644 index a9f30e3a2..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'join_keys_to_values function' do - describe 'success' do - pp = <<-DOC - $a = {'aaa'=>'bbb','ccc'=>'ddd'} - $b = ':' - $o = join_keys_to_values($a,$b) - notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>')) - DOC - it 'join_keys_to_valuess hashes' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]}) - end - end - it 'handles non hashes' - it 'handles empty hashes' - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/join_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/join_spec.rb deleted file mode 100644 index 233b953a0..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/join_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'join function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - describe 'success' do - pp = <<-DOC - $a = ['aaa','bbb','ccc'] - $b = ':' - $c = 'aaa:bbb:ccc' - $o = join($a,$b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'joins arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - it 'handles non arrays' - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/keys_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/keys_spec.rb deleted file mode 100644 index 9c4122c64..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/keys_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'keys function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - describe 'success' do - pp = <<-DOC - $a = {'aaa'=>'bbb','ccc'=>'ddd'} - $o = keys($a) - notice(inline_template('keys is <%= @o.sort.inspect %>')) - DOC - it 'keyss hashes' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{keys is \["aaa", "ccc"\]}) - end - end - it 'handles non hashes' - it 'handles empty hashes' - end - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb deleted file mode 100644 index 31d015abe..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/loadjson_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper_acceptance' - -tmpdir = default.tmpdir('stdlib') - -describe 'loadjson function' do - describe 'success' do - shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/test1json.json") - pp1 = <<-DOC - $o = loadjson('#{tmpdir}/test1json.json') - notice(inline_template('loadjson[aaa] is <%= @o["aaa"].inspect %>')) - notice(inline_template('loadjson[bbb] is <%= @o["bbb"].inspect %>')) - notice(inline_template('loadjson[ccc] is <%= @o["ccc"].inspect %>')) - notice(inline_template('loadjson[ddd] is <%= @o["ddd"].inspect %>')) - DOC - regex_array = [%r{loadjson\[aaa\] is 1}, %r{loadjson\[bbb\] is 2}, %r{loadjson\[ccc\] is 3}, %r{loadjson\[ddd\] is 4}] - it 'loadjsons array of values' do - apply_manifest(pp1, :catch_failures => true) do |r| - regex_array.each do |i| - expect(r.stdout).to match(i) - end - end - end - - pp2 = <<-DOC - $o = loadjson('#{tmpdir}/no-file.json', {'default' => 'value'}) - notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>')) - DOC - it 'returns the default value if there is no file to load' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{loadjson\[default\] is "value"}) - end - end - - shell("echo '!' > #{tmpdir}/test2json.json") - pp3 = <<-DOC - $o = loadjson('#{tmpdir}/test2json.json', {'default' => 'value'}) - notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>')) - DOC - it 'returns the default value if the file was parsed with an error' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{loadjson\[default\] is "value"}) - end - end - end - describe 'failure' do - it 'fails with no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/loadyaml_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/loadyaml_spec.rb deleted file mode 100644 index f55274c58..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/loadyaml_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'spec_helper_acceptance' - -tmpdir = default.tmpdir('stdlib') - -describe 'loadyaml function' do - describe 'success' do - shell("echo '--- - aaa: 1 - bbb: 2 - ccc: 3 - ddd: 4' > #{tmpdir}/test1yaml.yaml") - pp1 = <<-DOC - $o = loadyaml('#{tmpdir}/test1yaml.yaml') - notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>')) - notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>')) - notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>')) - notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>')) - DOC - regex_array = [%r{loadyaml\[aaa\] is 1}, %r{loadyaml\[bbb\] is 2}, %r{loadyaml\[ccc\] is 3}, %r{loadyaml\[ddd\] is 4}] - it 'loadyamls array of values' do - apply_manifest(pp1, :catch_failures => true) do |r| - regex_array.each do |i| - expect(r.stdout).to match(i) - end - end - end - - pp2 = <<-DOC - $o = loadyaml('#{tmpdir}/no-file.yaml', {'default' => 'value'}) - notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>')) - DOC - it 'returns the default value if there is no file to load' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{loadyaml\[default\] is "value"}) - end - end - - shell("echo '!' > #{tmpdir}/test2yaml.yaml") - pp3 = <<-DOC - $o = loadyaml('#{tmpdir}/test2yaml.yaml', {'default' => 'value'}) - notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>')) - DOC - it 'returns the default value if the file was parsed with an error' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{loadyaml\[default\] is "value"}) - end - end - end - describe 'failure' do - it 'fails with no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/lstrip_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/lstrip_spec.rb deleted file mode 100644 index 1621c5733..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/lstrip_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'lstrip function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = [" the "," public "," art","galleries "] - # Anagram: Large picture halls, I bet - $o = lstrip($a) - notice(inline_template('lstrip is <%= @o.inspect %>')) - DOC - it 'lstrips arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{lstrip is \["the ", "public ", "art", "galleries "\]}) - end - end - - pp2 = <<-DOC - $a = " blowzy night-frumps vex'd jack q " - $o = lstrip($a) - notice(inline_template('lstrip is <%= @o.inspect %>')) - DOC - it 'lstrips strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{lstrip is "blowzy night-frumps vex'd jack q "}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/max_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/max_spec.rb deleted file mode 100644 index 3958a70b2..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/max_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'max function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp = <<-DOC - $o = max("the","public","art","galleries") - notice(inline_template('max is <%= @o.inspect %>')) - DOC - it 'maxs arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{max is "the"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/member_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/member_spec.rb deleted file mode 100644 index ebadeb454..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/member_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'member function' do - shared_examples 'item found' do - it 'outputs correctly' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - end - describe 'success' do - pp1 = <<-DOC - $a = ['aaa','bbb','ccc'] - $b = 'ccc' - $c = true - $o = member($a,$b) - if $o == $c { - notify { 'output correct': } - } - DOC - it 'members arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{Notice: output correct}) - end - end - - describe 'members array of integers' do - let(:pp) do - <<-DOC - if member( [1,2,3,4], 4 ){ - notify { 'output correct': } - } - DOC - end - - it_behaves_like 'item found' do - end - end - describe 'members of mixed array' do - let(:pp) do - <<-DOC - if member( ['a','4',3], 'a' ){ - notify { 'output correct': } - } - DOC - end - - it_behaves_like 'item found' do - end - end - it 'members arrays without members' - end - - describe 'failure' do - it 'handles improper argument counts' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/merge_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/merge_spec.rb deleted file mode 100644 index 17e2b9e01..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/merge_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'merge function' do - describe 'success' do - pp = <<-DOC - $a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } - $b = {'two' => 'dos', 'three' => { 'five' => 5 } } - $o = merge($a, $b) - notice(inline_template('merge[one] is <%= @o["one"].inspect %>')) - notice(inline_template('merge[two] is <%= @o["two"].inspect %>')) - notice(inline_template('merge[three] is <%= @o["three"].inspect %>')) - DOC - regex_array = [%r{merge\[one\] is ("1"|1)}, %r{merge\[two\] is "dos"}, %r{merge\[three\] is {"five"=>("5"|5)}}] - it 'merges two hashes' do - apply_manifest(pp, :catch_failures => true) do |r| - regex_array.each do |i| - expect(r.stdout).to match(i) - end - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/min_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/min_spec.rb deleted file mode 100644 index ea9606032..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/min_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'min function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp = <<-DOC - $o = min("the","public","art","galleries") - notice(inline_template('min is <%= @o.inspect %>')) - DOC - it 'mins arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{min is "art"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/num2bool_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/num2bool_spec.rb deleted file mode 100644 index d95cb934d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/num2bool_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'num2bool function' do - describe 'success' do - pp1 = <<-DOC - $a = 1 - $b = "1" - $c = "50" - $ao = num2bool($a) - $bo = num2bool($b) - $co = num2bool($c) - notice(inline_template('a is <%= @ao.inspect %>')) - notice(inline_template('b is <%= @bo.inspect %>')) - notice(inline_template('c is <%= @co.inspect %>')) - DOC - regex_array_true = [%r{a is true}, %r{b is true}, %r{c is true}] - it 'bools positive numbers and numeric strings as true' do - apply_manifest(pp1, :catch_failures => true) do |r| - regex_array_true.each do |i| - expect(r.stdout).to match(i) - end - end - end - - pp2 = <<-DOC - $a = 0 - $b = -0.1 - $c = ["-50","1"] - $ao = num2bool($a) - $bo = num2bool($b) - $co = num2bool($c) - notice(inline_template('a is <%= @ao.inspect %>')) - notice(inline_template('b is <%= @bo.inspect %>')) - notice(inline_template('c is <%= @co.inspect %>')) - DOC - regex_array_false = [%r{a is false}, %r{b is false}, %r{c is false}] - it 'bools negative numbers as false' do - apply_manifest(pp2, :catch_failures => true) do |r| - regex_array_false.each do |i| - expect(r.stdout).to match(i) - end - end - end - end - - describe 'failure' do - pp3 = <<-DOC - $a = "a" - $ao = num2bool($a) - notice(inline_template('a is <%= @ao.inspect %>')) - DOC - it 'fails on words' do - expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{not look like a number}) - end - - pp4 = <<-DOC - $b = "1b" - $bo = num2bool($b) - notice(inline_template('b is <%= @bo.inspect %>')) - DOC - it 'fails on numberwords' do - expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{not look like a number}) - end - - pp5 = <<-DOC # rubocop:disable Lint/UselessAssignment - $c = {"c" => "-50"} - $co = num2bool($c) - notice(inline_template('c is <%= @co.inspect %>')) - DOC - it 'fails on non-numeric/strings' do - pending "The function will call .to_s.to_i on anything not a Numeric or - String, and results in 0. Is this intended?" - expect(apply_manifest(pp5(:expect_failures => true)).stderr).to match(%r{Unable to parse}) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/parsejson_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/parsejson_spec.rb deleted file mode 100644 index 8a19907dc..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/parsejson_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'parsejson function' do - describe 'success' do - pp1 = <<-DOC - $a = '{"hunter": "washere", "tests": "passing"}' - $ao = parsejson($a) - $tests = $ao['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - DOC - it 'parses valid json' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{tests are "passing"}) - end - end - end - - describe 'failure' do - pp2 = <<-DOC - $a = '{"hunter": "washere", "tests": "passing",}' - $ao = parsejson($a, 'tests are using the default value') - notice(inline_template('a is <%= @ao.inspect %>')) - DOC - it 'raises error on incorrect json - default value is used' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{tests are using the default value}) - end - end - - pp3 = <<-DOC - $a = '{"hunter": "washere", "tests": "passing",}' - $ao = parsejson($a) - notice(inline_template('a is <%= @ao.inspect %>')) - DOC - it 'raises error on incorrect json' do - apply_manifest(pp3, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{expected next name}) - end - end - - pp4 = <<-DOC - $o = parsejson() - DOC - it 'raises error on incorrect number of arguments' do - apply_manifest(pp4, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{wrong number of arguments}i) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/parseyaml_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/parseyaml_spec.rb deleted file mode 100644 index 4cdf36dc5..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/parseyaml_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'parseyaml function' do - describe 'success' do - pp1 = <<-DOC - $a = "---\nhunter: washere\ntests: passing\n" - $o = parseyaml($a) - $tests = $o['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - DOC - it 'parses valid yaml' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{tests are "passing"}) - end - end - end - - describe 'failure' do - pp2 = <<-DOC - $a = "---\nhunter: washere\ntests: passing\n:" - $o = parseyaml($a, {'tests' => 'using the default value'}) - $tests = $o['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - DOC - it 'returns the default value on incorrect yaml' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{tests are "using the default value"}) - end - end - - pp3 = <<-DOC - $a = "---\nhunter: washere\ntests: passing\n:" - $o = parseyaml($a) - $tests = $o['tests'] - notice(inline_template('tests are <%= @tests.inspect %>')) - DOC - it 'raises error on incorrect yaml' do - apply_manifest(pp3, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{(syntax error|did not find expected key)}) - end - end - - pp4 = <<-DOC - $o = parseyaml() - DOC - it 'raises error on incorrect number of arguments' do - apply_manifest(pp4, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{wrong number of arguments}i) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/pick_default_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/pick_default_spec.rb deleted file mode 100644 index 82b7ea5d3..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/pick_default_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'pick_default function' do - describe 'success' do - pp1 = <<-DOC - $a = undef - $o = pick_default($a, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'pick_defaults a default value' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{picked is "default"}) - end - end - - pp2 = <<-DOC - $a = undef - $b = undef - $o = pick_default($a,$b) - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'pick_defaults with no value' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{picked is ""}) - end - end - - pp3 = <<-DOC - $a = "something" - $b = "long" - $o = pick_default($a, $b, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'pick_defaults the first set value' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{picked is "something"}) - end - end - end - describe 'failure' do - pp4 = <<-DOC - $o = pick_default() - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'raises error with no values' do - apply_manifest(pp4, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{Must receive at least one argument}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/pick_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/pick_spec.rb deleted file mode 100644 index 14834b426..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/pick_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'pick function' do - describe 'success' do - pp1 = <<-DOC - $a = undef - $o = pick($a, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'picks a default value' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{picked is "default"}) - end - end - - pp2 = <<-DOC - $a = "something" - $b = "long" - $o = pick($a, $b, 'default') - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'picks the first set value' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{picked is "something"}) - end - end - end - - describe 'failure' do - pp3 = <<-DOC - $a = undef - $b = undef - $o = pick($a, $b) - notice(inline_template('picked is <%= @o.inspect %>')) - DOC - it 'raises error with all undef values' do - apply_manifest(pp3, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{must receive at least one non empty value}) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/prefix_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/prefix_spec.rb deleted file mode 100644 index 9a37fb371..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/prefix_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'prefix function' do - describe 'success' do - pp1 = <<-DOC - $o = prefix(['a','b','c'],'p') - notice(inline_template('prefix is <%= @o.inspect %>')) - DOC - it 'prefixes array of values' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{prefix is \["pa", "pb", "pc"\]}) - end - end - - pp2 = <<-DOC - $o = prefix([],'p') - notice(inline_template('prefix is <%= @o.inspect %>')) - DOC - it 'prefixs with empty array' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{prefix is \[\]}) - end - end - - pp3 = <<-DOC - $o = prefix(['a','b','c'], undef) - notice(inline_template('prefix is <%= @o.inspect %>')) - DOC - it 'prefixs array of values with undef' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{prefix is \["a", "b", "c"\]}) - end - end - end - describe 'failure' do - it 'fails with no arguments' - it 'fails when first argument is not array' - it 'fails when second argument is not string' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb deleted file mode 100644 index 9c0d716c6..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/pw_hash_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper_acceptance' - -# Windows and OS X do not have useful implementations of crypt(3) -describe 'pw_hash function', :unless => ['windows', 'Darwin', 'SLES'].include?(fact('operatingsystem')) do - describe 'success' do - pp1 = <<-DOC - $o = pw_hash('password', 'sha-512', 'salt') - notice(inline_template('pw_hash is <%= @o.inspect %>')) - DOC - it 'hashes passwords' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."}) - end - end - - pp2 = <<-DOC - $o = pw_hash('', 'sha-512', 'salt') - notice(inline_template('pw_hash is <%= @o.inspect %>')) - DOC - it 'returns nil if no password is provided' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{pw_hash is nil}) - end - end - end - describe 'failure' do - it 'handles less than three arguments' - it 'handles more than three arguments' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/range_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/range_spec.rb deleted file mode 100644 index a5a7d2222..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/range_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'range function' do - describe 'success' do - pp1 = <<-DOC - $o = range('a','d') - notice(inline_template('range is <%= @o.inspect %>')) - DOC - it 'ranges letters' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{range is \["a", "b", "c", "d"\]}) - end - end - - pp2 = <<-DOC - $o = range('a','d', '2') - notice(inline_template('range is <%= @o.inspect %>')) - DOC - it 'ranges letters with a step' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{range is \["a", "c"\]}) - end - end - it 'ranges letters with a negative step' - it 'ranges numbers' - it 'ranges numbers with a step' - it 'ranges numbers with a negative step' - it 'ranges numeric strings' - it 'ranges zero padded numbers' - end - describe 'failure' do - it 'fails with no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/reject_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/reject_spec.rb deleted file mode 100644 index 753dd78a6..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/reject_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'reject function' do - describe 'success' do - pp1 = <<-DOC - $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa') - notice(inline_template('reject is <%= @o.inspect %>')) - DOC - it 'rejects array of values' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{reject is \["bbb", "ccc"\]}) - end - end - - pp2 = <<-DOC - $o = reject([],'aaa') - notice(inline_template('reject is <%= @o.inspect %>')) - DOC - it 'rejects with empty array' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{reject is \[\]}) - end - end - - pp3 = <<-DOC - $o = reject(['aaa','bbb','ccc','aaaddd'], undef) - notice(inline_template('reject is <%= @o.inspect %>')) - DOC - it 'rejects array of values with undef' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{reject is \[\]}) - end - end - end - describe 'failure' do - it 'fails with no arguments' - it 'fails when first argument is not array' - it 'fails when second argument is not string' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/reverse_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/reverse_spec.rb deleted file mode 100644 index 393fc30fd..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/reverse_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'reverse function' do - describe 'success' do - pp1 = <<-DOC - $a = "the public art galleries" - # Anagram: Large picture halls, I bet - $o = reverse($a) - notice(inline_template('reverse is <%= @o.inspect %>')) - DOC - it 'reverses strings' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{reverse is "seirellag tra cilbup eht"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/rstrip_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/rstrip_spec.rb deleted file mode 100644 index b7aebda48..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/rstrip_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'rstrip function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = [" the "," public "," art","galleries "] - # Anagram: Large picture halls, I bet - $o = rstrip($a) - notice(inline_template('rstrip is <%= @o.inspect %>')) - DOC - it 'rstrips arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{rstrip is \[" the", " public", " art", "galleries"\]}) - end - end - - pp2 = <<-DOC - $a = " blowzy night-frumps vex'd jack q " - $o = rstrip($a) - notice(inline_template('rstrip is <%= @o.inspect %>')) - DOC - it 'rstrips strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{rstrip is " blowzy night-frumps vex'd jack q"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/shuffle_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/shuffle_spec.rb deleted file mode 100644 index d8c03a298..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/shuffle_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'shuffle function' do - describe 'success' do - pp1 = <<-DOC - $a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"] - # Anagram: Large picture halls, I bet - $o = shuffle($a) - notice(inline_template('shuffle is <%= @o.inspect %>')) - DOC - it 'shuffles arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).not_to match(%r{shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]}) - end - end - - pp2 = <<-DOC - $a = "blowzy night-frumps vex'd jack q" - $o = shuffle($a) - notice(inline_template('shuffle is <%= @o.inspect %>')) - DOC - it 'shuffles strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).not_to match(%r{shuffle is "blowzy night-frumps vex'd jack q"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/size_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/size_spec.rb deleted file mode 100644 index e84e66523..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/size_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'size function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = 'discombobulate' - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - DOC - it 'single string size' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{size is 14}) - end - end - - pp2 = <<-DOC - $a = '' - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - DOC - it 'with empty string' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{size is 0}) - end - end - - pp3 = <<-DOC - $a = undef - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - DOC - it 'with undef' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{size is 0}) - end - end - - pp4 = <<-DOC - $a = ['discombobulate', 'moo'] - $o = size($a) - notice(inline_template('size is <%= @o.inspect %>')) - DOC - it 'strings in array' do - apply_manifest(pp4, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{size is 2}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/sort_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/sort_spec.rb deleted file mode 100644 index 8c4a3ab0d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/sort_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'sort function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = ["the","public","art","galleries"] - # Anagram: Large picture halls, I bet - $o = sort($a) - notice(inline_template('sort is <%= @o.inspect %>')) - DOC - it 'sorts arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{sort is \["art", "galleries", "public", "the"\]}) - end - end - - pp2 = <<-DOC - $a = "blowzy night-frumps vex'd jack q" - $o = sort($a) - notice(inline_template('sort is <%= @o.inspect %>')) - DOC - it 'sorts strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{sort is " '-abcdefghijklmnopqrstuvwxyz"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/squeeze_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/squeeze_spec.rb deleted file mode 100644 index c3be9db28..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/squeeze_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'squeeze function' do - describe 'success' do - pp1 = <<-DOC - # Real words! - $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"] - $o = squeeze($a) - notice(inline_template('squeeze is <%= @o.inspect %>')) - DOC - it 'squeezes arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]}) - end - end - - it 'squeezez arrays with an argument' - pp2 = <<-DOC - $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" - $o = squeeze($a) - notice(inline_template('squeeze is <%= @o.inspect %>')) - DOC - it 'squeezes strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{squeeze is "wales laparohysterosalpingophorectomy br godeship"}) - end - end - - pp3 = <<-DOC - $a = "countessship duchessship governessship hostessship" - $o = squeeze($a, 's') - notice(inline_template('squeeze is <%= @o.inspect %>')) - DOC - it 'squeezes strings with an argument' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{squeeze is "counteship ducheship governeship hosteship"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/str2bool_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/str2bool_spec.rb deleted file mode 100644 index 809456af0..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/str2bool_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'str2bool function' do - describe 'success' do - pp = <<-DOC - $o = str2bool('y') - notice(inline_template('str2bool is <%= @o.inspect %>')) - DOC - it 'works with "y"' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{str2bool is true}) - end - end - it 'works with "Y"' - it 'works with "yes"' - it 'works with "1"' - it 'works with "true"' - it 'works with "n"' - it 'works with "N"' - it 'works with "no"' - it 'works with "0"' - it 'works with "false"' - it 'works with undef' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non arrays or strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb deleted file mode 100644 index 4e38e07a7..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'str2saltedsha512 function' do - describe 'success' do - pp = <<-DOC - $o = str2saltedsha512('password') - notice(inline_template('str2saltedsha512 is <%= @o.inspect %>')) - DOC - it 'works with "y"' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{str2saltedsha512 is "[a-f0-9]{136}"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles more than one argument' - it 'handles non strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/strftime_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/strftime_spec.rb deleted file mode 100644 index 4ba2c6aa6..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/strftime_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'strftime function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '4.8.0') < 0 do - describe 'success' do - pp = <<-DOC - $o = strftime('%C') - notice(inline_template('strftime is <%= @o.inspect %>')) - DOC - it 'gives the Century' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{strftime is "20"}) - end - end - it 'takes a timezone argument' - end - describe 'failure' do - it 'handles no arguments' - it 'handles invalid format strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/strip_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/strip_spec.rb deleted file mode 100644 index 67a939a85..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/strip_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'strip function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = [" the "," public "," art","galleries "] - # Anagram: Large picture halls, I bet - $o = strip($a) - notice(inline_template('strip is <%= @o.inspect %>')) - DOC - it 'strips arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{strip is \["the", "public", "art", "galleries"\]}) - end - end - - pp2 = <<-DOC - $a = " blowzy night-frumps vex'd jack q " - $o = strip($a) - notice(inline_template('strip is <%= @o.inspect %>')) - DOC - it 'strips strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{strip is "blowzy night-frumps vex'd jack q"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/suffix_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/suffix_spec.rb deleted file mode 100644 index 6b0409543..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/suffix_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'suffix function' do - describe 'success' do - pp1 = <<-DOC - $o = suffix(['a','b','c'],'p') - notice(inline_template('suffix is <%= @o.inspect %>')) - DOC - it 'suffixes array of values' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{suffix is \["ap", "bp", "cp"\]}) - end - end - - pp2 = <<-DOC - $o = suffix([],'p') - notice(inline_template('suffix is <%= @o.inspect %>')) - DOC - it 'suffixs with empty array' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{suffix is \[\]}) - end - end - - pp3 = <<-DOC - $o = suffix(['a','b','c'], undef) - notice(inline_template('suffix is <%= @o.inspect %>')) - DOC - it 'suffixs array of values with undef' do - apply_manifest(pp3, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{suffix is \["a", "b", "c"\]}) - end - end - end - describe 'failure' do - it 'fails with no arguments' - it 'fails when first argument is not array' - it 'fails when second argument is not string' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/swapcase_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/swapcase_spec.rb deleted file mode 100644 index 1d606f0b1..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/swapcase_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'swapcase function' do - describe 'success' do - pp = <<-DOC - $o = swapcase('aBcD') - notice(inline_template('swapcase is <%= @o.inspect %>')) - DOC - it 'works with strings' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{swapcase is "AbCd"}) - end - end - it 'works with arrays' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non arrays or strings' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/time_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/time_spec.rb deleted file mode 100644 index b0a456462..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/time_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'time function' do - describe 'success' do - pp1 = <<-DOC - $o = time() - notice(inline_template('time is <%= @o.inspect %>')) - DOC - it 'gives the time' do - apply_manifest(pp1, :catch_failures => true) do |r| - m = r.stdout.match(%r{time is (\d+)\D}) - # When I wrote this test - expect(Integer(m[1])).to be > 1_398_894_170 - end - end - - pp2 = <<-DOC - $o = time('UTC') - notice(inline_template('time is <%= @o.inspect %>')) - DOC - it 'takes a timezone argument' do - apply_manifest(pp2, :catch_failures => true) do |r| - m = r.stdout.match(%r{time is (\d+)\D}) - expect(Integer(m[1])).to be > 1_398_894_170 - end - end - end - describe 'failure' do - it 'handles more arguments' - it 'handles invalid timezones' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/to_bytes_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/to_bytes_spec.rb deleted file mode 100644 index f042fe0e4..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/to_bytes_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'to_bytes function' do - describe 'success' do - pp = <<-DOC - $o = to_bytes('4 kB') - notice(inline_template('to_bytes is <%= @o.inspect %>')) - DOC - it 'converts kB to B' do - apply_manifest(pp, :catch_failures => true) do |r| - m = r.stdout.match(%r{to_bytes is (\d+)\D}) - expect(m[1]).to eq('4096') - end - end - it 'works without the B in unit' - it 'works without a space before unit' - it 'works without a unit' - it 'converts fractions' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non integer arguments' - it 'handles unknown units like uB' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb deleted file mode 100644 index 111281317..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/try_get_value_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'try_get_value function' do - describe 'success' do - pp1 = <<-DOC - $data = { - 'a' => { 'b' => 'passing'} - } - - $tests = try_get_value($data, 'a/b') - notice(inline_template('tests are <%= @tests.inspect %>')) - DOC - it 'gets a value' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{tests are "passing"}) - end - end - end - - describe 'failure' do - pp2 = <<-DOC - $data = { - 'a' => { 'b' => 'passing'} - } - - $tests = try_get_value($data, 'c/d', 'using the default value') - notice(inline_template('tests are <%= @tests.inspect %>')) - DOC - it 'uses a default value' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{using the default value}) - end - end - - pp = <<-DOC - $o = try_get_value() - DOC - it 'raises error on incorrect number of arguments' do - apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(%r{wrong number of arguments}i) - end - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/type3x_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/type3x_spec.rb deleted file mode 100644 index 4b755488c..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/type3x_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'type3x function' do - describe 'success' do - { - %{type3x({ 'a' => 'hash' })} => 'Hash', - %{type3x(['array'])} => 'Array', - %{type3x(false)} => 'Boolean', - %{type3x('asdf')} => 'String', - %{type3x(242)} => 'Integer', - %{type3x(3.14)} => 'Float', - }.each do |pp, type| - it "with type #{type}" do - apply_manifest(pp, :catch_failures => true) - end - end - end - - describe 'failure' do - pp_fail = <<-MANIFEST - type3x('one','two') - MANIFEST - it 'handles improper number of arguments' do - expect(apply_manifest(pp_fail, :expect_failures => true).stderr).to match(%r{Wrong number of arguments}) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/type_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/type_spec.rb deleted file mode 100644 index 7b6e1fbb8..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/type_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'type function' do - describe 'success' do - pp1 = <<-DOC - $a = ["the","public","art","galleries"] - # Anagram: Large picture halls, I bet - $o = type($a) - notice(inline_template('type is <%= @o.to_s %>')) - DOC - it 'types arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{type is Tuple\[String.*, String.*, String.*, String.*\]}) - end - end - - pp2 = <<-DOC - $a = "blowzy night-frumps vex'd jack q" - $o = type($a) - notice(inline_template('type is <%= @o.to_s %>')) - DOC - it 'types strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{type is String}) - end - end - it 'types hashes' - it 'types integers' - it 'types floats' - it 'types booleans' - end - describe 'failure' do - it 'handles no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/union_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/union_spec.rb deleted file mode 100644 index e1b3d9aeb..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/union_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'union function' do - describe 'success' do - pp = <<-DOC - $a = ["the","public"] - $b = ["art"] - $c = ["galleries"] - # Anagram: Large picture halls, I bet - $o = union($a,$b,$c) - notice(inline_template('union is <%= @o.inspect %>')) - DOC - it 'unions arrays' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{union is \["the", "public", "art", "galleries"\]}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/unique_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/unique_spec.rb deleted file mode 100644 index 614eae532..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/unique_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'unique function' do - describe 'success' do - pp1 = <<-DOC - $a = ["wallless", "wallless", "brrr", "goddessship"] - $o = unique($a) - notice(inline_template('unique is <%= @o.inspect %>')) - DOC - it 'uniques arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{unique is \["wallless", "brrr", "goddessship"\]}) - end - end - - pp2 = <<-DOC - $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" - $o = unique($a) - notice(inline_template('unique is <%= @o.inspect %>')) - DOC - it 'uniques strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{unique is "wales prohytingcmbd"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/upcase_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/upcase_spec.rb deleted file mode 100644 index fda444b9d..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/upcase_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'upcase function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"] - $o = upcase($a) - notice(inline_template('upcase is <%= @o.inspect %>')) - DOC - it 'upcases arrays' do - apply_manifest(pp1, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]}) - end - end - - pp2 = <<-DOC - $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" - $o = upcase($a) - notice(inline_template('upcase is <%= @o.inspect %>')) - DOC - it 'upcases strings' do - apply_manifest(pp2, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"}) - end - end - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/uriescape_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/uriescape_spec.rb deleted file mode 100644 index 95536259c..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/uriescape_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'uriescape function' do - describe 'success' do - pp = <<-DOC - $a = ":/?#[]@!$&'()*+,;= \\\"{}" - $o = uriescape($a) - notice(inline_template('uriescape is <%= @o.inspect %>')) - DOC - it 'uriescape strings' do - apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(%r{uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"}) - end - end - it 'does nothing if a string is already safe' - end - describe 'failure' do - it 'handles no arguments' - it 'handles non strings or arrays' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb deleted file mode 100644 index 9fa0f807f..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_absolute_path function' do - describe 'success' do - ['C:/', 'C:\\\\', 'C:\\\\WINDOWS\\\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\\\foo\\\\bar', '/var/tmp', '/var/lib/puppet', '/var/opt/../lib/puppet'].each do |path| - pp = <<-DOC - $one = '#{path}' - validate_absolute_path($one) - DOC - it "validates a single argument #{path}" do - apply_manifest(pp, :catch_failures => true) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles relative paths' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_array_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_array_spec.rb deleted file mode 100644 index 87016c229..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_array_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_array function' do - describe 'success' do - pp1 = <<-DOC - $one = ['a', 'b'] - validate_array($one) - DOC - it 'validates a single argument' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = ['a', 'b'] - $two = [['c'], 'd'] - validate_array($one,$two) - DOC - it 'validates an multiple arguments' do - apply_manifest(pp2, :catch_failures => true) - end - [ - %{validate_array({'a' => 'hash' })}, - %{validate_array('string')}, - %{validate_array(false)}, - %{validate_array(undef)}, - ].each do |pp| - it "rejects #{pp.inspect}" do - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(%r{is not an Array\. It looks to be a}) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_augeas_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_augeas_spec.rb deleted file mode 100644 index 9a59f38cb..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_augeas_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do - describe 'prep' do - it 'installs augeas for tests' - end - describe 'success' do - context 'with valid inputs with no 3rd argument' do - { - 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns', - 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns', - }.each do |line, lens| - pp1 = <<-DOC - $line = "#{line}" - $lens = "#{lens}" - validate_augeas($line, $lens) - DOC - it "validates a single argument for #{lens}" do - apply_manifest(pp1, :catch_failures => true) - end - end - end - - context 'with valid inputs with 3rd and 4th arguments' do - line = 'root:x:0:0:root:/root:/bin/barsh\n' - lens = 'Passwd.lns' - restriction = '$file/*[shell="/bin/barsh"]' - pp2 = <<-DOC - $line = "#{line}" - $lens = "#{lens}" - $restriction = ['#{restriction}'] - validate_augeas($line, $lens, $restriction, "my custom failure message") - DOC - it 'validates a restricted value' do - expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{my custom failure message}) - end - end - - context 'with invalid inputs' do - { - 'root:x:0:0:root' => 'Passwd.lns', - '127.0.1.1' => 'Hosts.lns', - }.each do |line, lens| - pp3 = <<-DOC - $line = "#{line}" - $lens = "#{lens}" - validate_augeas($line, $lens) - DOC - it "validates a single argument for #{lens}" do - apply_manifest(pp3, :expect_failures => true) - end - end - end - context 'with garbage inputs' do - it 'raises an error on invalid inputs' - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_bool_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_bool_spec.rb deleted file mode 100644 index fb3ec14f9..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_bool_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_bool function' do - describe 'success' do - pp1 = <<-DOC - $one = true - validate_bool($one) - DOC - it 'validates a single argument' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = true - $two = false - validate_bool($one,$two) - DOC - it 'validates an multiple arguments' do - apply_manifest(pp2, :catch_failures => true) - end - [ - %{validate_bool('true')}, - %{validate_bool('false')}, - %{validate_bool([true])}, - %{validate_bool(undef)}, - ].each do |pp3| - it "rejects #{pp3.inspect}" do - expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{is not a boolean\. It looks to be a}) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_cmd_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_cmd_spec.rb deleted file mode 100644 index a846b5355..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_cmd_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_cmd function' do - describe 'success' do - pp1 = <<-DOC - $one = 'foo' - if $::osfamily == 'windows' { - $two = 'echo' #shell built-in - } else { - $two = '/bin/echo' - } - validate_cmd($one,$two) - DOC - it 'validates a true command' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = 'foo' - if $::osfamily == 'windows' { - $two = 'C:/aoeu' - } else { - $two = '/bin/aoeu' - } - validate_cmd($one,$two) - DOC - it 'validates a fail command' do - apply_manifest(pp2, :expect_failures => true) - end - - pp3 = <<-DOC - $one = 'foo' - if $::osfamily == 'windows' { - $two = 'C:/aoeu' - } else { - $two = '/bin/aoeu' - } - validate_cmd($one,$two,"aoeu is dvorak") - DOC - it 'validates a fail command with a custom error message' do - apply_manifest(pp3, :expect_failures => true) do |output| - expect(output.stderr).to match(%r{aoeu is dvorak}) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles improper argument types' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_hash_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_hash_spec.rb deleted file mode 100644 index c349020a1..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_hash_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_hash function' do - describe 'success' do - pp1 = <<-DOC - $one = { 'a' => 1 } - validate_hash($one) - DOC - it 'validates a single argument' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = { 'a' => 1 } - $two = { 'b' => 2 } - validate_hash($one,$two) - DOC - it 'validates an multiple arguments' do - apply_manifest(pp2, :catch_failures => true) - end - - [ - %{validate_hash('{ "not" => "hash" }')}, - %{validate_hash('string')}, - %{validate_hash(["array"])}, - %{validate_hash(undef)}, - ].each do |pp3| - it "rejects #{pp3.inspect}" do - expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{}) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb deleted file mode 100644 index 3ea165a58..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_ipv4_address function' do - describe 'success' do - pp1 = <<-DOC - $one = '1.2.3.4' - validate_ipv4_address($one) - DOC - it 'validates a single argument' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = '1.2.3.4' - $two = '5.6.7.8' - validate_ipv4_address($one,$two) - DOC - it 'validates an multiple arguments' do - apply_manifest(pp2, :catch_failures => true) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles ipv6 addresses' - it 'handles non-ipv4 strings' - it 'handles numbers' - it 'handles no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb deleted file mode 100644 index c329331ca..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_ipv6_address function' do - describe 'success' do - pp1 = <<-DOC - $one = '3ffe:0505:0002::' - validate_ipv6_address($one) - DOC - it 'validates a single argument' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = '3ffe:0505:0002::' - $two = '3ffe:0505:0001::' - validate_ipv6_address($one,$two) - DOC - it 'validates an multiple arguments' do - apply_manifest(pp2, :catch_failures => true) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles ipv6 addresses' - it 'handles non-ipv6 strings' - it 'handles numbers' - it 'handles no arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_re_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_re_spec.rb deleted file mode 100644 index 2d2291ca6..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_re_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_re function' do - describe 'success' do - pp1 = <<-DOC - $one = 'one' - $two = '^one$' - validate_re($one,$two) - DOC - it 'validates a string' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = 'one' - $two = ['^one$', '^two'] - validate_re($one,$two) - DOC - it 'validates an array' do - apply_manifest(pp2, :catch_failures => true) - end - - pp3 = <<-DOC - $one = 'one' - $two = ['^two$', '^three'] - validate_re($one,$two) - DOC - it 'validates a failed array' do - apply_manifest(pp3, :expect_failures => true) - end - - pp4 = <<-DOC - $one = '3.4.3' - $two = '^2.7' - validate_re($one,$two,"The $puppetversion fact does not match 2.7") - DOC - it 'validates a failed array with a custom error message' do - expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{does not match}) - end - end - - describe 'failure' do - it 'handles improper number of arguments' - it 'handles improper argument types' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_slength_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_slength_spec.rb deleted file mode 100644 index afbb97b7f..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_slength_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_slength function' do - describe 'success' do - pp1 = <<-DOC - $one = 'discombobulate' - $two = 17 - validate_slength($one,$two) - DOC - it 'validates a single string max' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = ['discombobulate', 'moo'] - $two = 17 - validate_slength($one,$two) - DOC - it 'validates multiple string maxes' do - apply_manifest(pp2, :catch_failures => true) - end - - pp3 = <<-DOC - $one = ['discombobulate', 'moo'] - $two = 17 - $three = 3 - validate_slength($one,$two,$three) - DOC - it 'validates min/max of strings in array' do - apply_manifest(pp3, :catch_failures => true) - end - - pp4 = <<-DOC - $one = 'discombobulate' - $two = 1 - validate_slength($one,$two) - DOC - it 'validates a single string max of incorrect length' do - apply_manifest(pp4, :expect_failures => true) - end - - pp5 = <<-DOC - $one = ['discombobulate', 'moo'] - $two = 3 - validate_slength($one,$two) - DOC - it 'validates multiple string maxes of incorrect length' do - apply_manifest(pp5, :expect_failures => true) - end - - pp6 = <<-DOC - $one = ['discombobulate', 'moo'] - $two = 17 - $three = 10 - validate_slength($one,$two,$three) - DOC - it 'validates multiple strings min/maxes of incorrect length' do - apply_manifest(pp6, :expect_failures => true) - end - end - describe 'failure' do - it 'handles improper number of arguments' - it 'handles improper first argument type' - it 'handles non-strings in array of first argument' - it 'handles improper second argument type' - it 'handles improper third argument type' - it 'handles negative ranges' - it 'handles improper ranges' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/validate_string_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/validate_string_spec.rb deleted file mode 100644 index d141f59f3..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/validate_string_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'validate_string function' do - describe 'success' do - pp1 = <<-DOC - $one = 'string' - validate_string($one) - DOC - it 'validates a single argument' do - apply_manifest(pp1, :catch_failures => true) - end - - pp2 = <<-DOC - $one = 'string' - $two = 'also string' - validate_string($one,$two) - DOC - it 'validates an multiple arguments' do - apply_manifest(pp2, :catch_failures => true) - end - - pp3 = <<-DOC - validate_string(undef) - DOC - it 'validates undef' do - apply_manifest(pp3, :catch_failures => true) - end - - { - %{validate_string({ 'a' => 'hash' })} => 'Hash', - %{validate_string(['array'])} => 'Array', - %{validate_string(false)} => 'FalseClass', - }.each do |pp4, type| - it "validates a non-string: #{pp4.inspect}" do - expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{a #{type}}) - end - end - end - describe 'failure' do - it 'handles improper number of arguments' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/values_at_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/values_at_spec.rb deleted file mode 100644 index ffd6f4c9f..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/values_at_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'values_at function' do - describe 'success' do - pp1 = <<-DOC - $one = ['a','b','c','d','e'] - $two = 1 - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'returns a specific value' do - expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\["b"\]}) - end - - pp2 = <<-DOC - $one = ['a','b','c','d','e'] - $two = -1 - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'returns a specific negative index value' do - pending("negative numbers don't work") - expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\["e"\]}) - end - - pp3 = <<-DOC - $one = ['a','b','c','d','e'] - $two = "1-3" - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'returns a range of values' do - expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\["b", "c", "d"\]}) - end - - pp4 = <<-DOC - $one = ['a','b','c','d','e'] - $two = ["1-3",0] - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'returns a negative specific value and range of values' do - expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\["b", "c", "d", "a"\]}) - end - end - - describe 'failure' do - pp5 = <<-DOC - $one = ['a','b','c','d','e'] - $output = values_at($one) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'handles improper number of arguments' do - expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments}) - end - - pp6 = <<-DOC - $one = ['a','b','c','d','e'] - $two = [] - $output = values_at($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'handles non-indicies arguments' do - expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{at least one positive index}) - end - - it 'detects index ranges smaller than the start range' - it 'handles index ranges larger than array' - it 'handles non-integer indicies' - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/values_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/values_spec.rb deleted file mode 100644 index b450dc7ba..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/values_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'values function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do - describe 'success' do - pp1 = <<-DOC - $arg = { - 'a' => 1, - 'b' => 2, - 'c' => 3, - } - $output = values($arg) - notice(inline_template('<%= @output.sort.inspect %>')) - DOC - it 'returns an array of values' do - expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[1, 2, 3\]}) - end - end - - describe 'failure' do - pp2 = <<-DOC - $arg = "foo" - $output = values($arg) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'handles non-hash arguments' do - expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash}) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/acceptance/zip_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/zip_spec.rb deleted file mode 100644 index 57adfa7a8..000000000 --- a/3rdparty/modules/stdlib/spec/acceptance/zip_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'zip function' do - describe 'success' do - pp1 = <<-DOC - $one = [1,2,3,4] - $two = [5,6,7,8] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'zips two arrays of numbers together' do - expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]}) - end - - pp2 = <<-DOC - $one = [1,2,"three",4] - $two = [true,true,false,false] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'zips two arrays of numbers & bools together' do - expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]}) - end - - # XXX This only tests the argument `true`, even though the following are valid: - # 1 t y true yes - # 0 f n false no - # undef undefined - pp3 = <<-DOC - $one = [1,2,3,4] - $two = [5,6,7,8] - $output = zip($one,$two,true) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'zips two arrays of numbers together and flattens them' do - expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\[1, 5, 2, 6, 3, 7, 4, 8\]}) - end - - # XXX Is this expected behavior? - pp4 = <<-DOC - $one = [1,2] - $two = [5,6,7,8] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'handles unmatched length' do - expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\]\]}) - end - end - - describe 'failure' do - pp5 = <<-DOC - $one = [1,2] - $output = zip($one) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'handles improper number of arguments' do - expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments}) - end - - pp6 = <<-DOC - $one = "a string" - $two = [5,6,7,8] - $output = zip($one,$two) - notice(inline_template('<%= @output.inspect %>')) - DOC - it 'handles improper argument types' do - expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{Requires array}) - end - end -end diff --git a/3rdparty/modules/stdlib/spec/functions/abs_spec.rb b/3rdparty/modules/stdlib/spec/functions/abs_spec.rb index 2d183328b..24dfa2fda 100644 --- a/3rdparty/modules/stdlib/spec/functions/abs_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/abs_spec.rb @@ -2,38 +2,6 @@ require 'spec_helper' if Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 describe 'abs' do it { is_expected.not_to eq(nil) } - - describe 'signature validation in puppet3', :unless => RSpec.configuration.puppet_future do - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { - pending('Current implementation ignores parameters after the first.') - is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) - } - end - - describe 'signature validation in puppet4', :if => RSpec.configuration.puppet_future do - it { - pending 'the puppet 6 implementation' - is_expected.to run.with_params.and_raise_error(ArgumentError) - } - it { - pending 'the puppet 6 implementation' - is_expected.to run.with_params(1, 2).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 6 implementation' - is_expected.to run.with_params([]).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 6 implementation' - is_expected.to run.with_params({}).and_raise_error(ArgumentError) - } - it { - pending 'the puppet 6 implementation' - is_expected.to run.with_params(true).and_raise_error(ArgumentError) - } - end - it { is_expected.to run.with_params(-34).and_return(34) } it { is_expected.to run.with_params('-34').and_return(34) } it { is_expected.to run.with_params(34).and_return(34) } diff --git a/3rdparty/modules/stdlib/spec/functions/basename_spec.rb b/3rdparty/modules/stdlib/spec/functions/basename_spec.rb index 6957133e4..a2a12a1f8 100644 --- a/3rdparty/modules/stdlib/spec/functions/basename_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/basename_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' describe 'basename' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{No arguments given}) } + it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Too many arguments given}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as first argument}) } + it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError, %r{Requires string as second argument}) } it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('file.ext') } it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('file.ext') } it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') } diff --git a/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb b/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb index 3ba5e2cf7..7402f3a9f 100644 --- a/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/bool2num_spec.rb @@ -4,11 +4,15 @@ describe 'bool2num' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - [true, 'true', AlsoString.new('true')].each do |truthy| + [true, 'true', 't', '1', 'y', 'yes', AlsoString.new('true')].each do |truthy| it { is_expected.to run.with_params(truthy).and_return(1) } end - [false, 'false', AlsoString.new('false')].each do |falsey| + [false, 'false', 'f', '0', 'n', 'no', AlsoString.new('false')].each do |falsey| it { is_expected.to run.with_params(falsey).and_return(0) } end + + [[], 10, 'invalid', 1.0].each do |falsey| + it { is_expected.to run.with_params(falsey).and_raise_error(Puppet::ParseError) } + end end diff --git a/3rdparty/modules/stdlib/spec/functions/ceiling_spec.rb b/3rdparty/modules/stdlib/spec/functions/ceiling_spec.rb index 8150c6ef6..7f9a0450a 100644 --- a/3rdparty/modules/stdlib/spec/functions/ceiling_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/ceiling_spec.rb @@ -2,11 +2,12 @@ require 'spec_helper' describe 'ceiling', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{Wrong argument type given}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong argument type given}) } it { is_expected.to run.with_params(34).and_return(34) } it { is_expected.to run.with_params(-34).and_return(-34) } it { is_expected.to run.with_params(33.1).and_return(34) } it { is_expected.to run.with_params(-33.1).and_return(-33) } + it { is_expected.to run.with_params('33.1').and_return(34) } end diff --git a/3rdparty/modules/stdlib/spec/functions/chomp_spec.rb b/3rdparty/modules/stdlib/spec/functions/chomp_spec.rb index e6612e8d3..2137c6166 100644 --- a/3rdparty/modules/stdlib/spec/functions/chomp_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/chomp_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe 'chomp', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments given}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string}) } it { pending('Current implementation ignores parameters after the first.') is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError) @@ -18,6 +18,8 @@ describe 'chomp', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0 it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'two', 'three']) } + it { is_expected.to run.with_params([1, 2, 3]).and_return([1, 2, 3]) } + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } diff --git a/3rdparty/modules/stdlib/spec/functions/chop_spec.rb b/3rdparty/modules/stdlib/spec/functions/chop_spec.rb index b33edb5e8..be9098129 100644 --- a/3rdparty/modules/stdlib/spec/functions/chop_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/chop_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe 'chop', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either an array or string}) } it { pending('Current implementation ignores parameters after the first.') is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError) @@ -18,6 +18,8 @@ describe 'chop', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0' it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'tw', 'three']) } + it { is_expected.to run.with_params([1, 2, 3]).and_return([1, 2, 3]) } + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } diff --git a/3rdparty/modules/stdlib/spec/functions/clamp_spec.rb b/3rdparty/modules/stdlib/spec/functions/clamp_spec.rb index 7f0de3431..6380b2936 100644 --- a/3rdparty/modules/stdlib/spec/functions/clamp_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/clamp_spec.rb @@ -2,11 +2,12 @@ require 'spec_helper' describe 'clamp' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(ArgumentError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } it { is_expected.to run.with_params(12, 88, 71, 190).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments, need three to clamp}) } it { is_expected.to run.with_params('12string', 88, 15).and_raise_error(Puppet::ParseError, %r{Required explicit numeric}) } it { is_expected.to run.with_params(1, 2, 'a' => 55).and_raise_error(Puppet::ParseError, %r{The Hash type is not allowed}) } + it { is_expected.to run.with_params('24', [575, 187]).and_return(187) } it { is_expected.to run.with_params([4, 3, '99']).and_return(4) } it { is_expected.to run.with_params(16, 750, 88).and_return(88) } diff --git a/3rdparty/modules/stdlib/spec/functions/concat_spec.rb b/3rdparty/modules/stdlib/spec/functions/concat_spec.rb index 4c67b3fb7..9290d407c 100644 --- a/3rdparty/modules/stdlib/spec/functions/concat_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/concat_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe 'concat' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError, %r{Requires array}) } it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) } it { is_expected.to run.with_params(['1', '2', '3'], ['4', '5', '6']).and_return(['1', '2', '3', '4', '5', '6']) } it { is_expected.to run.with_params(['1', '2', '3'], '4').and_return(['1', '2', '3', '4']) } diff --git a/3rdparty/modules/stdlib/spec/functions/delete_at_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_at_spec.rb index bc261c720..89359b1b8 100644 --- a/3rdparty/modules/stdlib/spec/functions/delete_at_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/delete_at_spec.rb @@ -2,17 +2,17 @@ require 'spec_helper' describe 'delete_at' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('one', 1).and_raise_error(Puppet::ParseError, %r{Requires array}) } + it { is_expected.to run.with_params(1, 1).and_raise_error(Puppet::ParseError, %r{Requires array}) } + it { is_expected.to run.with_params(['one'], 'two').and_raise_error(Puppet::ParseError, %r{You must provide non-negative numeric}) } it { pending('Current implementation ignores parameters after the first two.') is_expected.to run.with_params(['one'], 0, 1).and_raise_error(Puppet::ParseError) } describe 'argument validation' do - it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, %r{Given index exceeds size of array}) } end it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) } diff --git a/3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb index ff21d310c..8e16b0b3d 100644 --- a/3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/delete_regex_spec.rb @@ -2,13 +2,12 @@ require 'spec_helper' describe 'delete_regex' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } it { is_expected.to run.with_params([], 'two') } it { is_expected.to run.with_params({}, 'two') } - it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], 'two', 'three', 'four').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) } + it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be an Array, Hash, or String}) } describe 'deleting from an array' do it { is_expected.to run.with_params([], '').and_return([]) } diff --git a/3rdparty/modules/stdlib/spec/functions/delete_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_spec.rb index df9ad52be..df5ee7a40 100644 --- a/3rdparty/modules/stdlib/spec/functions/delete_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/delete_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' describe 'delete' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } it { is_expected.to run.with_params([], 'two') } - it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) } + it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be an Array, String, or Hash}) } describe 'deleting from an array' do it { is_expected.to run.with_params([], '').and_return([]) } diff --git a/3rdparty/modules/stdlib/spec/functions/delete_undef_values_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_undef_values_spec.rb index 813105e22..129457949 100644 --- a/3rdparty/modules/stdlib/spec/functions/delete_undef_values_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/delete_undef_values_spec.rb @@ -4,10 +4,10 @@ describe 'delete_undef_values' do let(:is_puppet_6) { Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') == 0 } it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{expected an array or hash}) } + it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{expected an array or hash}) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{expected an array or hash}) } describe 'when deleting from an array' do # Behavior is different in Puppet 6.0.0, and fixed in PUP-9180 in Puppet 6.0.1 diff --git a/3rdparty/modules/stdlib/spec/functions/delete_values_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_values_spec.rb index fdd8ac4df..3ee3af13c 100644 --- a/3rdparty/modules/stdlib/spec/functions/delete_values_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/delete_values_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper' describe 'delete_values' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } describe 'when the first argument is not a hash' do - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError) } - it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError) } + it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) } + it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) } end describe 'when deleting from a hash' do diff --git a/3rdparty/modules/stdlib/spec/functions/difference_spec.rb b/3rdparty/modules/stdlib/spec/functions/difference_spec.rb index 127e7b173..b30437e71 100644 --- a/3rdparty/modules/stdlib/spec/functions/difference_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/difference_spec.rb @@ -2,13 +2,12 @@ require 'spec_helper' describe 'difference' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Requires 2 arrays}) } + it { is_expected.to run.with_params('one', []).and_raise_error(Puppet::ParseError, %r{Requires 2 arrays}) } + it { is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{Requires 2 arrays}) } + it { is_expected.to run.with_params([], []).and_return([]) } it { is_expected.to run.with_params([], ['one']).and_return([]) } it { is_expected.to run.with_params(['one'], ['one']).and_return([]) } diff --git a/3rdparty/modules/stdlib/spec/functions/dig44_spec.rb b/3rdparty/modules/stdlib/spec/functions/dig44_spec.rb index 2a9252cfe..e7c6d817c 100644 --- a/3rdparty/modules/stdlib/spec/functions/dig44_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/dig44_spec.rb @@ -46,15 +46,15 @@ describe 'dig44' do end it 'requires two arguments' do - is_expected.to run.with_params.and_raise_error(ArgumentError) + is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) end it 'fails if the data is not a structure' do - is_expected.to run.with_params('test', []).and_raise_error(Puppet::Error) + is_expected.to run.with_params('test', []).and_raise_error(Puppet::Error, %r{first argument must be a hash or an array}) end it 'fails if the path is not an array' do - is_expected.to run.with_params({}, '').and_raise_error(Puppet::Error) + is_expected.to run.with_params({}, '').and_raise_error(Puppet::Error, %r{second argument must be an array}) end it 'returns the value if the value is string' do diff --git a/3rdparty/modules/stdlib/spec/functions/dirname_spec.rb b/3rdparty/modules/stdlib/spec/functions/dirname_spec.rb index af2f476f9..cda15c8d7 100644 --- a/3rdparty/modules/stdlib/spec/functions/dirname_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/dirname_spec.rb @@ -2,15 +2,14 @@ require 'spec_helper' describe 'dirname' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(:undef).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(nil).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{No arguments given}) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{Too many arguments given}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) } + it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) } + it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires a non-empty string as argument}) } + it { is_expected.to run.with_params(:undef).and_raise_error(Puppet::ParseError, %r{string as argument}) } + it { is_expected.to run.with_params(nil).and_raise_error(Puppet::ParseError, %r{string as argument}) } it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') } it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') } diff --git a/3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb b/3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb index 8677d8c27..4b04f5bba 100644 --- a/3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/dos2unix_spec.rb @@ -10,13 +10,13 @@ describe 'dos2unix' do is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{Wrong number of arguments}) end it do - is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) + is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) end it do - is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError) + is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) end it do - is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) + is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires string as argument}) end end diff --git a/3rdparty/modules/stdlib/spec/functions/downcase_spec.rb b/3rdparty/modules/stdlib/spec/functions/downcase_spec.rb index 78bfec210..181e282b9 100644 --- a/3rdparty/modules/stdlib/spec/functions/downcase_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/downcase_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe 'downcase', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(100).and_raise_error(Puppet::ParseError, %r{Requires either array or string}) } it { is_expected.to run.with_params('abc').and_return('abc') } it { is_expected.to run.with_params('Abc').and_return('abc') } it { is_expected.to run.with_params('ABC').and_return('abc') } diff --git a/3rdparty/modules/stdlib/spec/functions/empty_spec.rb b/3rdparty/modules/stdlib/spec/functions/empty_spec.rb index c6bf1e44a..695c8a5ad 100644 --- a/3rdparty/modules/stdlib/spec/functions/empty_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/empty_spec.rb @@ -2,11 +2,12 @@ require 'spec_helper' describe 'empty', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } it { pending('Current implementation ignores parameters after the first.') is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params(false).and_raise_error(Puppet::ParseError, %r{Requires either array, hash, string or integer}) } it { is_expected.to run.with_params(0).and_return(false) } it { is_expected.to run.with_params('').and_return(true) } it { is_expected.to run.with_params('one').and_return(false) } diff --git a/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb b/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb index 16109e3a2..0b08f35fd 100644 --- a/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb @@ -2,10 +2,11 @@ require 'spec_helper' describe 'flatten', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires array}) } + it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array}) } + it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['one']).and_return(['one']) } it { is_expected.to run.with_params([['one']]).and_return(['one']) } diff --git a/3rdparty/modules/stdlib/spec/functions/floor_spec.rb b/3rdparty/modules/stdlib/spec/functions/floor_spec.rb index 07d4ed3a5..e87a601f9 100644 --- a/3rdparty/modules/stdlib/spec/functions/floor_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/floor_spec.rb @@ -2,9 +2,10 @@ require 'spec_helper' describe 'floor', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, %r{Wrong argument type}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong argument type}) } + it { is_expected.to run.with_params(34).and_return(34) } it { is_expected.to run.with_params(-34).and_return(-34) } it { is_expected.to run.with_params(33.1).and_return(33) } diff --git a/3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb b/3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb index a6da6f26a..60df2e47c 100644 --- a/3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/fqdn_uuid_spec.rb @@ -2,11 +2,15 @@ require 'spec_helper' describe 'fqdn_uuid' do context 'with invalid parameters' do - it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{No arguments given$}) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{No arguments given}) } + it { is_expected.to run.with_params('puppetlabs.com', 'google.com').and_raise_error(ArgumentError, %r{Too many arguments given}) } + it { is_expected.to run.with_params({}).and_raise_error(TypeError, %r{no implicit conversion of Hash}) } + it { is_expected.to run.with_params(0).and_raise_error(TypeError, %r{no implicit conversion of Integer}) } end context 'with given string' do it { is_expected.to run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') } it { is_expected.to run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') } + it { is_expected.to run.with_params('0').and_return('6af613b6-569c-5c22-9c37-2ed93f31d3af') } end end diff --git a/3rdparty/modules/stdlib/spec/functions/has_ip_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/has_ip_address_spec.rb index 33934f35b..8fbde610e 100644 --- a/3rdparty/modules/stdlib/spec/functions/has_ip_address_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/has_ip_address_spec.rb @@ -18,5 +18,6 @@ describe 'has_ip_address' do it { is_expected.to run.with_params('127.0.0.1').and_return(true) } it { is_expected.to run.with_params('10.0.0.1').and_return(true) } it { is_expected.to run.with_params('8.8.8.8').and_return(false) } + it { is_expected.to run.with_params('invalid').and_return(false) } end end diff --git a/3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb b/3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb index cc6ff0b02..b9dbde910 100644 --- a/3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/has_ip_network_spec.rb @@ -17,5 +17,6 @@ describe 'has_ip_network' do it { is_expected.to run.with_params('127.0.0.0').and_return(true) } it { is_expected.to run.with_params('10.0.0.0').and_return(true) } it { is_expected.to run.with_params('8.8.8.0').and_return(false) } + it { is_expected.to run.with_params('invalid').and_return(false) } end end diff --git a/3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb b/3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb new file mode 100644 index 000000000..01d800ce6 --- /dev/null +++ b/3rdparty/modules/stdlib/spec/functions/ip_in_range_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'stdlib::ip_in_range' do + describe 'signature validation' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' expects 2 arguments, got none}) } + it { is_expected.to run.with_params('one', 'two', '3').and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' expects 2 arguments, got 3}) } + it { is_expected.to run.with_params([], []).and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' parameter 'ipaddress' expects a String value, got Array}) } + it { is_expected.to run.with_params('1.1.1.1', 7).and_raise_error(ArgumentError, %r{'stdlib::ip_in_range' parameter 'range' expects a value of type String or Array, got Integer}) } + end + + describe 'basic validation inputs' do + it { is_expected.to run.with_params('192.168.100.12', '192.168.100.0/24').and_return(true) } + it { is_expected.to run.with_params('192.168.100.12', ['10.10.10.10/24', '192.168.100.0/24']).and_return(true) } + it { is_expected.to run.with_params('10.10.10.10', '192.168.100.0/24').and_return(false) } + end +end diff --git a/3rdparty/modules/stdlib/spec/functions/is_domain_name_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_domain_name_spec.rb index c2d598887..16caa8ae0 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_domain_name_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_domain_name_spec.rb @@ -19,9 +19,12 @@ describe 'is_domain_name' do it { is_expected.to run.with_params('2foo.example.com.').and_return(true) } it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) } it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) } + it { is_expected.to run.with_params(true).and_return(false) } + describe 'inputs with spaces' do it { is_expected.to run.with_params('invalid domain').and_return(false) } end + describe 'inputs with hyphens' do it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) } it { is_expected.to run.with_params('foo-bar.example.com.').and_return(true) } @@ -30,13 +33,16 @@ describe 'is_domain_name' do it { is_expected.to run.with_params('-foo.example.com').and_return(false) } it { is_expected.to run.with_params('-foo.example.com.').and_return(false) } end + # Values obtained from Facter values will be frozen strings # in newer versions of Facter: it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) } + describe 'top level domain must be alphabetic if there are multiple labels' do it { is_expected.to run.with_params('2com').and_return(true) } it { is_expected.to run.with_params('www.example.2com').and_return(false) } end + describe 'IP addresses are not domain names' do it { is_expected.to run.with_params('192.168.1.1').and_return(false) } end diff --git a/3rdparty/modules/stdlib/spec/functions/is_float_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_float_spec.rb index effb1da2e..a231446fa 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_float_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_float_spec.rb @@ -5,21 +5,17 @@ describe 'is_float' do it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } it { is_expected.to run.with_params(0.1, 0.2).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - - describe 'passing a string' do - it { is_expected.to run.with_params('0.1').and_return(true) } - it { is_expected.to run.with_params('1.0').and_return(true) } - it { is_expected.to run.with_params('1').and_return(false) } - it { is_expected.to run.with_params('one').and_return(false) } - it { is_expected.to run.with_params('one 1.0').and_return(false) } - it { is_expected.to run.with_params('1.0 one').and_return(false) } - end - - describe 'passing numbers' do - it { is_expected.to run.with_params(0.1).and_return(true) } - it { is_expected.to run.with_params(1.0).and_return(true) } - it { is_expected.to run.with_params(1).and_return(false) } - end + it { is_expected.to run.with_params('0.1').and_return(true) } + it { is_expected.to run.with_params('1.0').and_return(true) } + it { is_expected.to run.with_params('1').and_return(false) } + it { is_expected.to run.with_params('one').and_return(false) } + it { is_expected.to run.with_params('one 1.0').and_return(false) } + it { is_expected.to run.with_params('1.0 one').and_return(false) } + it { is_expected.to run.with_params(0.1).and_return(true) } + it { is_expected.to run.with_params(1.0).and_return(true) } + it { is_expected.to run.with_params(1).and_return(false) } + it { is_expected.to run.with_params({}).and_return(false) } + it { is_expected.to run.with_params([]).and_return(false) } context 'with deprecation warning' do after(:each) do diff --git a/3rdparty/modules/stdlib/spec/functions/is_function_available_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_function_available_spec.rb index 887f06996..4de7f9ea8 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_function_available_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_function_available_spec.rb @@ -6,4 +6,7 @@ describe 'is_function_available' do it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } it { is_expected.to run.with_params('include').and_return(true) } it { is_expected.to run.with_params('no_such_function').and_return(false) } + it { is_expected.to run.with_params([]).and_return(false) } + it { is_expected.to run.with_params({}).and_return(false) } + it { is_expected.to run.with_params(1).and_return(false) } end diff --git a/3rdparty/modules/stdlib/spec/functions/is_hash_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_hash_spec.rb index 3ef061d99..e154be3e5 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_hash_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_hash_spec.rb @@ -8,4 +8,5 @@ describe 'is_hash' do it { is_expected.to run.with_params({}).and_return(true) } it { is_expected.to run.with_params([]).and_return(false) } it { is_expected.to run.with_params(1).and_return(false) } + it { is_expected.to run.with_params([{ 'aaa' => 'bbb' }]).and_return(false) } end diff --git a/3rdparty/modules/stdlib/spec/functions/is_ip_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_ip_address_spec.rb index daa09dbe2..86f3cf892 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_ip_address_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_ip_address_spec.rb @@ -20,21 +20,5 @@ describe 'is_ip_address' do it { is_expected.to run.with_params(1).and_return(false) } it { is_expected.to run.with_params({}).and_return(false) } it { is_expected.to run.with_params([]).and_return(false) } - - context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do - # Checking for deprecation warning, which should only be provoked when the env variable for it is set. - it 'displays a single deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' - expect(scope).to receive(:warning).with(include('This method is deprecated')) - is_expected.to run.with_params('1.2.3.4').and_return(true) - end - it 'displays no warning for deprecation' do - ENV['STDLIB_LOG_DEPRECATIONS'] = 'false' - expect(scope).to receive(:warning).with(include('This method is deprecated')).never - is_expected.to run.with_params('1.2.3.4').and_return(true) - end - after(:each) do - ENV.delete('STDLIB_LOG_DEPRECATIONS') - end - end + it { is_expected.to run.with_params('thisstring').and_return(false) } end diff --git a/3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb index 0aca0e30f..c8bad5128 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_ipv6_address_spec.rb @@ -9,6 +9,7 @@ describe 'is_ipv6_address' do it { is_expected.to run.with_params('1.2.3.4.5').and_return(false) } it { is_expected.to run.with_params('').and_return(false) } it { is_expected.to run.with_params('one').and_return(false) } + it { is_expected.to run.with_params('2001:0db8:85a3:0000:0000:8a2e:0370:7334:ggg').and_return(false) } context 'Checking for deprecation warning', :if => Puppet.version.to_f < 4.0 do after(:each) do diff --git a/3rdparty/modules/stdlib/spec/functions/is_numeric_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_numeric_spec.rb index f9c518045..6125ecdbb 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_numeric_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_numeric_spec.rb @@ -26,6 +26,7 @@ describe 'is_numeric' do it { is_expected.to run.with_params(false).and_return(false) } it { is_expected.to run.with_params('0001234').and_return(false) } it { is_expected.to run.with_params(' - 1234').and_return(false) } + it { is_expected.to run.with_params(['aaa.com', 'bbb', 'ccc']).and_return(false) } context 'with deprecation warning' do after(:each) do diff --git a/3rdparty/modules/stdlib/spec/functions/is_string_spec.rb b/3rdparty/modules/stdlib/spec/functions/is_string_spec.rb index f3a78235e..1fb5264ba 100644 --- a/3rdparty/modules/stdlib/spec/functions/is_string_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/is_string_spec.rb @@ -25,6 +25,7 @@ describe 'is_string' do it { is_expected.to run.with_params(false).and_return(false) } it { is_expected.to run.with_params('one').and_return(true) } it { is_expected.to run.with_params('0001234').and_return(true) } + it { is_expected.to run.with_params('aaa' => 'www.com').and_return(false) } context 'with deprecation warning' do after(:each) do diff --git a/3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb b/3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb index c5ea78a48..a97b6b4ac 100644 --- a/3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/load_module_metadata_spec.rb @@ -9,6 +9,8 @@ describe 'load_module_metadata' do before :each do allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"name": "puppetlabs-stdlib"}') allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"name": "puppetlabs-stdlib"}') + # Additional modules used by litmus which are identified while running these dues to being in fixtures + allow(File).to receive(:read).with(%r{\/(provision|puppet_agent|facts)\/metadata.json}, :encoding => 'utf-8') end context 'when calling with valid utf8 and double byte character arguments' do diff --git a/3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb b/3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb index e6e60f437..c0c630b7b 100644 --- a/3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/loadjson_spec.rb @@ -8,6 +8,8 @@ describe 'loadjson' do before :each do allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}, :encoding => 'utf-8').and_return('{"name": "puppetlabs-stdlib"}') allow(File).to receive(:read).with(%r{\/(stdlib|test)\/metadata.json}).and_return('{"name": "puppetlabs-stdlib"}') + # Additional modules used by litmus which are identified while running these dues to being in fixtures + allow(File).to receive(:read).with(%r{\/(provision|puppet_agent|facts)\/metadata.json}, :encoding => 'utf-8') end context 'when a non-existing file is specified' do diff --git a/3rdparty/modules/stdlib/spec/functions/member_spec.rb b/3rdparty/modules/stdlib/spec/functions/member_spec.rb index f548bb564..861f6e5f8 100644 --- a/3rdparty/modules/stdlib/spec/functions/member_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/member_spec.rb @@ -17,6 +17,8 @@ describe 'member' do it { is_expected.to run.with_params(['one'], 'one').and_return(true) } it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } + it { is_expected.to run.with_params([1, 2, 3, 4], [4, 2]).and_return(true) } + it { is_expected.to run.with_params([1, 'a', 'b', 4], [4, 'b']).and_return(true) } it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ŧẅồ']).and_return(true) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ƒί√ə']).and_return(false) } diff --git a/3rdparty/modules/stdlib/spec/functions/merge_spec.rb b/3rdparty/modules/stdlib/spec/functions/merge_spec.rb index 25e2658f6..7bffaab85 100644 --- a/3rdparty/modules/stdlib/spec/functions/merge_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/merge_spec.rb @@ -2,18 +2,34 @@ require 'spec_helper' describe 'merge' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params({}, 'two').and_raise_error(Puppet::ParseError, %r{unexpected argument type String}) } - it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{unexpected argument type (Fixnum|Integer)}) } it { - pending 'should not special case this' - is_expected.to run.with_params({}).and_return({}) + is_expected.to run \ + .with_params({}, 'two') \ + .and_raise_error( + ArgumentError, \ + Regexp.new(Regexp.escape("rejected: parameter 'args' expects a value of type Undef, Hash, or String[0, 0], got String")), + ) + } + it { + is_expected.to run \ + .with_params({}, 1) \ + .and_raise_error(ArgumentError, %r{parameter 'args' expects a value of type Undef, Hash, or String, got Integer}) } + it { + is_expected.to run \ + .with_params({ 'one' => 1, 'three' => { 'four' => 4 } }, 'two' => 'dos', 'three' => { 'five' => 5 }) \ + .and_return('one' => 1, 'three' => { 'five' => 5 }, 'two' => 'dos') + } + + it { is_expected.to run.with_params.and_return({}) } + it { is_expected.to run.with_params({}).and_return({}) } it { is_expected.to run.with_params({}, {}).and_return({}) } it { is_expected.to run.with_params({}, {}, {}).and_return({}) } + describe 'should accept empty strings as puppet undef' do it { is_expected.to run.with_params({}, '').and_return({}) } end + it { is_expected.to run.with_params({ 'key' => 'value' }, {}).and_return('key' => 'value') } it { is_expected.to run.with_params({}, 'key' => 'value').and_return('key' => 'value') } it { is_expected.to run.with_params({ 'key' => 'value1' }, 'key' => 'value2').and_return('key' => 'value2') } @@ -22,4 +38,43 @@ describe 'merge' do .with_params({ 'key1' => 'value1' }, { 'key2' => 'value2' }, 'key3' => 'value3') \ .and_return('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3') } + describe 'should accept iterable and merge produced hashes' do + it { + is_expected.to run \ + .with_params([1, 2, 3]) \ + .with_lambda { |_hsh, val| { val => val } } \ + .and_return(1 => 1, 2 => 2, 3 => 3) + } + it { + is_expected.to run \ + .with_params([1, 2, 3]) \ + .with_lambda { |_hsh, val| { val => val } unless val == 2 } \ + .and_return(1 => 1, 3 => 3) + } + it { + is_expected.to run \ + .with_params([1, 2, 3]) \ + # rubocop:disable Style/Semicolon + .with_lambda { |_hsh, val| raise StopIteration if val == 3; { val => val } } \ + .and_return(1 => 1, 2 => 2) + } + it { + is_expected.to run \ + .with_params(['a', 'b', 'b', 'c', 'b']) \ + .with_lambda { |hsh, val| { val => (hsh[val] || 0) + 1 } } \ + .and_return('a' => 1, 'b' => 3, 'c' => 1) + } + it { + is_expected.to run \ + .with_params(['a', 'b', 'c']) \ + .with_lambda { |_hsh, idx, val| { idx => val } } \ + .and_return(0 => 'a', 1 => 'b', 2 => 'c') + } + it { + is_expected.to run \ + .with_params('a' => 'A', 'b' => 'B', 'c' => 'C') \ + .with_lambda { |_hsh, key, val| { key => "#{key}#{val}" } } \ + .and_return('a' => 'aA', 'b' => 'bB', 'c' => 'cC') + } + end end diff --git a/3rdparty/modules/stdlib/spec/functions/min_spec.rb b/3rdparty/modules/stdlib/spec/functions/min_spec.rb index 9e350d950..34efb67b5 100644 --- a/3rdparty/modules/stdlib/spec/functions/min_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/min_spec.rb @@ -12,6 +12,7 @@ describe 'min', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') it { is_expected.to run.with_params('one', 'two').and_return('one') } it { is_expected.to run.with_params('one', 'two', 'three').and_return('one') } it { is_expected.to run.with_params('three', 'two', 'one').and_return('one') } + it { is_expected.to run.with_params('the', 'public', 'art', 'galleries').and_return('art') } describe 'implementation artifacts' do it { is_expected.to run.with_params(1, 'one').and_return(1) } diff --git a/3rdparty/modules/stdlib/spec/functions/num2bool_spec.rb b/3rdparty/modules/stdlib/spec/functions/num2bool_spec.rb index 60533e390..786fd9757 100644 --- a/3rdparty/modules/stdlib/spec/functions/num2bool_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/num2bool_spec.rb @@ -19,4 +19,5 @@ describe 'num2bool' do it { is_expected.to run.with_params('[]').and_raise_error(Puppet::ParseError, %r{does not look like a number}) } it { is_expected.to run.with_params({}).and_return(false) } it { is_expected.to run.with_params('{}').and_raise_error(Puppet::ParseError, %r{does not look like a number}) } + it { is_expected.to run.with_params(['-50', '1']).and_return(false) } end diff --git a/3rdparty/modules/stdlib/spec/functions/os_version_gte_spec.rb b/3rdparty/modules/stdlib/spec/functions/os_version_gte_spec.rb index 4abfd7ef3..98ccc4428 100644 --- a/3rdparty/modules/stdlib/spec/functions/os_version_gte_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/os_version_gte_spec.rb @@ -30,4 +30,16 @@ describe 'os_version_gte' do it { is_expected.to run.with_params('Ubuntu', '18.04').and_return(true) } it { is_expected.to run.with_params('Fedora', '29').and_return(false) } end + + context 'with invalid params' do + let(:facts) do + { + :operatingsystem => 'Ubuntu', + :operatingsystemmajrelease => '16.04', + } + end + + it { is_expected.to run.with_params('123', 'abc').and_return(false) } + it { is_expected.to run.with_params([], 123).and_raise_error(ArgumentError) } + end end diff --git a/3rdparty/modules/stdlib/spec/functions/parseyaml_spec.rb b/3rdparty/modules/stdlib/spec/functions/parseyaml_spec.rb index e8d3f4ec1..62e18a324 100644 --- a/3rdparty/modules/stdlib/spec/functions/parseyaml_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/parseyaml_spec.rb @@ -44,18 +44,9 @@ describe 'parseyaml' do end end - context 'on a modern ruby', :unless => RUBY_VERSION == '1.8.7' do - it 'raises an error with invalid YAML and no default' do - is_expected.to run.with_params('["one"') - .and_raise_error(Psych::SyntaxError) - end - end - - context 'when running on ruby 1.8.7, which does not have Psych', :if => RUBY_VERSION == '1.8.7' do - it 'raises an error with invalid YAML and no default' do - is_expected.to run.with_params('["one"') - .and_raise_error(ArgumentError) - end + it 'raises an error with invalid YAML and no default' do + is_expected.to run.with_params('["one"') + .and_raise_error(Psych::SyntaxError) end context 'with incorrect YAML data' do @@ -71,7 +62,7 @@ describe 'parseyaml' do end end - context 'when running on modern rubies', :unless => RUBY_VERSION == '1.8.7' do + context 'when running on modern rubies' do ['---', '...', '*8', ''].each do |value| it "should return the default value for an incorrect #{value.inspect} string parameter" do is_expected.to run.with_params(value, 'default_value') diff --git a/3rdparty/modules/stdlib/spec/functions/sort_spec.rb b/3rdparty/modules/stdlib/spec/functions/sort_spec.rb index a9bdea3ce..0e6e8e6e6 100644 --- a/3rdparty/modules/stdlib/spec/functions/sort_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/sort_spec.rb @@ -30,4 +30,8 @@ describe 'sort', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0' it { is_expected.to run.with_params('a').and_return('a') } it { is_expected.to run.with_params('cbda').and_return('abcd') } end + + context 'when called with a number' do + it { is_expected.to run.with_params('9478').and_return('4789') } + end end diff --git a/3rdparty/modules/stdlib/spec/functions/strftime_spec.rb b/3rdparty/modules/stdlib/spec/functions/strftime_spec.rb index 73c5c968b..92a6893ba 100644 --- a/3rdparty/modules/stdlib/spec/functions/strftime_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/strftime_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'strftime', :if => Puppet::Util::Package.versioncmp(Puppet.version, '4.8.0') < 0 do +describe 'strftime' do it 'exists' do expect(Puppet::Parser::Functions.function('strftime')).to eq('function_strftime') end diff --git a/3rdparty/modules/stdlib/spec/functions/suffix_spec.rb b/3rdparty/modules/stdlib/spec/functions/suffix_spec.rb index bbd1186d7..802d598f2 100644 --- a/3rdparty/modules/stdlib/spec/functions/suffix_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/suffix_spec.rb @@ -17,21 +17,11 @@ describe 'suffix' do it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) } it { is_expected.to run.with_params(['ỗńέ', 'ťשׂǿ', 'ŧҺř℮ə'], 'рổŝţ').and_return(['ỗńέрổŝţ', 'ťשׂǿрổŝţ', 'ŧҺř℮əрổŝţ']) } - it { - is_expected.to run.with_params({}).and_return({}) - } - it { - is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3) - } - it { - is_expected.to run.with_params({}, '').and_return({}) - } - it { - is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') - } - it { - is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return('keypost' => 'value') - } + it { is_expected.to run.with_params({}).and_return({}) } + it { is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3) } + it { is_expected.to run.with_params({}, '').and_return({}) } + it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return('key' => 'value') } + it { is_expected.to run.with_params({ 'key' => 'value' }, 'post').and_return('keypost' => 'value') } it { is_expected.to run \ .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'post') \ diff --git a/3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb b/3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb index 630296bb3..6fe9c10fd 100644 --- a/3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/try_get_value_spec.rb @@ -104,5 +104,9 @@ describe 'try_get_value' do it 'is able to use a custom path separator: default' do is_expected.to run.with_params(data, 'a::c', 'default', '::').and_return('default') end + + it 'is able to throw an error with incorrect params' do + is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}i) + end end end diff --git a/3rdparty/modules/stdlib/spec/functions/validate_absolute_path_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_absolute_path_spec.rb index 53a7feb38..ba73a2192 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_absolute_path_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_absolute_path_spec.rb @@ -41,7 +41,7 @@ describe 'validate_absolute_path' do end context 'with relative paths' do - ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'opt/puppet/bin', 'relative\\windows'].each do |path| + ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'relative\\windows'].each do |path| it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } diff --git a/3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb index c00d5125b..87b7c2431 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_array_spec.rb @@ -30,6 +30,7 @@ describe 'validate_array' do it { is_expected.to run.with_params([], 1).and_raise_error(Puppet::ParseError, %r{is not an Array}) } it { is_expected.to run.with_params([], true).and_raise_error(Puppet::ParseError, %r{is not an Array}) } it { is_expected.to run.with_params([], 'one').and_raise_error(Puppet::ParseError, %r{is not an Array}) } + it { is_expected.to run.with_params(nil).and_raise_error(Puppet::ParseError, %r{is not an Array}) } end end end diff --git a/3rdparty/modules/stdlib/spec/functions/validate_bool_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_bool_spec.rb index e7ca1e292..72c1e2dc9 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_bool_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_bool_spec.rb @@ -24,6 +24,8 @@ describe 'validate_bool' do end describe 'validation failures' do + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } + it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) } it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) } diff --git a/3rdparty/modules/stdlib/spec/functions/validate_hash_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_hash_spec.rb index f71d0c379..1c6213b78 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_hash_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_hash_spec.rb @@ -33,6 +33,7 @@ describe 'validate_hash' do it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) } it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) } + it { is_expected.to run.with_params("{ 'number' => 'one' }").and_raise_error(Puppet::ParseError, %r{is not a Hash}) } end end end diff --git a/3rdparty/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb index 0a1a43378..72c3e7a2d 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_ipv4_address_spec.rb @@ -37,4 +37,9 @@ describe 'validate_ipv4_address' do it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS.first, invalid).and_raise_error(Puppet::ParseError, %r{is not a string}) } end end + + describe 'multiple inputs' do + it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS[0], SharedData::IPV4_PATTERNS[1]) } + it { is_expected.to run.with_params(SharedData::IPV4_PATTERNS[0], 'invalid ip').and_raise_error(Puppet::ParseError, %r{is not a valid IPv4}) } + end end diff --git a/3rdparty/modules/stdlib/spec/functions/validate_re_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_re_spec.rb index 270e2b1ac..2a5068981 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_re_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_re_spec.rb @@ -40,14 +40,14 @@ describe 'validate_re' do describe 'non-string inputs' do [ - 1, # Fixnum - 3.14, # Float - nil, # NilClass - true, # TrueClass - false, # FalseClass - ['10'], # Array - :key, # Symbol - { :key => 'val' }, # Hash + 1, # Fixnum + 3.14, # Float + nil, # NilClass + true, # TrueClass + false, # FalseClass + ['10'], # Array + :key, # Symbol + { :key => 'val' }, # Hash ].each do |input| it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, %r{needs to be a String}) } end diff --git a/3rdparty/modules/stdlib/spec/functions/validate_string_spec.rb b/3rdparty/modules/stdlib/spec/functions/validate_string_spec.rb index 27570d4ae..40522c6f1 100644 --- a/3rdparty/modules/stdlib/spec/functions/validate_string_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/validate_string_spec.rb @@ -28,6 +28,7 @@ describe 'validate_string' do it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) } it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) } it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) } + it { is_expected.to run.with_params('one', 2).and_raise_error(Puppet::ParseError, %r{is not a string}) } end end end diff --git a/3rdparty/modules/stdlib/spec/functions/zip_spec.rb b/3rdparty/modules/stdlib/spec/functions/zip_spec.rb index 433e44800..c2b4e3bb3 100644 --- a/3rdparty/modules/stdlib/spec/functions/zip_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/zip_spec.rb @@ -12,6 +12,9 @@ describe 'zip' do it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6]).and_return([[1, 4], [2, 5], [3, 6]]) } it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], false).and_return([[1, 4], [2, 5], [3, 6]]) } it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], true).and_return([1, 4, 2, 5, 3, 6]) } + it { is_expected.to run.with_params([1, 2, 'four'], [true, true, false]).and_return([[1, true], [2, true], ['four', false]]) } + it { is_expected.to run.with_params([1, 2, 3], [4, 5]).and_return([[1, 4], [2, 5], [3, nil]]) } + it { is_expected.to run.with_params('A string', [4, 5]).and_raise_error(Puppet::ParseError, %r{Requires array}i) } context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params(['ầ', 'ь', 'ć'], ['đ', 'ề', 'ƒ']).and_return([['ầ', 'đ'], ['ь', 'ề'], ['ć', 'ƒ']]) } diff --git a/3rdparty/modules/stdlib/spec/spec_helper.rb b/3rdparty/modules/stdlib/spec/spec_helper.rb index 0a030e672..012cbacb1 100644 --- a/3rdparty/modules/stdlib/spec/spec_helper.rb +++ b/3rdparty/modules/stdlib/spec/spec_helper.rb @@ -23,12 +23,17 @@ default_fact_files.each do |f| next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f))) + default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) rescue => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value +end + RSpec.configure do |c| c.default_facts = default_facts c.before :each do @@ -36,8 +41,13 @@ RSpec.configure do |c| # by default Puppet runs at warning level Puppet.settings[:strict] = :warning end + c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + c.after(:suite) do + end end +# Ensures that a module is defined +# @param module_name Name of the module def ensure_module_defined(module_name) module_name.split('::').reduce(Object) do |last_module, next_module| last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) diff --git a/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb b/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb index d6587031a..820e9bf8c 100644 --- a/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb +++ b/3rdparty/modules/stdlib/spec/spec_helper_acceptance.rb @@ -1,57 +1,82 @@ -require 'beaker-pe' -require 'beaker-puppet' -require 'puppet' -require 'beaker-rspec' -require 'beaker/puppet_install_helper' -require 'beaker/module_install_helper' +# frozen_string_literal: true -run_puppet_install_helper -configure_type_defaults_on(hosts) -install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i -install_module_on(hosts) -install_module_dependencies_on(hosts) +require 'serverspec' +require 'puppet_litmus' +require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) +include PuppetLitmus -RSpec.configure do |c| - # Readable test descriptions - c.formatter = :documentation - - # Configure all nodes in nodeset - c.before :suite do +if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost' + puts 'Running tests against this machine !' + if Gem.win_platform? + set :backend, :cmd + else + set :backend, :exec end -end +else + # load inventory + inventory_hash = inventory_hash_from_inventory_file + node_config = config_from_node(inventory_hash, ENV['TARGET_HOST']) -def return_puppet_version - (on default, puppet('--version')).output.chomp -end - -RSpec.shared_context 'with faked facts' do - let(:facts_d) do - puppet_version = return_puppet_version - if fact('osfamily') =~ %r{windows}i - if fact('kernelmajversion').to_f < 6.0 - 'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d' - else - 'C:/ProgramData/PuppetLabs/facter/facts.d' - end - elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 && fact('is_pe', '--puppet') == 'true' - '/etc/puppetlabs/facter/facts.d' - else - '/etc/facter/facts.d' - end - end - - before :each do - # No need to create on windows, PE creates by default - if fact('osfamily') !~ %r{windows}i - shell("mkdir -p '#{facts_d}'") - end - end - - after :each do - shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0, 1]) - end + if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes') + host = ENV['TARGET_HOST'] + set :backend, :docker + set :docker_container, host + elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes') + set :backend, :ssh + options = Net::SSH::Config.for(host) + options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil? + options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil? + options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil? + options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil? + # Support both net-ssh 4 and 5. + # rubocop:disable Metrics/BlockNesting + options[:verify_host_key] = if node_config.dig('ssh', 'host-key-check').nil? + # Fall back to SSH behavior. This variable will only be set in net-ssh 5.3+. + if @strict_host_key_checking.nil? || @strict_host_key_checking + Net::SSH::Verifiers::Always.new + else + # SSH's behavior with StrictHostKeyChecking=no: adds new keys to known_hosts. + # If known_hosts points to /dev/null, then equivalent to :never where it + # accepts any key beacuse they're all new. + Net::SSH::Verifiers::AcceptNewOrLocalTunnel.new + end + elsif node_config.dig('ssh', 'host-key-check') + if defined?(Net::SSH::Verifiers::Always) + Net::SSH::Verifiers::Always.new + else + Net::SSH::Verifiers::Secure.new + end + elsif defined?(Net::SSH::Verifiers::Never) + Net::SSH::Verifiers::Never.new + else + Net::SSH::Verifiers::Null.new + end + # rubocop:enable Metrics/BlockNesting + host = if ENV['TARGET_HOST'].include?(':') + ENV['TARGET_HOST'].split(':').first + else + ENV['TARGET_HOST'] + end + set :host, options[:host_name] || host + set :ssh_options, options + set :request_pty, true + elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes') + require 'winrm' + # rubocop:disable Style/HashSyntax + set :backend, :winrm + set :os, family: 'windows' + user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil? + pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil? + endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" - def fake_fact(name, value) - shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'") + opts = { + user: user, + password: pass, + endpoint: endpoint, + operation_timeout: 300, + } + # rubocop:enable Style/HashSyntax + winrm = WinRM::Connection.new opts + Specinfra.configuration.winrm = winrm end end diff --git a/3rdparty/modules/stdlib/spec/type_aliases/objectstore_gsuri_spec.rb b/3rdparty/modules/stdlib/spec/type_aliases/objectstore_gsuri_spec.rb new file mode 100644 index 000000000..9f5ec65e4 --- /dev/null +++ b/3rdparty/modules/stdlib/spec/type_aliases/objectstore_gsuri_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::ObjectStore::GSUri' do + describe 'accepts case-sensitive google cloud gs uris' do + [ + 'gs://mybucket/myfile.csv', + 'gs://bucket/path/to/file.tar.gz', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '', + 'GS://mybucket/myfile.csv', + 5, + 'gs//mybucket/myfile.csv', + 'gs:/mybucket/myfile.csv', + 'gs:mybucket/myfile.csv', + 'gs-mybucket/myfile.csv', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/3rdparty/modules/stdlib/spec/type_aliases/objectstore_s3uri_spec.rb b/3rdparty/modules/stdlib/spec/type_aliases/objectstore_s3uri_spec.rb new file mode 100644 index 000000000..e711ad279 --- /dev/null +++ b/3rdparty/modules/stdlib/spec/type_aliases/objectstore_s3uri_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::ObjectStore::S3Uri' do + describe 'accepts case-sensitive amazon web services s3 uris' do + [ + 's3://bucket-name/path', + 's3://bucket/path/to/file.txt', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '', + 'S3://bucket-name/path', + 3, + 's3:/bucket-name/path', + 's3//bucket-name/path', + 's3:bucket-name/path', + 's3-bucket-name/path', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/3rdparty/modules/stdlib/spec/type_aliases/objectstore_spec.rb b/3rdparty/modules/stdlib/spec/type_aliases/objectstore_spec.rb new file mode 100644 index 000000000..ae3c2caca --- /dev/null +++ b/3rdparty/modules/stdlib/spec/type_aliases/objectstore_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::ObjectStore' do + describe 'accepts case-sensitive google cloud gs or amazon web services s3 uris' do + [ + 's3://bucket-name/path', + 's3://bucket/path/to/file.txt', + 'gs://mybucket/myfile.csv', + 'gs://bucket/path/to/file.tar.gz', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '', + 'S3://bucket/path', + 'GS://bucket/path', + 5, + 3, + 'gs//bucket/path/to/file', + 's3//bucket/path/to/file', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/3rdparty/modules/stdlib/spec/type_aliases/yes_no_spec.rb b/3rdparty/modules/stdlib/spec/type_aliases/yes_no_spec.rb new file mode 100644 index 000000000..9416c6ae2 --- /dev/null +++ b/3rdparty/modules/stdlib/spec/type_aliases/yes_no_spec.rb @@ -0,0 +1,44 @@ +# coding: utf-8 + +require 'spec_helper' + +describe 'Stdlib::Yes_no' do + describe 'valid types' do + [ + 'yes', + 'no', + 'YES', + 'Yes', + 'NO', + 'No', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'invalid types' do + context 'with garbage inputs' do + [ + true, + false, + :keyword, + nil, + ['yes', 'no'], + { 'foo' => 'bar' }, + {}, + '', + 'ネット', + '55555', + '0x123', + 'yess', + 'nooo', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/3rdparty/modules/stdlib/types/objectstore.pp b/3rdparty/modules/stdlib/types/objectstore.pp new file mode 100644 index 000000000..a89fb6a45 --- /dev/null +++ b/3rdparty/modules/stdlib/types/objectstore.pp @@ -0,0 +1,4 @@ +type Stdlib::ObjectStore = Variant[ + Stdlib::ObjectStore::GSUri, + Stdlib::ObjectStore::S3Uri, +] diff --git a/3rdparty/modules/stdlib/types/objectstore/gsuri.pp b/3rdparty/modules/stdlib/types/objectstore/gsuri.pp new file mode 100644 index 000000000..61e73448f --- /dev/null +++ b/3rdparty/modules/stdlib/types/objectstore/gsuri.pp @@ -0,0 +1,2 @@ +type Stdlib::ObjectStore::GSUri = Pattern[/^gs:\/\//] + diff --git a/3rdparty/modules/stdlib/types/objectstore/s3uri.pp b/3rdparty/modules/stdlib/types/objectstore/s3uri.pp new file mode 100644 index 000000000..6c42e1666 --- /dev/null +++ b/3rdparty/modules/stdlib/types/objectstore/s3uri.pp @@ -0,0 +1 @@ +type Stdlib::ObjectStore::S3Uri = Pattern[/^s3:\/\//] diff --git a/3rdparty/modules/stdlib/types/syslogfacility.pp b/3rdparty/modules/stdlib/types/syslogfacility.pp new file mode 100644 index 000000000..417673ba7 --- /dev/null +++ b/3rdparty/modules/stdlib/types/syslogfacility.pp @@ -0,0 +1,26 @@ +type Stdlib::Syslogfacility = Enum[ + 'kern', + 'user', + 'mail', + 'daemon', + 'auth', + 'syslog', + 'lpr', + 'news', + 'uucp', + 'cron', + 'authpriv', + 'ftp', + 'ntp', + 'security', + 'console', + 'solaris-cron', + 'local0', + 'local1', + 'local2', + 'local3', + 'local4', + 'local5', + 'local6', + 'local7' +] diff --git a/3rdparty/modules/stdlib/types/yes_no.pp b/3rdparty/modules/stdlib/types/yes_no.pp new file mode 100644 index 000000000..d87f4eebf --- /dev/null +++ b/3rdparty/modules/stdlib/types/yes_no.pp @@ -0,0 +1 @@ +type Stdlib::Yes_no = Pattern[/\A(?i:(yes|no))\z/] -- 2.20.1