bolt 0.20.0 → 0.20.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/bolt/cli.rb +5 -0
- data/lib/bolt/puppetdb/client.rb +1 -1
- data/lib/bolt/transport/ssh.rb +1 -1
- data/lib/bolt/util/on_access.rb +4 -2
- data/lib/bolt/version.rb +1 -1
- data/vendored/facter/lib/facter.rb +261 -0
- data/vendored/facter/lib/facter/Cfkey.rb +42 -0
- data/vendored/facter/lib/facter/application.rb +206 -0
- data/vendored/facter/lib/facter/architecture.rb +50 -0
- data/vendored/facter/lib/facter/augeasversion.rb +28 -0
- data/vendored/facter/lib/facter/blockdevices.rb +105 -0
- data/vendored/facter/lib/facter/core/aggregate.rb +220 -0
- data/vendored/facter/lib/facter/core/directed_graph.rb +46 -0
- data/vendored/facter/lib/facter/core/execution.rb +123 -0
- data/vendored/facter/lib/facter/core/execution/base.rb +81 -0
- data/vendored/facter/lib/facter/core/execution/posix.rb +50 -0
- data/vendored/facter/lib/facter/core/execution/windows.rb +57 -0
- data/vendored/facter/lib/facter/core/logging.rb +197 -0
- data/vendored/facter/lib/facter/core/resolvable.rb +94 -0
- data/vendored/facter/lib/facter/core/suitable.rb +113 -0
- data/vendored/facter/lib/facter/dhcp_servers.rb +45 -0
- data/vendored/facter/lib/facter/domain.rb +99 -0
- data/vendored/facter/lib/facter/ec2.rb +68 -0
- data/vendored/facter/lib/facter/ec2/rest.rb +137 -0
- data/vendored/facter/lib/facter/facterversion.rb +15 -0
- data/vendored/facter/lib/facter/filesystems.rb +45 -0
- data/vendored/facter/lib/facter/fqdn.rb +24 -0
- data/vendored/facter/lib/facter/gce.rb +16 -0
- data/vendored/facter/lib/facter/gce/metadata.rb +87 -0
- data/vendored/facter/lib/facter/gid.rb +25 -0
- data/vendored/facter/lib/facter/hardwareisa.rb +20 -0
- data/vendored/facter/lib/facter/hardwaremodel.rb +67 -0
- data/vendored/facter/lib/facter/hostname.rb +31 -0
- data/vendored/facter/lib/facter/id.rb +21 -0
- data/vendored/facter/lib/facter/interfaces.rb +58 -0
- data/vendored/facter/lib/facter/ipaddress.rb +169 -0
- data/vendored/facter/lib/facter/ipaddress6.rb +82 -0
- data/vendored/facter/lib/facter/iphostnumber.rb +29 -0
- data/vendored/facter/lib/facter/kernel.rb +22 -0
- data/vendored/facter/lib/facter/kernelmajversion.rb +23 -0
- data/vendored/facter/lib/facter/kernelrelease.rb +45 -0
- data/vendored/facter/lib/facter/kernelversion.rb +22 -0
- data/vendored/facter/lib/facter/ldom.rb +51 -0
- data/vendored/facter/lib/facter/lsbdistcodename.rb +20 -0
- data/vendored/facter/lib/facter/lsbdistdescription.rb +21 -0
- data/vendored/facter/lib/facter/lsbdistid.rb +20 -0
- data/vendored/facter/lib/facter/lsbdistrelease.rb +20 -0
- data/vendored/facter/lib/facter/lsbmajdistrelease.rb +22 -0
- data/vendored/facter/lib/facter/lsbminordistrelease.rb +22 -0
- data/vendored/facter/lib/facter/lsbrelease.rb +20 -0
- data/vendored/facter/lib/facter/macaddress.rb +99 -0
- data/vendored/facter/lib/facter/macosx.rb +56 -0
- data/vendored/facter/lib/facter/manufacturer.rb +68 -0
- data/vendored/facter/lib/facter/memory.rb +168 -0
- data/vendored/facter/lib/facter/netmask.rb +43 -0
- data/vendored/facter/lib/facter/network.rb +20 -0
- data/vendored/facter/lib/facter/operatingsystem.rb +24 -0
- data/vendored/facter/lib/facter/operatingsystem/base.rb +61 -0
- data/vendored/facter/lib/facter/operatingsystem/cumuluslinux.rb +27 -0
- data/vendored/facter/lib/facter/operatingsystem/implementation.rb +33 -0
- data/vendored/facter/lib/facter/operatingsystem/linux.rb +484 -0
- data/vendored/facter/lib/facter/operatingsystem/osreleaselinux.rb +28 -0
- data/vendored/facter/lib/facter/operatingsystem/sunos.rb +54 -0
- data/vendored/facter/lib/facter/operatingsystem/vmkernel.rb +11 -0
- data/vendored/facter/lib/facter/operatingsystem/windows.rb +43 -0
- data/vendored/facter/lib/facter/operatingsystemmajrelease.rb +31 -0
- data/vendored/facter/lib/facter/operatingsystemrelease.rb +29 -0
- data/vendored/facter/lib/facter/os.rb +98 -0
- data/vendored/facter/lib/facter/osfamily.rb +18 -0
- data/vendored/facter/lib/facter/partitions.rb +39 -0
- data/vendored/facter/lib/facter/path.rb +14 -0
- data/vendored/facter/lib/facter/physicalprocessorcount.rb +27 -0
- data/vendored/facter/lib/facter/processor.rb +52 -0
- data/vendored/facter/lib/facter/processors.rb +66 -0
- data/vendored/facter/lib/facter/processors/os.rb +244 -0
- data/vendored/facter/lib/facter/ps.rb +31 -0
- data/vendored/facter/lib/facter/puppetversion.rb +20 -0
- data/vendored/facter/lib/facter/rackspace.rb +37 -0
- data/vendored/facter/lib/facter/rubyplatform.rb +12 -0
- data/vendored/facter/lib/facter/rubysitedir.rb +15 -0
- data/vendored/facter/lib/facter/rubyversion.rb +12 -0
- data/vendored/facter/lib/facter/selinux.rb +154 -0
- data/vendored/facter/lib/facter/ssh.rb +73 -0
- data/vendored/facter/lib/facter/system32.rb +21 -0
- data/vendored/facter/lib/facter/system_uptime.rb +44 -0
- data/vendored/facter/lib/facter/timezone.rb +14 -0
- data/vendored/facter/lib/facter/uniqueid.rb +4 -0
- data/vendored/facter/lib/facter/uptime.rb +16 -0
- data/vendored/facter/lib/facter/uptime_days.rb +13 -0
- data/vendored/facter/lib/facter/uptime_hours.rb +13 -0
- data/vendored/facter/lib/facter/uptime_seconds.rb +20 -0
- data/vendored/facter/lib/facter/util/architecture.rb +19 -0
- data/vendored/facter/lib/facter/util/collection.rb +161 -0
- data/vendored/facter/lib/facter/util/composite_loader.rb +12 -0
- data/vendored/facter/lib/facter/util/config.rb +88 -0
- data/vendored/facter/lib/facter/util/confine.rb +66 -0
- data/vendored/facter/lib/facter/util/dhcp_servers.rb +58 -0
- data/vendored/facter/lib/facter/util/directory_loader.rb +88 -0
- data/vendored/facter/lib/facter/util/ec2.rb +106 -0
- data/vendored/facter/lib/facter/util/fact.rb +204 -0
- data/vendored/facter/lib/facter/util/file_read.rb +37 -0
- data/vendored/facter/lib/facter/util/formatter.rb +39 -0
- data/vendored/facter/lib/facter/util/ip.rb +340 -0
- data/vendored/facter/lib/facter/util/ip/windows.rb +215 -0
- data/vendored/facter/lib/facter/util/loader.rb +155 -0
- data/vendored/facter/lib/facter/util/macaddress.rb +43 -0
- data/vendored/facter/lib/facter/util/macosx.rb +73 -0
- data/vendored/facter/lib/facter/util/manufacturer.rb +99 -0
- data/vendored/facter/lib/facter/util/memory.rb +228 -0
- data/vendored/facter/lib/facter/util/netmask.rb +40 -0
- data/vendored/facter/lib/facter/util/normalization.rb +94 -0
- data/vendored/facter/lib/facter/util/nothing_loader.rb +12 -0
- data/vendored/facter/lib/facter/util/operatingsystem.rb +21 -0
- data/vendored/facter/lib/facter/util/parser.rb +168 -0
- data/vendored/facter/lib/facter/util/partitions.rb +47 -0
- data/vendored/facter/lib/facter/util/partitions/linux.rb +71 -0
- data/vendored/facter/lib/facter/util/partitions/openbsd.rb +40 -0
- data/vendored/facter/lib/facter/util/plist.rb +24 -0
- data/vendored/facter/lib/facter/util/plist/generator.rb +228 -0
- data/vendored/facter/lib/facter/util/plist/parser.rb +226 -0
- data/vendored/facter/lib/facter/util/posix.rb +16 -0
- data/vendored/facter/lib/facter/util/processor.rb +289 -0
- data/vendored/facter/lib/facter/util/registry.rb +11 -0
- data/vendored/facter/lib/facter/util/resolution.rb +160 -0
- data/vendored/facter/lib/facter/util/solaris_zones.rb +158 -0
- data/vendored/facter/lib/facter/util/unix_root.rb +5 -0
- data/vendored/facter/lib/facter/util/uptime.rb +83 -0
- data/vendored/facter/lib/facter/util/values.rb +109 -0
- data/vendored/facter/lib/facter/util/virtual.rb +212 -0
- data/vendored/facter/lib/facter/util/vlans.rb +21 -0
- data/vendored/facter/lib/facter/util/windows.rb +10 -0
- data/vendored/facter/lib/facter/util/windows/api_types.rb +135 -0
- data/vendored/facter/lib/facter/util/windows/dir.rb +43 -0
- data/vendored/facter/lib/facter/util/windows/error.rb +87 -0
- data/vendored/facter/lib/facter/util/windows/process.rb +294 -0
- data/vendored/facter/lib/facter/util/windows/user.rb +186 -0
- data/vendored/facter/lib/facter/util/windows_root.rb +7 -0
- data/vendored/facter/lib/facter/util/wmi.rb +49 -0
- data/vendored/facter/lib/facter/util/xendomains.rb +28 -0
- data/vendored/facter/lib/facter/version.rb +86 -0
- data/vendored/facter/lib/facter/virtual.rb +330 -0
- data/vendored/facter/lib/facter/vlans.rb +17 -0
- data/vendored/facter/lib/facter/xendomains.rb +20 -0
- data/vendored/facter/lib/facter/zfs_version.rb +14 -0
- data/vendored/facter/lib/facter/zonename.rb +6 -0
- data/vendored/facter/lib/facter/zones.rb +18 -0
- data/vendored/facter/lib/facter/zpool_version.rb +10 -0
- data/vendored/hiera/lib/hiera.rb +119 -0
- data/vendored/hiera/lib/hiera/backend.rb +360 -0
- data/vendored/hiera/lib/hiera/backend/json_backend.rb +58 -0
- data/vendored/hiera/lib/hiera/backend/yaml_backend.rb +63 -0
- data/vendored/hiera/lib/hiera/config.rb +97 -0
- data/vendored/hiera/lib/hiera/console_logger.rb +13 -0
- data/vendored/hiera/lib/hiera/error.rb +4 -0
- data/vendored/hiera/lib/hiera/fallback_logger.rb +41 -0
- data/vendored/hiera/lib/hiera/filecache.rb +86 -0
- data/vendored/hiera/lib/hiera/interpolate.rb +121 -0
- data/vendored/hiera/lib/hiera/noop_logger.rb +8 -0
- data/vendored/hiera/lib/hiera/puppet_logger.rb +17 -0
- data/vendored/hiera/lib/hiera/recursive_guard.rb +20 -0
- data/vendored/hiera/lib/hiera/util.rb +65 -0
- data/vendored/hiera/lib/hiera/util/win32.rb +40 -0
- data/vendored/hiera/lib/hiera/version.rb +89 -0
- data/vendored/puppet/lib/hiera/puppet_function.rb +84 -0
- data/vendored/puppet/lib/hiera/scope.rb +61 -0
- data/vendored/puppet/lib/hiera_puppet.rb +79 -0
- data/vendored/puppet/lib/puppet.rb +307 -0
- data/vendored/puppet/lib/puppet/agent.rb +134 -0
- data/vendored/puppet/lib/puppet/agent/disabler.rb +53 -0
- data/vendored/puppet/lib/puppet/agent/locker.rb +53 -0
- data/vendored/puppet/lib/puppet/application.rb +502 -0
- data/vendored/puppet/lib/puppet/application/agent.rb +473 -0
- data/vendored/puppet/lib/puppet/application/apply.rb +356 -0
- data/vendored/puppet/lib/puppet/application/ca.rb +11 -0
- data/vendored/puppet/lib/puppet/application/catalog.rb +4 -0
- data/vendored/puppet/lib/puppet/application/cert.rb +339 -0
- data/vendored/puppet/lib/puppet/application/certificate.rb +17 -0
- data/vendored/puppet/lib/puppet/application/certificate_request.rb +7 -0
- data/vendored/puppet/lib/puppet/application/certificate_revocation_list.rb +7 -0
- data/vendored/puppet/lib/puppet/application/config.rb +5 -0
- data/vendored/puppet/lib/puppet/application/describe.rb +257 -0
- data/vendored/puppet/lib/puppet/application/device.rb +378 -0
- data/vendored/puppet/lib/puppet/application/doc.rb +230 -0
- data/vendored/puppet/lib/puppet/application/epp.rb +5 -0
- data/vendored/puppet/lib/puppet/application/face_base.rb +268 -0
- data/vendored/puppet/lib/puppet/application/facts.rb +9 -0
- data/vendored/puppet/lib/puppet/application/filebucket.rb +300 -0
- data/vendored/puppet/lib/puppet/application/generate.rb +5 -0
- data/vendored/puppet/lib/puppet/application/help.rb +5 -0
- data/vendored/puppet/lib/puppet/application/indirection_base.rb +4 -0
- data/vendored/puppet/lib/puppet/application/key.rb +4 -0
- data/vendored/puppet/lib/puppet/application/lookup.rb +369 -0
- data/vendored/puppet/lib/puppet/application/man.rb +4 -0
- data/vendored/puppet/lib/puppet/application/master.rb +317 -0
- data/vendored/puppet/lib/puppet/application/module.rb +4 -0
- data/vendored/puppet/lib/puppet/application/node.rb +4 -0
- data/vendored/puppet/lib/puppet/application/parser.rb +5 -0
- data/vendored/puppet/lib/puppet/application/plugin.rb +3 -0
- data/vendored/puppet/lib/puppet/application/report.rb +4 -0
- data/vendored/puppet/lib/puppet/application/resource.rb +231 -0
- data/vendored/puppet/lib/puppet/application/script.rb +261 -0
- data/vendored/puppet/lib/puppet/application/status.rb +4 -0
- data/vendored/puppet/lib/puppet/application_support.rb +62 -0
- data/vendored/puppet/lib/puppet/coercion.rb +40 -0
- data/vendored/puppet/lib/puppet/compilable_resource_type.rb +15 -0
- data/vendored/puppet/lib/puppet/configurer.rb +464 -0
- data/vendored/puppet/lib/puppet/configurer/downloader.rb +67 -0
- data/vendored/puppet/lib/puppet/configurer/fact_handler.rb +46 -0
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +49 -0
- data/vendored/puppet/lib/puppet/confine.rb +80 -0
- data/vendored/puppet/lib/puppet/confine/any.rb +26 -0
- data/vendored/puppet/lib/puppet/confine/exists.rb +19 -0
- data/vendored/puppet/lib/puppet/confine/false.rb +19 -0
- data/vendored/puppet/lib/puppet/confine/feature.rb +17 -0
- data/vendored/puppet/lib/puppet/confine/true.rb +20 -0
- data/vendored/puppet/lib/puppet/confine/variable.rb +59 -0
- data/vendored/puppet/lib/puppet/confine_collection.rb +50 -0
- data/vendored/puppet/lib/puppet/confiner.rb +46 -0
- data/vendored/puppet/lib/puppet/context.rb +116 -0
- data/vendored/puppet/lib/puppet/context/trusted_information.rb +76 -0
- data/vendored/puppet/lib/puppet/daemon.rb +195 -0
- data/vendored/puppet/lib/puppet/data_binding.rb +14 -0
- data/vendored/puppet/lib/puppet/datatypes.rb +213 -0
- data/vendored/puppet/lib/puppet/datatypes/error.rb +21 -0
- data/vendored/puppet/lib/puppet/datatypes/impl/error.rb +40 -0
- data/vendored/puppet/lib/puppet/defaults.rb +2071 -0
- data/vendored/puppet/lib/puppet/environments.rb +511 -0
- data/vendored/puppet/lib/puppet/error.rb +110 -0
- data/vendored/puppet/lib/puppet/etc.rb +161 -0
- data/vendored/puppet/lib/puppet/external/dot.rb +319 -0
- data/vendored/puppet/lib/puppet/external/nagios.rb +46 -0
- data/vendored/puppet/lib/puppet/external/nagios/base.rb +472 -0
- data/vendored/puppet/lib/puppet/external/nagios/parser.rb +400 -0
- data/vendored/puppet/lib/puppet/external/pson/common.rb +374 -0
- data/vendored/puppet/lib/puppet/external/pson/pure.rb +15 -0
- data/vendored/puppet/lib/puppet/external/pson/pure/generator.rb +395 -0
- data/vendored/puppet/lib/puppet/external/pson/pure/parser.rb +307 -0
- data/vendored/puppet/lib/puppet/external/pson/version.rb +8 -0
- data/vendored/puppet/lib/puppet/face.rb +12 -0
- data/vendored/puppet/lib/puppet/face/ca.rb +266 -0
- data/vendored/puppet/lib/puppet/face/catalog.rb +130 -0
- data/vendored/puppet/lib/puppet/face/catalog/select.rb +49 -0
- data/vendored/puppet/lib/puppet/face/certificate.rb +165 -0
- data/vendored/puppet/lib/puppet/face/certificate_request.rb +56 -0
- data/vendored/puppet/lib/puppet/face/certificate_revocation_list.rb +56 -0
- data/vendored/puppet/lib/puppet/face/config.rb +210 -0
- data/vendored/puppet/lib/puppet/face/epp.rb +554 -0
- data/vendored/puppet/lib/puppet/face/facts.rb +87 -0
- data/vendored/puppet/lib/puppet/face/generate.rb +64 -0
- data/vendored/puppet/lib/puppet/face/help.rb +201 -0
- data/vendored/puppet/lib/puppet/face/key.rb +16 -0
- data/vendored/puppet/lib/puppet/face/man.rb +145 -0
- data/vendored/puppet/lib/puppet/face/module.rb +19 -0
- data/vendored/puppet/lib/puppet/face/module/build.rb +64 -0
- data/vendored/puppet/lib/puppet/face/module/changes.rb +42 -0
- data/vendored/puppet/lib/puppet/face/module/generate.rb +256 -0
- data/vendored/puppet/lib/puppet/face/module/install.rb +150 -0
- data/vendored/puppet/lib/puppet/face/module/list.rb +268 -0
- data/vendored/puppet/lib/puppet/face/module/search.rb +98 -0
- data/vendored/puppet/lib/puppet/face/module/uninstall.rb +93 -0
- data/vendored/puppet/lib/puppet/face/module/upgrade.rb +91 -0
- data/vendored/puppet/lib/puppet/face/node.rb +43 -0
- data/vendored/puppet/lib/puppet/face/node/clean.rb +96 -0
- data/vendored/puppet/lib/puppet/face/parser.rb +187 -0
- data/vendored/puppet/lib/puppet/face/plugin.rb +56 -0
- data/vendored/puppet/lib/puppet/face/report.rb +54 -0
- data/vendored/puppet/lib/puppet/face/resource.rb +53 -0
- data/vendored/puppet/lib/puppet/face/status.rb +51 -0
- data/vendored/puppet/lib/puppet/feature/base.rb +95 -0
- data/vendored/puppet/lib/puppet/feature/bolt.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/eventlog.rb +5 -0
- data/vendored/puppet/lib/puppet/feature/hiera_eyaml.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/hocon.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/libuser.rb +8 -0
- data/vendored/puppet/lib/puppet/feature/msgpack.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/pe_license.rb +4 -0
- data/vendored/puppet/lib/puppet/feature/rack.rb +19 -0
- data/vendored/puppet/lib/puppet/feature/selinux.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/ssh.rb +3 -0
- data/vendored/puppet/lib/puppet/feature/telnet.rb +9 -0
- data/vendored/puppet/lib/puppet/feature/zlib.rb +5 -0
- data/vendored/puppet/lib/puppet/file_bucket.rb +4 -0
- data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +173 -0
- data/vendored/puppet/lib/puppet/file_bucket/file.rb +129 -0
- data/vendored/puppet/lib/puppet/file_serving.rb +3 -0
- data/vendored/puppet/lib/puppet/file_serving/base.rb +86 -0
- data/vendored/puppet/lib/puppet/file_serving/configuration.rb +115 -0
- data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +137 -0
- data/vendored/puppet/lib/puppet/file_serving/content.rb +43 -0
- data/vendored/puppet/lib/puppet/file_serving/fileset.rb +174 -0
- data/vendored/puppet/lib/puppet/file_serving/http_metadata.rb +46 -0
- data/vendored/puppet/lib/puppet/file_serving/metadata.rb +163 -0
- data/vendored/puppet/lib/puppet/file_serving/mount.rb +39 -0
- data/vendored/puppet/lib/puppet/file_serving/mount/file.rb +121 -0
- data/vendored/puppet/lib/puppet/file_serving/mount/locales.rb +35 -0
- data/vendored/puppet/lib/puppet/file_serving/mount/modules.rb +24 -0
- data/vendored/puppet/lib/puppet/file_serving/mount/pluginfacts.rb +35 -0
- data/vendored/puppet/lib/puppet/file_serving/mount/plugins.rb +35 -0
- data/vendored/puppet/lib/puppet/file_serving/mount/tasks.rb +21 -0
- data/vendored/puppet/lib/puppet/file_serving/terminus_helper.rb +31 -0
- data/vendored/puppet/lib/puppet/file_serving/terminus_selector.rb +32 -0
- data/vendored/puppet/lib/puppet/file_system.rb +404 -0
- data/vendored/puppet/lib/puppet/file_system/file_impl.rb +154 -0
- data/vendored/puppet/lib/puppet/file_system/memory_file.rb +66 -0
- data/vendored/puppet/lib/puppet/file_system/memory_impl.rb +86 -0
- data/vendored/puppet/lib/puppet/file_system/path_pattern.rb +98 -0
- data/vendored/puppet/lib/puppet/file_system/posix.rb +46 -0
- data/vendored/puppet/lib/puppet/file_system/uniquefile.rb +190 -0
- data/vendored/puppet/lib/puppet/file_system/windows.rb +130 -0
- data/vendored/puppet/lib/puppet/forge.rb +242 -0
- data/vendored/puppet/lib/puppet/forge/cache.rb +60 -0
- data/vendored/puppet/lib/puppet/forge/errors.rb +114 -0
- data/vendored/puppet/lib/puppet/forge/repository.rb +155 -0
- data/vendored/puppet/lib/puppet/functions.rb +725 -0
- data/vendored/puppet/lib/puppet/functions/alert.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/all.rb +104 -0
- data/vendored/puppet/lib/puppet/functions/annotate.rb +108 -0
- data/vendored/puppet/lib/puppet/functions/any.rb +109 -0
- data/vendored/puppet/lib/puppet/functions/assert_type.rb +93 -0
- data/vendored/puppet/lib/puppet/functions/binary_file.rb +32 -0
- data/vendored/puppet/lib/puppet/functions/break.rb +51 -0
- data/vendored/puppet/lib/puppet/functions/call.rb +42 -0
- data/vendored/puppet/lib/puppet/functions/contain.rb +55 -0
- data/vendored/puppet/lib/puppet/functions/convert_to.rb +33 -0
- data/vendored/puppet/lib/puppet/functions/crit.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/debug.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/defined.rb +159 -0
- data/vendored/puppet/lib/puppet/functions/dig.rb +47 -0
- data/vendored/puppet/lib/puppet/functions/each.rb +169 -0
- data/vendored/puppet/lib/puppet/functions/emerg.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/empty.rb +79 -0
- data/vendored/puppet/lib/puppet/functions/epp.rb +48 -0
- data/vendored/puppet/lib/puppet/functions/err.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +96 -0
- data/vendored/puppet/lib/puppet/functions/filter.rb +143 -0
- data/vendored/puppet/lib/puppet/functions/find_file.rb +44 -0
- data/vendored/puppet/lib/puppet/functions/flatten.rb +64 -0
- data/vendored/puppet/lib/puppet/functions/hiera.rb +88 -0
- data/vendored/puppet/lib/puppet/functions/hiera_array.rb +81 -0
- data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +92 -0
- data/vendored/puppet/lib/puppet/functions/hiera_include.rb +104 -0
- data/vendored/puppet/lib/puppet/functions/hocon_data.rb +41 -0
- data/vendored/puppet/lib/puppet/functions/import.rb +7 -0
- data/vendored/puppet/lib/puppet/functions/include.rb +53 -0
- data/vendored/puppet/lib/puppet/functions/info.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/inline_epp.rb +59 -0
- data/vendored/puppet/lib/puppet/functions/join.rb +56 -0
- data/vendored/puppet/lib/puppet/functions/json_data.rb +33 -0
- data/vendored/puppet/lib/puppet/functions/keys.rb +25 -0
- data/vendored/puppet/lib/puppet/functions/length.rb +44 -0
- data/vendored/puppet/lib/puppet/functions/lest.rb +55 -0
- data/vendored/puppet/lib/puppet/functions/lookup.rb +223 -0
- data/vendored/puppet/lib/puppet/functions/map.rb +136 -0
- data/vendored/puppet/lib/puppet/functions/match.rb +120 -0
- data/vendored/puppet/lib/puppet/functions/module_directory.rb +41 -0
- data/vendored/puppet/lib/puppet/functions/new.rb +1022 -0
- data/vendored/puppet/lib/puppet/functions/next.rb +23 -0
- data/vendored/puppet/lib/puppet/functions/notice.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/reduce.rb +164 -0
- data/vendored/puppet/lib/puppet/functions/regsubst.rb +82 -0
- data/vendored/puppet/lib/puppet/functions/require.rb +77 -0
- data/vendored/puppet/lib/puppet/functions/return.rb +22 -0
- data/vendored/puppet/lib/puppet/functions/reverse_each.rb +94 -0
- data/vendored/puppet/lib/puppet/functions/scanf.rb +44 -0
- data/vendored/puppet/lib/puppet/functions/slice.rb +124 -0
- data/vendored/puppet/lib/puppet/functions/split.rb +49 -0
- data/vendored/puppet/lib/puppet/functions/step.rb +98 -0
- data/vendored/puppet/lib/puppet/functions/strftime.rb +217 -0
- data/vendored/puppet/lib/puppet/functions/then.rb +77 -0
- data/vendored/puppet/lib/puppet/functions/tree_each.rb +200 -0
- data/vendored/puppet/lib/puppet/functions/type.rb +72 -0
- data/vendored/puppet/lib/puppet/functions/unique.rb +132 -0
- data/vendored/puppet/lib/puppet/functions/unwrap.rb +44 -0
- data/vendored/puppet/lib/puppet/functions/values.rb +25 -0
- data/vendored/puppet/lib/puppet/functions/versioncmp.rb +36 -0
- data/vendored/puppet/lib/puppet/functions/warning.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/with.rb +32 -0
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +42 -0
- data/vendored/puppet/lib/puppet/generate/models/type/property.rb +70 -0
- data/vendored/puppet/lib/puppet/generate/models/type/type.rb +62 -0
- data/vendored/puppet/lib/puppet/generate/type.rb +239 -0
- data/vendored/puppet/lib/puppet/gettext/config.rb +252 -0
- data/vendored/puppet/lib/puppet/gettext/module_translations.rb +42 -0
- data/vendored/puppet/lib/puppet/gettext/stubs.rb +11 -0
- data/vendored/puppet/lib/puppet/graph.rb +11 -0
- data/vendored/puppet/lib/puppet/graph/key.rb +26 -0
- data/vendored/puppet/lib/puppet/graph/prioritizer.rb +29 -0
- data/vendored/puppet/lib/puppet/graph/random_prioritizer.rb +16 -0
- data/vendored/puppet/lib/puppet/graph/rb_tree_map.rb +388 -0
- data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +283 -0
- data/vendored/puppet/lib/puppet/graph/sequential_prioritizer.rb +31 -0
- data/vendored/puppet/lib/puppet/graph/simple_graph.rb +539 -0
- data/vendored/puppet/lib/puppet/graph/title_hash_prioritizer.rb +16 -0
- data/vendored/puppet/lib/puppet/indirector.rb +61 -0
- data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +418 -0
- data/vendored/puppet/lib/puppet/indirector/catalog/json.rb +24 -0
- data/vendored/puppet/lib/puppet/indirector/catalog/msgpack.rb +6 -0
- data/vendored/puppet/lib/puppet/indirector/catalog/rest.rb +6 -0
- data/vendored/puppet/lib/puppet/indirector/catalog/store_configs.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/catalog/yaml.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/certificate/ca.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/certificate/file.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/certificate/rest.rb +16 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_request/ca.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_request/file.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_request/memory.rb +6 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_request/rest.rb +10 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/ca.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/file.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_status.rb +4 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +91 -0
- data/vendored/puppet/lib/puppet/indirector/certificate_status/rest.rb +11 -0
- data/vendored/puppet/lib/puppet/indirector/code.rb +6 -0
- data/vendored/puppet/lib/puppet/indirector/data_binding/hiera.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/data_binding/none.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/direct_file_server.rb +17 -0
- data/vendored/puppet/lib/puppet/indirector/envelope.rb +11 -0
- data/vendored/puppet/lib/puppet/indirector/errors.rb +5 -0
- data/vendored/puppet/lib/puppet/indirector/exec.rb +38 -0
- data/vendored/puppet/lib/puppet/indirector/face.rb +153 -0
- data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +88 -0
- data/vendored/puppet/lib/puppet/indirector/facts/memory.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/facts/network_device.rb +27 -0
- data/vendored/puppet/lib/puppet/indirector/facts/rest.rb +21 -0
- data/vendored/puppet/lib/puppet/indirector/facts/store_configs.rb +11 -0
- data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +82 -0
- data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +262 -0
- data/vendored/puppet/lib/puppet/indirector/file_bucket_file/rest.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/file_bucket_file/selector.rb +53 -0
- data/vendored/puppet/lib/puppet/indirector/file_content.rb +5 -0
- data/vendored/puppet/lib/puppet/indirector/file_content/file.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/file_content/file_server.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/file_content/http.rb +17 -0
- data/vendored/puppet/lib/puppet/indirector/file_content/rest.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/file_content/selector.rb +30 -0
- data/vendored/puppet/lib/puppet/indirector/file_metadata.rb +5 -0
- data/vendored/puppet/lib/puppet/indirector/file_metadata/file.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/file_metadata/file_server.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/file_metadata/http.rb +27 -0
- data/vendored/puppet/lib/puppet/indirector/file_metadata/rest.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/file_metadata/selector.rb +30 -0
- data/vendored/puppet/lib/puppet/indirector/file_server.rb +59 -0
- data/vendored/puppet/lib/puppet/indirector/generic_http.rb +16 -0
- data/vendored/puppet/lib/puppet/indirector/hiera.rb +94 -0
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +344 -0
- data/vendored/puppet/lib/puppet/indirector/json.rb +75 -0
- data/vendored/puppet/lib/puppet/indirector/key/ca.rb +16 -0
- data/vendored/puppet/lib/puppet/indirector/key/disabled_ca.rb +22 -0
- data/vendored/puppet/lib/puppet/indirector/key/file.rb +50 -0
- data/vendored/puppet/lib/puppet/indirector/key/memory.rb +6 -0
- data/vendored/puppet/lib/puppet/indirector/ldap.rb +80 -0
- data/vendored/puppet/lib/puppet/indirector/memory.rb +34 -0
- data/vendored/puppet/lib/puppet/indirector/msgpack.rb +83 -0
- data/vendored/puppet/lib/puppet/indirector/node/exec.rb +71 -0
- data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +275 -0
- data/vendored/puppet/lib/puppet/indirector/node/memory.rb +10 -0
- data/vendored/puppet/lib/puppet/indirector/node/msgpack.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/node/plain.rb +21 -0
- data/vendored/puppet/lib/puppet/indirector/node/rest.rb +7 -0
- data/vendored/puppet/lib/puppet/indirector/node/store_configs.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +39 -0
- data/vendored/puppet/lib/puppet/indirector/node/yaml.rb +13 -0
- data/vendored/puppet/lib/puppet/indirector/none.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/plain.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/report/msgpack.rb +11 -0
- data/vendored/puppet/lib/puppet/indirector/report/processor.rb +59 -0
- data/vendored/puppet/lib/puppet/indirector/report/rest.rb +28 -0
- data/vendored/puppet/lib/puppet/indirector/report/yaml.rb +11 -0
- data/vendored/puppet/lib/puppet/indirector/request.rb +278 -0
- data/vendored/puppet/lib/puppet/indirector/resource/ral.rb +63 -0
- data/vendored/puppet/lib/puppet/indirector/resource/store_configs.rb +12 -0
- data/vendored/puppet/lib/puppet/indirector/resource/validator.rb +8 -0
- data/vendored/puppet/lib/puppet/indirector/rest.rb +350 -0
- data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +201 -0
- data/vendored/puppet/lib/puppet/indirector/status.rb +3 -0
- data/vendored/puppet/lib/puppet/indirector/status/local.rb +12 -0
- data/vendored/puppet/lib/puppet/indirector/status/rest.rb +9 -0
- data/vendored/puppet/lib/puppet/indirector/store_configs.rb +30 -0
- data/vendored/puppet/lib/puppet/indirector/terminus.rb +169 -0
- data/vendored/puppet/lib/puppet/indirector/yaml.rb +63 -0
- data/vendored/puppet/lib/puppet/info_service.rb +17 -0
- data/vendored/puppet/lib/puppet/info_service/class_information_service.rb +110 -0
- data/vendored/puppet/lib/puppet/info_service/task_information_service.rb +32 -0
- data/vendored/puppet/lib/puppet/interface.rb +237 -0
- data/vendored/puppet/lib/puppet/interface/action.rb +402 -0
- data/vendored/puppet/lib/puppet/interface/action_builder.rb +166 -0
- data/vendored/puppet/lib/puppet/interface/action_manager.rb +97 -0
- data/vendored/puppet/lib/puppet/interface/documentation.rb +353 -0
- data/vendored/puppet/lib/puppet/interface/face_collection.rb +132 -0
- data/vendored/puppet/lib/puppet/interface/option.rb +171 -0
- data/vendored/puppet/lib/puppet/interface/option_builder.rb +105 -0
- data/vendored/puppet/lib/puppet/interface/option_manager.rb +104 -0
- data/vendored/puppet/lib/puppet/loaders.rb +27 -0
- data/vendored/puppet/lib/puppet/metatype/manager.rb +199 -0
- data/vendored/puppet/lib/puppet/module.rb +467 -0
- data/vendored/puppet/lib/puppet/module/task.rb +90 -0
- data/vendored/puppet/lib/puppet/module_tool.rb +196 -0
- data/vendored/puppet/lib/puppet/module_tool/applications.rb +14 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +90 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +152 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +62 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +355 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/searcher.rb +29 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +121 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +100 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +281 -0
- data/vendored/puppet/lib/puppet/module_tool/checksums.rb +49 -0
- data/vendored/puppet/lib/puppet/module_tool/contents_description.rb +88 -0
- data/vendored/puppet/lib/puppet/module_tool/dependency.rb +41 -0
- data/vendored/puppet/lib/puppet/module_tool/errors.rb +11 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/base.rb +15 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +93 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +195 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +50 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +63 -0
- data/vendored/puppet/lib/puppet/module_tool/install_directory.rb +45 -0
- data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +96 -0
- data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +90 -0
- data/vendored/puppet/lib/puppet/module_tool/metadata.rb +223 -0
- data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +180 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +1 -0
- data/vendored/puppet/lib/puppet/module_tool/tar.rb +18 -0
- data/vendored/puppet/lib/puppet/module_tool/tar/gnu.rb +19 -0
- data/vendored/puppet/lib/puppet/module_tool/tar/mini.rb +106 -0
- data/vendored/puppet/lib/puppet/network.rb +3 -0
- data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +90 -0
- data/vendored/puppet/lib/puppet/network/authconfig.rb +112 -0
- data/vendored/puppet/lib/puppet/network/authorization.rb +41 -0
- data/vendored/puppet/lib/puppet/network/authstore.rb +282 -0
- data/vendored/puppet/lib/puppet/network/client_request.rb +29 -0
- data/vendored/puppet/lib/puppet/network/format.rb +110 -0
- data/vendored/puppet/lib/puppet/network/format_handler.rb +108 -0
- data/vendored/puppet/lib/puppet/network/format_support.rb +134 -0
- data/vendored/puppet/lib/puppet/network/formats.rb +171 -0
- data/vendored/puppet/lib/puppet/network/http.rb +30 -0
- data/vendored/puppet/lib/puppet/network/http/api.rb +44 -0
- data/vendored/puppet/lib/puppet/network/http/api/ca.rb +2 -0
- data/vendored/puppet/lib/puppet/network/http/api/ca/v1.rb +11 -0
- data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +279 -0
- data/vendored/puppet/lib/puppet/network/http/api/indirection_type.rb +32 -0
- data/vendored/puppet/lib/puppet/network/http/api/master.rb +2 -0
- data/vendored/puppet/lib/puppet/network/http/api/master/v3.rb +28 -0
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/authorization.rb +18 -0
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +85 -0
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +35 -0
- data/vendored/puppet/lib/puppet/network/http/compression.rb +120 -0
- data/vendored/puppet/lib/puppet/network/http/connection.rb +332 -0
- data/vendored/puppet/lib/puppet/network/http/error.rb +73 -0
- data/vendored/puppet/lib/puppet/network/http/factory.rb +56 -0
- data/vendored/puppet/lib/puppet/network/http/handler.rb +183 -0
- data/vendored/puppet/lib/puppet/network/http/issues.rb +12 -0
- data/vendored/puppet/lib/puppet/network/http/memory_response.rb +13 -0
- data/vendored/puppet/lib/puppet/network/http/nocache_pool.rb +21 -0
- data/vendored/puppet/lib/puppet/network/http/pool.rb +129 -0
- data/vendored/puppet/lib/puppet/network/http/rack.rb +33 -0
- data/vendored/puppet/lib/puppet/network/http/rack/rest.rb +162 -0
- data/vendored/puppet/lib/puppet/network/http/request.rb +70 -0
- data/vendored/puppet/lib/puppet/network/http/response.rb +23 -0
- data/vendored/puppet/lib/puppet/network/http/route.rb +100 -0
- data/vendored/puppet/lib/puppet/network/http/session.rb +17 -0
- data/vendored/puppet/lib/puppet/network/http/site.rb +39 -0
- data/vendored/puppet/lib/puppet/network/http/webrick.rb +124 -0
- data/vendored/puppet/lib/puppet/network/http/webrick/rest.rb +114 -0
- data/vendored/puppet/lib/puppet/network/http_pool.rb +61 -0
- data/vendored/puppet/lib/puppet/network/resolver.rb +85 -0
- data/vendored/puppet/lib/puppet/network/rest_controller.rb +2 -0
- data/vendored/puppet/lib/puppet/network/rights.rb +209 -0
- data/vendored/puppet/lib/puppet/network/server.rb +39 -0
- data/vendored/puppet/lib/puppet/node.rb +282 -0
- data/vendored/puppet/lib/puppet/node/environment.rb +586 -0
- data/vendored/puppet/lib/puppet/node/facts.rb +137 -0
- data/vendored/puppet/lib/puppet/parameter.rb +567 -0
- data/vendored/puppet/lib/puppet/parameter/boolean.rb +15 -0
- data/vendored/puppet/lib/puppet/parameter/package_options.rb +31 -0
- data/vendored/puppet/lib/puppet/parameter/path.rb +57 -0
- data/vendored/puppet/lib/puppet/parameter/value.rb +91 -0
- data/vendored/puppet/lib/puppet/parameter/value_collection.rb +212 -0
- data/vendored/puppet/lib/puppet/parser.rb +20 -0
- data/vendored/puppet/lib/puppet/parser/abstract_compiler.rb +36 -0
- data/vendored/puppet/lib/puppet/parser/ast.rb +65 -0
- data/vendored/puppet/lib/puppet/parser/ast/block_expression.rb +15 -0
- data/vendored/puppet/lib/puppet/parser/ast/branch.rb +19 -0
- data/vendored/puppet/lib/puppet/parser/ast/hostclass.rb +27 -0
- data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +75 -0
- data/vendored/puppet/lib/puppet/parser/ast/node.rb +17 -0
- data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +273 -0
- data/vendored/puppet/lib/puppet/parser/ast/resource.rb +66 -0
- data/vendored/puppet/lib/puppet/parser/ast/resource_instance.rb +10 -0
- data/vendored/puppet/lib/puppet/parser/ast/resourceparam.rb +31 -0
- data/vendored/puppet/lib/puppet/parser/ast/top_level_construct.rb +4 -0
- data/vendored/puppet/lib/puppet/parser/compiler.rb +797 -0
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +57 -0
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/vendored/puppet/lib/puppet/parser/e4_parser_adapter.rb +60 -0
- data/vendored/puppet/lib/puppet/parser/environment_compiler.rb +199 -0
- data/vendored/puppet/lib/puppet/parser/files.rb +92 -0
- data/vendored/puppet/lib/puppet/parser/functions.rb +277 -0
- data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +60 -0
- data/vendored/puppet/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/vendored/puppet/lib/puppet/parser/functions/break.rb +39 -0
- data/vendored/puppet/lib/puppet/parser/functions/contain.rb +30 -0
- data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +112 -0
- data/vendored/puppet/lib/puppet/parser/functions/defined.rb +107 -0
- data/vendored/puppet/lib/puppet/parser/functions/dig.rb +38 -0
- data/vendored/puppet/lib/puppet/parser/functions/digest.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/functions/each.rb +104 -0
- data/vendored/puppet/lib/puppet/parser/functions/epp.rb +39 -0
- data/vendored/puppet/lib/puppet/parser/functions/fail.rb +4 -0
- data/vendored/puppet/lib/puppet/parser/functions/file.rb +33 -0
- data/vendored/puppet/lib/puppet/parser/functions/filter.rb +78 -0
- data/vendored/puppet/lib/puppet/parser/functions/find_file.rb +28 -0
- data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +36 -0
- data/vendored/puppet/lib/puppet/parser/functions/generate.rb +36 -0
- data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +103 -0
- data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +92 -0
- data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +102 -0
- data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +102 -0
- data/vendored/puppet/lib/puppet/parser/functions/include.rb +34 -0
- data/vendored/puppet/lib/puppet/parser/functions/inline_epp.rb +51 -0
- data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +26 -0
- data/vendored/puppet/lib/puppet/parser/functions/lest.rb +49 -0
- data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +132 -0
- data/vendored/puppet/lib/puppet/parser/functions/map.rb +76 -0
- data/vendored/puppet/lib/puppet/parser/functions/match.rb +43 -0
- data/vendored/puppet/lib/puppet/parser/functions/md5.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/functions/new.rb +991 -0
- data/vendored/puppet/lib/puppet/parser/functions/next.rb +38 -0
- data/vendored/puppet/lib/puppet/parser/functions/realize.rb +20 -0
- data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +137 -0
- data/vendored/puppet/lib/puppet/parser/functions/regsubst.rb +62 -0
- data/vendored/puppet/lib/puppet/parser/functions/require.rb +40 -0
- data/vendored/puppet/lib/puppet/parser/functions/return.rb +71 -0
- data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +83 -0
- data/vendored/puppet/lib/puppet/parser/functions/scanf.rb +38 -0
- data/vendored/puppet/lib/puppet/parser/functions/sha1.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/functions/sha256.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/functions/shellquote.rb +61 -0
- data/vendored/puppet/lib/puppet/parser/functions/slice.rb +39 -0
- data/vendored/puppet/lib/puppet/parser/functions/split.rb +28 -0
- data/vendored/puppet/lib/puppet/parser/functions/sprintf.rb +50 -0
- data/vendored/puppet/lib/puppet/parser/functions/step.rb +84 -0
- data/vendored/puppet/lib/puppet/parser/functions/strftime.rb +185 -0
- data/vendored/puppet/lib/puppet/parser/functions/tag.rb +12 -0
- data/vendored/puppet/lib/puppet/parser/functions/tagged.rb +24 -0
- data/vendored/puppet/lib/puppet/parser/functions/template.rb +39 -0
- data/vendored/puppet/lib/puppet/parser/functions/then.rb +73 -0
- data/vendored/puppet/lib/puppet/parser/functions/type.rb +53 -0
- data/vendored/puppet/lib/puppet/parser/functions/versioncmp.rb +30 -0
- data/vendored/puppet/lib/puppet/parser/functions/with.rb +28 -0
- data/vendored/puppet/lib/puppet/parser/parser_factory.rb +30 -0
- data/vendored/puppet/lib/puppet/parser/relationship.rb +83 -0
- data/vendored/puppet/lib/puppet/parser/resource.rb +417 -0
- data/vendored/puppet/lib/puppet/parser/resource/param.rb +22 -0
- data/vendored/puppet/lib/puppet/parser/scope.rb +1125 -0
- data/vendored/puppet/lib/puppet/parser/script_compiler.rb +118 -0
- data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +102 -0
- data/vendored/puppet/lib/puppet/parser/type_loader.rb +149 -0
- data/vendored/puppet/lib/puppet/plugins.rb +9 -0
- data/vendored/puppet/lib/puppet/plugins/configuration.rb +25 -0
- data/vendored/puppet/lib/puppet/plugins/syntax_checkers.rb +98 -0
- data/vendored/puppet/lib/puppet/pops.rb +120 -0
- data/vendored/puppet/lib/puppet/pops/adaptable.rb +206 -0
- data/vendored/puppet/lib/puppet/pops/adapters.rb +138 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +719 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/callable_signature.rb +107 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +373 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +234 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +86 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +29 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/collectors/exported_collector.rb +69 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb +37 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +252 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +120 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +1284 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/external_syntax_support.rb +45 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +82 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/puppet_proc.rb +69 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/relationship_operator.rb +185 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +202 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +117 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +540 -0
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +101 -0
- data/vendored/puppet/lib/puppet/pops/functions/dispatcher.rb +71 -0
- data/vendored/puppet/lib/puppet/pops/functions/function.rb +141 -0
- data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +137 -0
- data/vendored/puppet/lib/puppet/pops/issues.rb +901 -0
- data/vendored/puppet/lib/puppet/pops/label_provider.rb +90 -0
- data/vendored/puppet/lib/puppet/pops/loader/base_loader.rb +166 -0
- data/vendored/puppet/lib/puppet/pops/loader/dependency_loader.rb +92 -0
- data/vendored/puppet/lib/puppet/pops/loader/gem_support.rb +49 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +209 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +375 -0
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +523 -0
- data/vendored/puppet/lib/puppet/pops/loader/null_loader.rb +60 -0
- data/vendored/puppet/lib/puppet/pops/loader/predefined_loader.rb +24 -0
- data/vendored/puppet/lib/puppet/pops/loader/puppet_function_instantiator.rb +84 -0
- data/vendored/puppet/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
- data/vendored/puppet/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +79 -0
- data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +39 -0
- data/vendored/puppet/lib/puppet/pops/loader/ruby_function_instantiator.rb +45 -0
- data/vendored/puppet/lib/puppet/pops/loader/runtime3_type_loader.rb +101 -0
- data/vendored/puppet/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +163 -0
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +69 -0
- data/vendored/puppet/lib/puppet/pops/loader/type_definition_instantiator.rb +100 -0
- data/vendored/puppet/lib/puppet/pops/loader/typed_name.rb +54 -0
- data/vendored/puppet/lib/puppet/pops/loader/uri_helper.rb +22 -0
- data/vendored/puppet/lib/puppet/pops/loaders.rb +545 -0
- data/vendored/puppet/lib/puppet/pops/lookup.rb +96 -0
- data/vendored/puppet/lib/puppet/pops/lookup/configured_data_provider.rb +93 -0
- data/vendored/puppet/lib/puppet/pops/lookup/context.rb +200 -0
- data/vendored/puppet/lib/puppet/pops/lookup/data_adapter.rb +27 -0
- data/vendored/puppet/lib/puppet/pops/lookup/data_dig_function_provider.rb +145 -0
- data/vendored/puppet/lib/puppet/pops/lookup/data_hash_function_provider.rb +126 -0
- data/vendored/puppet/lib/puppet/pops/lookup/data_provider.rb +92 -0
- data/vendored/puppet/lib/puppet/pops/lookup/environment_data_provider.rb +35 -0
- data/vendored/puppet/lib/puppet/pops/lookup/explainer.rb +595 -0
- data/vendored/puppet/lib/puppet/pops/lookup/function_provider.rb +110 -0
- data/vendored/puppet/lib/puppet/pops/lookup/global_data_provider.rb +75 -0
- data/vendored/puppet/lib/puppet/pops/lookup/hiera_config.rb +761 -0
- data/vendored/puppet/lib/puppet/pops/lookup/interpolation.rb +154 -0
- data/vendored/puppet/lib/puppet/pops/lookup/invocation.rb +261 -0
- data/vendored/puppet/lib/puppet/pops/lookup/location_resolver.rb +99 -0
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +471 -0
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_key.rb +99 -0
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_key_function_provider.rb +92 -0
- data/vendored/puppet/lib/puppet/pops/lookup/module_data_provider.rb +89 -0
- data/vendored/puppet/lib/puppet/pops/lookup/sub_lookup.rb +92 -0
- data/vendored/puppet/lib/puppet/pops/merge_strategy.rb +437 -0
- data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +58 -0
- data/vendored/puppet/lib/puppet/pops/model/ast.rb +4870 -0
- data/vendored/puppet/lib/puppet/pops/model/ast_transformer.rb +131 -0
- data/vendored/puppet/lib/puppet/pops/model/factory.rb +1150 -0
- data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +132 -0
- data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +467 -0
- data/vendored/puppet/lib/puppet/pops/model/pn_transformer.rb +400 -0
- data/vendored/puppet/lib/puppet/pops/model/tree_dumper.rb +59 -0
- data/vendored/puppet/lib/puppet/pops/parser/code_merger.rb +29 -0
- data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +3315 -0
- data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +51 -0
- data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +260 -0
- data/vendored/puppet/lib/puppet/pops/parser/evaluating_parser.rb +165 -0
- data/vendored/puppet/lib/puppet/pops/parser/heredoc_support.rb +143 -0
- data/vendored/puppet/lib/puppet/pops/parser/interpolation_support.rb +244 -0
- data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +772 -0
- data/vendored/puppet/lib/puppet/pops/parser/lexer_support.rb +221 -0
- data/vendored/puppet/lib/puppet/pops/parser/locatable.rb +23 -0
- data/vendored/puppet/lib/puppet/pops/parser/locator.rb +336 -0
- data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +247 -0
- data/vendored/puppet/lib/puppet/pops/parser/pn_parser.rb +316 -0
- data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +117 -0
- data/vendored/puppet/lib/puppet/pops/patterns.rb +60 -0
- data/vendored/puppet/lib/puppet/pops/pcore.rb +147 -0
- data/vendored/puppet/lib/puppet/pops/pn.rb +236 -0
- data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +43 -0
- data/vendored/puppet/lib/puppet/pops/resource/param.rb +55 -0
- data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +314 -0
- data/vendored/puppet/lib/puppet/pops/semantic_error.rb +29 -0
- data/vendored/puppet/lib/puppet/pops/serialization.rb +41 -0
- data/vendored/puppet/lib/puppet/pops/serialization/abstract_reader.rb +180 -0
- data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +222 -0
- data/vendored/puppet/lib/puppet/pops/serialization/deserializer.rb +80 -0
- data/vendored/puppet/lib/puppet/pops/serialization/extension.rb +158 -0
- data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +223 -0
- data/vendored/puppet/lib/puppet/pops/serialization/instance_reader.rb +19 -0
- data/vendored/puppet/lib/puppet/pops/serialization/instance_writer.rb +14 -0
- data/vendored/puppet/lib/puppet/pops/serialization/json.rb +297 -0
- data/vendored/puppet/lib/puppet/pops/serialization/json_path.rb +127 -0
- data/vendored/puppet/lib/puppet/pops/serialization/object.rb +70 -0
- data/vendored/puppet/lib/puppet/pops/serialization/serializer.rb +140 -0
- data/vendored/puppet/lib/puppet/pops/serialization/time_factory.rb +67 -0
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +305 -0
- data/vendored/puppet/lib/puppet/pops/time/timespan.rb +718 -0
- data/vendored/puppet/lib/puppet/pops/time/timestamp.rb +160 -0
- data/vendored/puppet/lib/puppet/pops/types/annotatable.rb +36 -0
- data/vendored/puppet/lib/puppet/pops/types/annotation.rb +71 -0
- data/vendored/puppet/lib/puppet/pops/types/class_loader.rb +132 -0
- data/vendored/puppet/lib/puppet/pops/types/enumeration.rb +16 -0
- data/vendored/puppet/lib/puppet/pops/types/implementation_registry.rb +134 -0
- data/vendored/puppet/lib/puppet/pops/types/iterable.rb +339 -0
- data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +233 -0
- data/vendored/puppet/lib/puppet/pops/types/p_init_type.rb +238 -0
- data/vendored/puppet/lib/puppet/pops/types/p_meta_type.rb +94 -0
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +1114 -0
- data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
- data/vendored/puppet/lib/puppet/pops/types/p_runtime_type.rb +115 -0
- data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb +190 -0
- data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_type.rb +149 -0
- data/vendored/puppet/lib/puppet/pops/types/p_sensitive_type.rb +73 -0
- data/vendored/puppet/lib/puppet/pops/types/p_timespan_type.rb +192 -0
- data/vendored/puppet/lib/puppet/pops/types/p_timestamp_type.rb +73 -0
- data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +383 -0
- data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +190 -0
- data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +40 -0
- data/vendored/puppet/lib/puppet/pops/types/recursion_guard.rb +136 -0
- data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +472 -0
- data/vendored/puppet/lib/puppet/pops/types/ruby_method.rb +31 -0
- data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +1123 -0
- data/vendored/puppet/lib/puppet/pops/types/tree_iterators.rb +254 -0
- data/vendored/puppet/lib/puppet/pops/types/type_acceptor.rb +25 -0
- data/vendored/puppet/lib/puppet/pops/types/type_asserter.rb +47 -0
- data/vendored/puppet/lib/puppet/pops/types/type_assertion_error.rb +27 -0
- data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +809 -0
- data/vendored/puppet/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +614 -0
- data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +802 -0
- data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +1075 -0
- data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +685 -0
- data/vendored/puppet/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/vendored/puppet/lib/puppet/pops/types/type_with_members.rb +43 -0
- data/vendored/puppet/lib/puppet/pops/types/types.rb +3650 -0
- data/vendored/puppet/lib/puppet/pops/utils.rb +119 -0
- data/vendored/puppet/lib/puppet/pops/validation.rb +466 -0
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +998 -0
- data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +60 -0
- data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +43 -0
- data/vendored/puppet/lib/puppet/pops/visitable.rb +6 -0
- data/vendored/puppet/lib/puppet/pops/visitor.rb +116 -0
- data/vendored/puppet/lib/puppet/property.rb +608 -0
- data/vendored/puppet/lib/puppet/property/boolean.rb +7 -0
- data/vendored/puppet/lib/puppet/property/ensure.rb +105 -0
- data/vendored/puppet/lib/puppet/property/keyvalue.rb +95 -0
- data/vendored/puppet/lib/puppet/property/list.rb +69 -0
- data/vendored/puppet/lib/puppet/property/ordered_list.rb +29 -0
- data/vendored/puppet/lib/puppet/provider.rb +613 -0
- data/vendored/puppet/lib/puppet/provider/aixobject.rb +392 -0
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +566 -0
- data/vendored/puppet/lib/puppet/provider/cisco.rb +9 -0
- data/vendored/puppet/lib/puppet/provider/command.rb +25 -0
- data/vendored/puppet/lib/puppet/provider/computer/computer.rb +20 -0
- data/vendored/puppet/lib/puppet/provider/confine.rb +6 -0
- data/vendored/puppet/lib/puppet/provider/cron/crontab.rb +297 -0
- data/vendored/puppet/lib/puppet/provider/exec.rb +96 -0
- data/vendored/puppet/lib/puppet/provider/exec/posix.rb +48 -0
- data/vendored/puppet/lib/puppet/provider/exec/shell.rb +25 -0
- data/vendored/puppet/lib/puppet/provider/exec/windows.rb +55 -0
- data/vendored/puppet/lib/puppet/provider/file/posix.rb +136 -0
- data/vendored/puppet/lib/puppet/provider/file/windows.rb +104 -0
- data/vendored/puppet/lib/puppet/provider/group/aix.rb +143 -0
- data/vendored/puppet/lib/puppet/provider/group/directoryservice.rb +22 -0
- data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +111 -0
- data/vendored/puppet/lib/puppet/provider/group/ldap.rb +45 -0
- data/vendored/puppet/lib/puppet/provider/group/pw.rb +49 -0
- data/vendored/puppet/lib/puppet/provider/group/windows_adsi.rb +106 -0
- data/vendored/puppet/lib/puppet/provider/host/parsed.rb +46 -0
- data/vendored/puppet/lib/puppet/provider/interface/cisco.rb +27 -0
- data/vendored/puppet/lib/puppet/provider/ldap.rb +137 -0
- data/vendored/puppet/lib/puppet/provider/macauthorization/macauthorization.rb +298 -0
- data/vendored/puppet/lib/puppet/provider/mailalias/aliases.rb +50 -0
- data/vendored/puppet/lib/puppet/provider/maillist/mailman.rb +108 -0
- data/vendored/puppet/lib/puppet/provider/mcx/mcxcontent.rb +173 -0
- data/vendored/puppet/lib/puppet/provider/mount.rb +76 -0
- data/vendored/puppet/lib/puppet/provider/mount/parsed.rb +282 -0
- data/vendored/puppet/lib/puppet/provider/naginator.rb +63 -0
- data/vendored/puppet/lib/puppet/provider/nameservice.rb +325 -0
- data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +508 -0
- data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +22 -0
- data/vendored/puppet/lib/puppet/provider/nameservice/pw.rb +21 -0
- data/vendored/puppet/lib/puppet/provider/network_device.rb +72 -0
- data/vendored/puppet/lib/puppet/provider/package.rb +56 -0
- data/vendored/puppet/lib/puppet/provider/package/aix.rb +152 -0
- data/vendored/puppet/lib/puppet/provider/package/appdmg.rb +109 -0
- data/vendored/puppet/lib/puppet/provider/package/apple.rb +46 -0
- data/vendored/puppet/lib/puppet/provider/package/apt.rb +116 -0
- data/vendored/puppet/lib/puppet/provider/package/aptitude.rb +29 -0
- data/vendored/puppet/lib/puppet/provider/package/aptrpm.rb +83 -0
- data/vendored/puppet/lib/puppet/provider/package/blastwave.rb +111 -0
- data/vendored/puppet/lib/puppet/provider/package/dnf.rb +46 -0
- data/vendored/puppet/lib/puppet/provider/package/dpkg.rb +165 -0
- data/vendored/puppet/lib/puppet/provider/package/fink.rb +79 -0
- data/vendored/puppet/lib/puppet/provider/package/freebsd.rb +47 -0
- data/vendored/puppet/lib/puppet/provider/package/gem.rb +175 -0
- data/vendored/puppet/lib/puppet/provider/package/hpux.rb +44 -0
- data/vendored/puppet/lib/puppet/provider/package/macports.rb +107 -0
- data/vendored/puppet/lib/puppet/provider/package/nim.rb +282 -0
- data/vendored/puppet/lib/puppet/provider/package/openbsd.rb +242 -0
- data/vendored/puppet/lib/puppet/provider/package/opkg.rb +81 -0
- data/vendored/puppet/lib/puppet/provider/package/pacman.rb +267 -0
- data/vendored/puppet/lib/puppet/provider/package/pip.rb +188 -0
- data/vendored/puppet/lib/puppet/provider/package/pip3.rb +20 -0
- data/vendored/puppet/lib/puppet/provider/package/pkg.rb +255 -0
- data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +151 -0
- data/vendored/puppet/lib/puppet/provider/package/pkgin.rb +87 -0
- data/vendored/puppet/lib/puppet/provider/package/pkgng.rb +143 -0
- data/vendored/puppet/lib/puppet/provider/package/pkgutil.rb +186 -0
- data/vendored/puppet/lib/puppet/provider/package/portage.rb +300 -0
- data/vendored/puppet/lib/puppet/provider/package/ports.rb +91 -0
- data/vendored/puppet/lib/puppet/provider/package/portupgrade.rb +239 -0
- data/vendored/puppet/lib/puppet/provider/package/puppet_gem.rb +17 -0
- data/vendored/puppet/lib/puppet/provider/package/rpm.rb +405 -0
- data/vendored/puppet/lib/puppet/provider/package/rug.rb +51 -0
- data/vendored/puppet/lib/puppet/provider/package/sun.rb +133 -0
- data/vendored/puppet/lib/puppet/provider/package/sunfreeware.rb +9 -0
- data/vendored/puppet/lib/puppet/provider/package/tdnf.rb +28 -0
- data/vendored/puppet/lib/puppet/provider/package/up2date.rb +40 -0
- data/vendored/puppet/lib/puppet/provider/package/urpmi.rb +55 -0
- data/vendored/puppet/lib/puppet/provider/package/windows.rb +113 -0
- data/vendored/puppet/lib/puppet/provider/package/windows/exe_package.rb +71 -0
- data/vendored/puppet/lib/puppet/provider/package/windows/msi_package.rb +62 -0
- data/vendored/puppet/lib/puppet/provider/package/windows/package.rb +100 -0
- data/vendored/puppet/lib/puppet/provider/package/yum.rb +293 -0
- data/vendored/puppet/lib/puppet/provider/package/zypper.rb +145 -0
- data/vendored/puppet/lib/puppet/provider/parsedfile.rb +459 -0
- data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +590 -0
- data/vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
- data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +140 -0
- data/vendored/puppet/lib/puppet/provider/service/base.rb +134 -0
- data/vendored/puppet/lib/puppet/provider/service/bsd.rb +51 -0
- data/vendored/puppet/lib/puppet/provider/service/daemontools.rb +194 -0
- data/vendored/puppet/lib/puppet/provider/service/debian.rb +74 -0
- data/vendored/puppet/lib/puppet/provider/service/freebsd.rb +143 -0
- data/vendored/puppet/lib/puppet/provider/service/gentoo.rb +45 -0
- data/vendored/puppet/lib/puppet/provider/service/init.rb +194 -0
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +345 -0
- data/vendored/puppet/lib/puppet/provider/service/openbsd.rb +100 -0
- data/vendored/puppet/lib/puppet/provider/service/openrc.rb +71 -0
- data/vendored/puppet/lib/puppet/provider/service/openwrt.rb +36 -0
- data/vendored/puppet/lib/puppet/provider/service/rcng.rb +51 -0
- data/vendored/puppet/lib/puppet/provider/service/redhat.rb +72 -0
- data/vendored/puppet/lib/puppet/provider/service/runit.rb +112 -0
- data/vendored/puppet/lib/puppet/provider/service/service.rb +42 -0
- data/vendored/puppet/lib/puppet/provider/service/smf.rb +170 -0
- data/vendored/puppet/lib/puppet/provider/service/src.rb +147 -0
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +187 -0
- data/vendored/puppet/lib/puppet/provider/service/upstart.rb +359 -0
- data/vendored/puppet/lib/puppet/provider/service/windows.rb +106 -0
- data/vendored/puppet/lib/puppet/provider/ssh_authorized_key/parsed.rb +105 -0
- data/vendored/puppet/lib/puppet/provider/sshkey/parsed.rb +50 -0
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +383 -0
- data/vendored/puppet/lib/puppet/provider/user/directoryservice.rb +632 -0
- data/vendored/puppet/lib/puppet/provider/user/hpux.rb +95 -0
- data/vendored/puppet/lib/puppet/provider/user/ldap.rb +128 -0
- data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +76 -0
- data/vendored/puppet/lib/puppet/provider/user/pw.rb +98 -0
- data/vendored/puppet/lib/puppet/provider/user/user_role_add.rb +233 -0
- data/vendored/puppet/lib/puppet/provider/user/useradd.rb +265 -0
- data/vendored/puppet/lib/puppet/provider/user/windows_adsi.rb +148 -0
- data/vendored/puppet/lib/puppet/provider/vlan/cisco.rb +28 -0
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +303 -0
- data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +108 -0
- data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +364 -0
- data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +125 -0
- data/vendored/puppet/lib/puppet/reference/configuration.rb +86 -0
- data/vendored/puppet/lib/puppet/reference/function.rb +17 -0
- data/vendored/puppet/lib/puppet/reference/indirection.rb +71 -0
- data/vendored/puppet/lib/puppet/reference/metaparameter.rb +35 -0
- data/vendored/puppet/lib/puppet/reference/providers.rb +118 -0
- data/vendored/puppet/lib/puppet/reference/report.rb +20 -0
- data/vendored/puppet/lib/puppet/reference/type.rb +113 -0
- data/vendored/puppet/lib/puppet/relationship.rb +89 -0
- data/vendored/puppet/lib/puppet/reports.rb +93 -0
- data/vendored/puppet/lib/puppet/reports/http.rb +37 -0
- data/vendored/puppet/lib/puppet/reports/log.rb +14 -0
- data/vendored/puppet/lib/puppet/reports/store.rb +68 -0
- data/vendored/puppet/lib/puppet/resource.rb +670 -0
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +150 -0
- data/vendored/puppet/lib/puppet/resource/catalog.rb +682 -0
- data/vendored/puppet/lib/puppet/resource/status.rb +227 -0
- data/vendored/puppet/lib/puppet/resource/type.rb +524 -0
- data/vendored/puppet/lib/puppet/resource/type_collection.rb +263 -0
- data/vendored/puppet/lib/puppet/scheduler.rb +16 -0
- data/vendored/puppet/lib/puppet/scheduler/job.rb +53 -0
- data/vendored/puppet/lib/puppet/scheduler/scheduler.rb +44 -0
- data/vendored/puppet/lib/puppet/scheduler/splay_job.rb +32 -0
- data/vendored/puppet/lib/puppet/scheduler/timer.rb +13 -0
- data/vendored/puppet/lib/puppet/settings.rb +1475 -0
- data/vendored/puppet/lib/puppet/settings/array_setting.rb +17 -0
- data/vendored/puppet/lib/puppet/settings/autosign_setting.rb +22 -0
- data/vendored/puppet/lib/puppet/settings/base_setting.rb +197 -0
- data/vendored/puppet/lib/puppet/settings/boolean_setting.rb +32 -0
- data/vendored/puppet/lib/puppet/settings/certificate_revocation_setting.rb +21 -0
- data/vendored/puppet/lib/puppet/settings/config_file.rb +153 -0
- data/vendored/puppet/lib/puppet/settings/directory_setting.rb +18 -0
- data/vendored/puppet/lib/puppet/settings/duration_setting.rb +32 -0
- data/vendored/puppet/lib/puppet/settings/enum_setting.rb +16 -0
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +213 -0
- data/vendored/puppet/lib/puppet/settings/errors.rb +11 -0
- data/vendored/puppet/lib/puppet/settings/file_or_directory_setting.rb +40 -0
- data/vendored/puppet/lib/puppet/settings/file_setting.rb +245 -0
- data/vendored/puppet/lib/puppet/settings/ini_file.rb +225 -0
- data/vendored/puppet/lib/puppet/settings/path_setting.rb +8 -0
- data/vendored/puppet/lib/puppet/settings/priority_setting.rb +42 -0
- data/vendored/puppet/lib/puppet/settings/server_list_setting.rb +20 -0
- data/vendored/puppet/lib/puppet/settings/string_setting.rb +9 -0
- data/vendored/puppet/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/vendored/puppet/lib/puppet/settings/terminus_setting.rb +14 -0
- data/vendored/puppet/lib/puppet/settings/ttl_setting.rb +51 -0
- data/vendored/puppet/lib/puppet/settings/value_translator.rb +15 -0
- data/vendored/puppet/lib/puppet/ssl.rb +13 -0
- data/vendored/puppet/lib/puppet/ssl/base.rb +158 -0
- data/vendored/puppet/lib/puppet/ssl/certificate.rb +95 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +553 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_authority/autosign_command.rb +45 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_authority/interface.rb +324 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +219 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +325 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_request_attributes.rb +37 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_revocation_list.rb +111 -0
- data/vendored/puppet/lib/puppet/ssl/certificate_signer.rb +33 -0
- data/vendored/puppet/lib/puppet/ssl/configuration.rb +61 -0
- data/vendored/puppet/lib/puppet/ssl/digest.rb +20 -0
- data/vendored/puppet/lib/puppet/ssl/host.rb +400 -0
- data/vendored/puppet/lib/puppet/ssl/inventory.rb +55 -0
- data/vendored/puppet/lib/puppet/ssl/key.rb +63 -0
- data/vendored/puppet/lib/puppet/ssl/oids.rb +193 -0
- data/vendored/puppet/lib/puppet/ssl/validator.rb +60 -0
- data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +173 -0
- data/vendored/puppet/lib/puppet/ssl/validator/no_validator.rb +20 -0
- data/vendored/puppet/lib/puppet/status.rb +40 -0
- data/vendored/puppet/lib/puppet/syntax_checkers.rb +3 -0
- data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +40 -0
- data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +35 -0
- data/vendored/puppet/lib/puppet/test/test_helper.rb +252 -0
- data/vendored/puppet/lib/puppet/transaction.rb +444 -0
- data/vendored/puppet/lib/puppet/transaction/additional_resource_generator.rb +220 -0
- data/vendored/puppet/lib/puppet/transaction/event.rb +144 -0
- data/vendored/puppet/lib/puppet/transaction/event_manager.rb +167 -0
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +99 -0
- data/vendored/puppet/lib/puppet/transaction/report.rb +468 -0
- data/vendored/puppet/lib/puppet/transaction/resource_harness.rb +318 -0
- data/vendored/puppet/lib/puppet/type.rb +2665 -0
- data/vendored/puppet/lib/puppet/type/augeas.rb +211 -0
- data/vendored/puppet/lib/puppet/type/component.rb +88 -0
- data/vendored/puppet/lib/puppet/type/computer.rb +66 -0
- data/vendored/puppet/lib/puppet/type/cron.rb +480 -0
- data/vendored/puppet/lib/puppet/type/exec.rb +623 -0
- data/vendored/puppet/lib/puppet/type/file.rb +1039 -0
- data/vendored/puppet/lib/puppet/type/file/checksum.rb +50 -0
- data/vendored/puppet/lib/puppet/type/file/checksum_value.rb +54 -0
- data/vendored/puppet/lib/puppet/type/file/content.rb +160 -0
- data/vendored/puppet/lib/puppet/type/file/ctime.rb +20 -0
- data/vendored/puppet/lib/puppet/type/file/data_sync.rb +93 -0
- data/vendored/puppet/lib/puppet/type/file/ensure.rb +192 -0
- data/vendored/puppet/lib/puppet/type/file/group.rb +41 -0
- data/vendored/puppet/lib/puppet/type/file/mode.rb +177 -0
- data/vendored/puppet/lib/puppet/type/file/mtime.rb +18 -0
- data/vendored/puppet/lib/puppet/type/file/owner.rb +44 -0
- data/vendored/puppet/lib/puppet/type/file/selcontext.rb +141 -0
- data/vendored/puppet/lib/puppet/type/file/source.rb +356 -0
- data/vendored/puppet/lib/puppet/type/file/target.rb +87 -0
- data/vendored/puppet/lib/puppet/type/file/type.rb +19 -0
- data/vendored/puppet/lib/puppet/type/filebucket.rb +117 -0
- data/vendored/puppet/lib/puppet/type/group.rb +209 -0
- data/vendored/puppet/lib/puppet/type/host.rb +95 -0
- data/vendored/puppet/lib/puppet/type/interface.rb +121 -0
- data/vendored/puppet/lib/puppet/type/k5login.rb +165 -0
- data/vendored/puppet/lib/puppet/type/macauthorization.rb +167 -0
- data/vendored/puppet/lib/puppet/type/mailalias.rb +46 -0
- data/vendored/puppet/lib/puppet/type/maillist.rb +62 -0
- data/vendored/puppet/lib/puppet/type/mcx.rb +98 -0
- data/vendored/puppet/lib/puppet/type/mount.rb +314 -0
- data/vendored/puppet/lib/puppet/type/nagios_command.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_contact.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_contactgroup.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_host.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_hostdependency.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_hostescalation.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_hostextinfo.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_hostgroup.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_service.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_servicedependency.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_serviceescalation.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_serviceextinfo.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_servicegroup.rb +3 -0
- data/vendored/puppet/lib/puppet/type/nagios_timeperiod.rb +3 -0
- data/vendored/puppet/lib/puppet/type/notify.rb +46 -0
- data/vendored/puppet/lib/puppet/type/package.rb +571 -0
- data/vendored/puppet/lib/puppet/type/resources.rb +180 -0
- data/vendored/puppet/lib/puppet/type/router.rb +17 -0
- data/vendored/puppet/lib/puppet/type/schedule.rb +481 -0
- data/vendored/puppet/lib/puppet/type/scheduled_task.rb +183 -0
- data/vendored/puppet/lib/puppet/type/selboolean.rb +26 -0
- data/vendored/puppet/lib/puppet/type/selmodule.rb +59 -0
- data/vendored/puppet/lib/puppet/type/service.rb +258 -0
- data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +143 -0
- data/vendored/puppet/lib/puppet/type/sshkey.rb +83 -0
- data/vendored/puppet/lib/puppet/type/stage.rb +27 -0
- data/vendored/puppet/lib/puppet/type/tidy.rb +345 -0
- data/vendored/puppet/lib/puppet/type/user.rb +794 -0
- data/vendored/puppet/lib/puppet/type/vlan.rb +26 -0
- data/vendored/puppet/lib/puppet/type/whit.rb +34 -0
- data/vendored/puppet/lib/puppet/type/yumrepo.rb +439 -0
- data/vendored/puppet/lib/puppet/type/zfs.rb +154 -0
- data/vendored/puppet/lib/puppet/type/zone.rb +382 -0
- data/vendored/puppet/lib/puppet/type/zpool.rb +91 -0
- data/vendored/puppet/lib/puppet/util.rb +700 -0
- data/vendored/puppet/lib/puppet/util/at_fork.rb +35 -0
- data/vendored/puppet/lib/puppet/util/at_fork/noop.rb +18 -0
- data/vendored/puppet/lib/puppet/util/at_fork/solaris.rb +160 -0
- data/vendored/puppet/lib/puppet/util/autoload.rb +226 -0
- data/vendored/puppet/lib/puppet/util/backups.rb +86 -0
- data/vendored/puppet/lib/puppet/util/character_encoding.rb +98 -0
- data/vendored/puppet/lib/puppet/util/checksums.rb +363 -0
- data/vendored/puppet/lib/puppet/util/classgen.rb +228 -0
- data/vendored/puppet/lib/puppet/util/colors.rb +100 -0
- data/vendored/puppet/lib/puppet/util/command_line.rb +190 -0
- data/vendored/puppet/lib/puppet/util/command_line/puppet_option_parser.rb +87 -0
- data/vendored/puppet/lib/puppet/util/command_line/trollop.rb +825 -0
- data/vendored/puppet/lib/puppet/util/constant_inflector.rb +24 -0
- data/vendored/puppet/lib/puppet/util/diff.rb +79 -0
- data/vendored/puppet/lib/puppet/util/docs.rb +128 -0
- data/vendored/puppet/lib/puppet/util/errors.rb +159 -0
- data/vendored/puppet/lib/puppet/util/execution.rb +412 -0
- data/vendored/puppet/lib/puppet/util/execution_stub.rb +26 -0
- data/vendored/puppet/lib/puppet/util/feature.rb +95 -0
- data/vendored/puppet/lib/puppet/util/file_watcher.rb +28 -0
- data/vendored/puppet/lib/puppet/util/fileparsing.rb +375 -0
- data/vendored/puppet/lib/puppet/util/filetype.rb +309 -0
- data/vendored/puppet/lib/puppet/util/http_proxy.rb +207 -0
- data/vendored/puppet/lib/puppet/util/inifile.rb +340 -0
- data/vendored/puppet/lib/puppet/util/instance_loader.rb +79 -0
- data/vendored/puppet/lib/puppet/util/json_lockfile.rb +44 -0
- data/vendored/puppet/lib/puppet/util/ldap.rb +2 -0
- data/vendored/puppet/lib/puppet/util/ldap/connection.rb +71 -0
- data/vendored/puppet/lib/puppet/util/ldap/generator.rb +42 -0
- data/vendored/puppet/lib/puppet/util/ldap/manager.rb +281 -0
- data/vendored/puppet/lib/puppet/util/libuser.rb +12 -0
- data/vendored/puppet/lib/puppet/util/limits.rb +12 -0
- data/vendored/puppet/lib/puppet/util/lockfile.rb +66 -0
- data/vendored/puppet/lib/puppet/util/log.rb +415 -0
- data/vendored/puppet/lib/puppet/util/log/destination.rb +49 -0
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +258 -0
- data/vendored/puppet/lib/puppet/util/logging.rb +311 -0
- data/vendored/puppet/lib/puppet/util/metaid.rb +21 -0
- data/vendored/puppet/lib/puppet/util/methodhelper.rb +32 -0
- data/vendored/puppet/lib/puppet/util/metric.rb +64 -0
- data/vendored/puppet/lib/puppet/util/monkey_patches.rb +108 -0
- data/vendored/puppet/lib/puppet/util/multi_match.rb +51 -0
- data/vendored/puppet/lib/puppet/util/nagios_maker.rb +85 -0
- data/vendored/puppet/lib/puppet/util/network_device.rb +17 -0
- data/vendored/puppet/lib/puppet/util/network_device/base.rb +23 -0
- data/vendored/puppet/lib/puppet/util/network_device/cisco.rb +4 -0
- data/vendored/puppet/lib/puppet/util/network_device/cisco/device.rb +285 -0
- data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +72 -0
- data/vendored/puppet/lib/puppet/util/network_device/cisco/interface.rb +94 -0
- data/vendored/puppet/lib/puppet/util/network_device/config.rb +105 -0
- data/vendored/puppet/lib/puppet/util/network_device/ipcalc.rb +68 -0
- data/vendored/puppet/lib/puppet/util/network_device/transport.rb +5 -0
- data/vendored/puppet/lib/puppet/util/network_device/transport/base.rb +26 -0
- data/vendored/puppet/lib/puppet/util/network_device/transport/ssh.rb +126 -0
- data/vendored/puppet/lib/puppet/util/network_device/transport/telnet.rb +47 -0
- data/vendored/puppet/lib/puppet/util/package.rb +31 -0
- data/vendored/puppet/lib/puppet/util/pidlock.rb +62 -0
- data/vendored/puppet/lib/puppet/util/platform.rb +35 -0
- data/vendored/puppet/lib/puppet/util/plist.rb +155 -0
- data/vendored/puppet/lib/puppet/util/posix.rb +137 -0
- data/vendored/puppet/lib/puppet/util/profiler.rb +53 -0
- data/vendored/puppet/lib/puppet/util/profiler/aggregate.rb +85 -0
- data/vendored/puppet/lib/puppet/util/profiler/around_profiler.rb +67 -0
- data/vendored/puppet/lib/puppet/util/profiler/logging.rb +48 -0
- data/vendored/puppet/lib/puppet/util/profiler/object_counts.rb +17 -0
- data/vendored/puppet/lib/puppet/util/profiler/wall_clock.rb +35 -0
- data/vendored/puppet/lib/puppet/util/provider_features.rb +184 -0
- data/vendored/puppet/lib/puppet/util/psych_support.rb +30 -0
- data/vendored/puppet/lib/puppet/util/rdoc.rb +60 -0
- data/vendored/puppet/lib/puppet/util/rdoc/code_objects.rb +294 -0
- data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +910 -0
- data/vendored/puppet/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +1085 -0
- data/vendored/puppet/lib/puppet/util/rdoc/parser.rb +12 -0
- data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +259 -0
- data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +14 -0
- data/vendored/puppet/lib/puppet/util/reference.rb +118 -0
- data/vendored/puppet/lib/puppet/util/resource_template.rb +61 -0
- data/vendored/puppet/lib/puppet/util/retry_action.rb +46 -0
- data/vendored/puppet/lib/puppet/util/rubygems.rb +75 -0
- data/vendored/puppet/lib/puppet/util/run_mode.rb +110 -0
- data/vendored/puppet/lib/puppet/util/selinux.rb +264 -0
- data/vendored/puppet/lib/puppet/util/skip_tags.rb +9 -0
- data/vendored/puppet/lib/puppet/util/splayer.rb +18 -0
- data/vendored/puppet/lib/puppet/util/ssl.rb +53 -0
- data/vendored/puppet/lib/puppet/util/storage.rb +89 -0
- data/vendored/puppet/lib/puppet/util/suidmanager.rb +165 -0
- data/vendored/puppet/lib/puppet/util/symbolic_file_mode.rb +144 -0
- data/vendored/puppet/lib/puppet/util/tag_set.rb +27 -0
- data/vendored/puppet/lib/puppet/util/tagging.rb +118 -0
- data/vendored/puppet/lib/puppet/util/terminal.rb +16 -0
- data/vendored/puppet/lib/puppet/util/user_attr.rb +21 -0
- data/vendored/puppet/lib/puppet/util/warnings.rb +31 -0
- data/vendored/puppet/lib/puppet/util/watched_file.rb +37 -0
- data/vendored/puppet/lib/puppet/util/watcher.rb +17 -0
- data/vendored/puppet/lib/puppet/util/watcher/change_watcher.rb +33 -0
- data/vendored/puppet/lib/puppet/util/watcher/periodic_watcher.rb +37 -0
- data/vendored/puppet/lib/puppet/util/watcher/timer.rb +19 -0
- data/vendored/puppet/lib/puppet/util/windows.rb +35 -0
- data/vendored/puppet/lib/puppet/util/windows/access_control_entry.rb +84 -0
- data/vendored/puppet/lib/puppet/util/windows/access_control_list.rb +113 -0
- data/vendored/puppet/lib/puppet/util/windows/adsi.rb +545 -0
- data/vendored/puppet/lib/puppet/util/windows/api_types.rb +282 -0
- data/vendored/puppet/lib/puppet/util/windows/com.rb +225 -0
- data/vendored/puppet/lib/puppet/util/windows/error.rb +83 -0
- data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +197 -0
- data/vendored/puppet/lib/puppet/util/windows/file.rb +571 -0
- data/vendored/puppet/lib/puppet/util/windows/principal.rb +192 -0
- data/vendored/puppet/lib/puppet/util/windows/process.rb +497 -0
- data/vendored/puppet/lib/puppet/util/windows/registry.rb +374 -0
- data/vendored/puppet/lib/puppet/util/windows/root_certs.rb +108 -0
- data/vendored/puppet/lib/puppet/util/windows/security.rb +857 -0
- data/vendored/puppet/lib/puppet/util/windows/security_descriptor.rb +62 -0
- data/vendored/puppet/lib/puppet/util/windows/sid.rb +282 -0
- data/vendored/puppet/lib/puppet/util/windows/string.rb +16 -0
- data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +1267 -0
- data/vendored/puppet/lib/puppet/util/windows/user.rb +309 -0
- data/vendored/puppet/lib/puppet/util/yaml.rb +36 -0
- data/vendored/puppet/lib/puppet/vendor.rb +57 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge.rb +2 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge/core.rb +210 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge/deep_merge_hash.rb +28 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/lib/deep_merge/rails_compat.rb +27 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +608 -0
- data/vendored/puppet/lib/puppet/vendor/load_deep_merge.rb +1 -0
- data/vendored/puppet/lib/puppet/vendor/load_pathspec.rb +1 -0
- data/vendored/puppet/lib/puppet/vendor/load_semantic.rb +1 -0
- data/vendored/puppet/lib/puppet/vendor/load_semantic_puppet.rb +1 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec.rb +122 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +275 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec/regexspec.rb +17 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/lib/pathspec/spec.rb +14 -0
- data/vendored/puppet/lib/puppet/vendor/require_vendored.rb +6 -0
- data/vendored/puppet/lib/puppet/vendor/semantic/lib/semantic.rb +5 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +11 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +181 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +60 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +117 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +58 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +25 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +31 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +3 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +203 -0
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +758 -0
- data/vendored/puppet/lib/puppet/version.rb +93 -0
- data/vendored/puppet/lib/puppet_pal.rb +879 -0
- data/vendored/puppet/lib/puppet_x.rb +14 -0
- metadata +1237 -2
@@ -0,0 +1,318 @@
|
|
1
|
+
require 'puppet/resource/status'
|
2
|
+
|
3
|
+
class Puppet::Transaction::ResourceHarness
|
4
|
+
NO_ACTION = Object.new
|
5
|
+
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators :@transaction, :relationship_graph
|
8
|
+
|
9
|
+
attr_reader :transaction
|
10
|
+
|
11
|
+
def initialize(transaction)
|
12
|
+
@transaction = transaction
|
13
|
+
@persistence = transaction.persistence
|
14
|
+
end
|
15
|
+
|
16
|
+
def evaluate(resource)
|
17
|
+
status = Puppet::Resource::Status.new(resource)
|
18
|
+
|
19
|
+
begin
|
20
|
+
context = ResourceApplicationContext.from_resource(resource, status)
|
21
|
+
perform_changes(resource, context)
|
22
|
+
|
23
|
+
if status.changed? && ! resource.noop?
|
24
|
+
cache(resource, :synced, Time.now)
|
25
|
+
resource.flush if resource.respond_to?(:flush)
|
26
|
+
end
|
27
|
+
rescue => detail
|
28
|
+
status.failed_because(detail)
|
29
|
+
ensure
|
30
|
+
status.evaluation_time = Time.now - status.time
|
31
|
+
end
|
32
|
+
|
33
|
+
status
|
34
|
+
end
|
35
|
+
|
36
|
+
def scheduled?(resource)
|
37
|
+
return true if Puppet[:ignoreschedules]
|
38
|
+
return true unless schedule = schedule(resource)
|
39
|
+
|
40
|
+
# We use 'checked' here instead of 'synced' because otherwise we'll
|
41
|
+
# end up checking most resources most times, because they will generally
|
42
|
+
# have been synced a long time ago (e.g., a file only gets updated
|
43
|
+
# once a month on the server and its schedule is daily; the last sync time
|
44
|
+
# will have been a month ago, so we'd end up checking every run).
|
45
|
+
schedule.match?(cached(resource, :checked).to_i)
|
46
|
+
end
|
47
|
+
|
48
|
+
def schedule(resource)
|
49
|
+
unless resource.catalog
|
50
|
+
resource.warning _("Cannot schedule without a schedule-containing catalog")
|
51
|
+
return nil
|
52
|
+
end
|
53
|
+
|
54
|
+
return nil unless name = resource[:schedule]
|
55
|
+
resource.catalog.resource(:schedule, name) || resource.fail(_("Could not find schedule %{name}") % { name: name })
|
56
|
+
end
|
57
|
+
|
58
|
+
# Used mostly for scheduling and auditing at this point.
|
59
|
+
def cached(resource, name)
|
60
|
+
Puppet::Util::Storage.cache(resource)[name]
|
61
|
+
end
|
62
|
+
|
63
|
+
# Used mostly for scheduling and auditing at this point.
|
64
|
+
def cache(resource, name, value)
|
65
|
+
Puppet::Util::Storage.cache(resource)[name] = value
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def perform_changes(resource, context)
|
71
|
+
cache(resource, :checked, Time.now)
|
72
|
+
|
73
|
+
# Record the current state in state.yml.
|
74
|
+
context.audited_params.each do |param|
|
75
|
+
cache(resource, param, context.current_values[param])
|
76
|
+
end
|
77
|
+
|
78
|
+
ensure_param = resource.parameter(:ensure)
|
79
|
+
if ensure_param && ensure_param.should
|
80
|
+
ensure_event = sync_if_needed(ensure_param, context)
|
81
|
+
else
|
82
|
+
ensure_event = NO_ACTION
|
83
|
+
end
|
84
|
+
|
85
|
+
if ensure_event == NO_ACTION
|
86
|
+
if context.resource_present?
|
87
|
+
resource.properties.each do |param|
|
88
|
+
sync_if_needed(param, context)
|
89
|
+
end
|
90
|
+
else
|
91
|
+
resource.debug("Nothing to manage: no ensure and the resource doesn't exist")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
capture_audit_events(resource, context)
|
96
|
+
persist_system_values(resource, context)
|
97
|
+
end
|
98
|
+
|
99
|
+
# We persist the last known values for the properties of a resource after resource
|
100
|
+
# application.
|
101
|
+
# @param [Puppet::Type] resource resource whose values we are to persist.
|
102
|
+
# @param [ResourceApplicationContent] context the application context to operate on.
|
103
|
+
def persist_system_values(resource, context)
|
104
|
+
param_to_event = {}
|
105
|
+
context.status.events.each do |ev|
|
106
|
+
param_to_event[ev.property] = ev
|
107
|
+
end
|
108
|
+
|
109
|
+
context.system_value_params.each do |pname, param|
|
110
|
+
@persistence.set_system_value(resource.ref, pname.to_s,
|
111
|
+
new_system_value(param,
|
112
|
+
param_to_event[pname.to_s],
|
113
|
+
@persistence.get_system_value(resource.ref, pname.to_s)))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def sync_if_needed(param, context)
|
118
|
+
historical_value = context.historical_values[param.name]
|
119
|
+
current_value = context.current_values[param.name]
|
120
|
+
do_audit = context.audited_params.include?(param.name)
|
121
|
+
|
122
|
+
begin
|
123
|
+
if param.should && !param.safe_insync?(current_value)
|
124
|
+
event = create_change_event(param, current_value, historical_value)
|
125
|
+
if do_audit
|
126
|
+
event = audit_event(event, param, context)
|
127
|
+
end
|
128
|
+
|
129
|
+
brief_audit_message = audit_message(param, do_audit, historical_value, current_value)
|
130
|
+
|
131
|
+
if param.noop
|
132
|
+
noop(event, param, current_value, brief_audit_message)
|
133
|
+
else
|
134
|
+
sync(event, param, current_value, brief_audit_message)
|
135
|
+
end
|
136
|
+
|
137
|
+
event
|
138
|
+
else
|
139
|
+
NO_ACTION
|
140
|
+
end
|
141
|
+
rescue => detail
|
142
|
+
# Execution will continue on StandardErrors, just store the event
|
143
|
+
Puppet.log_exception(detail)
|
144
|
+
|
145
|
+
event = create_change_event(param, current_value, historical_value)
|
146
|
+
event.status = "failure"
|
147
|
+
event.message = param.format(_("change from %s to %s failed: "),
|
148
|
+
param.is_to_s(current_value),
|
149
|
+
param.should_to_s(param.should)) + detail.to_s
|
150
|
+
event
|
151
|
+
rescue Exception => detail
|
152
|
+
# Execution will halt on Exceptions, they get raised to the application
|
153
|
+
event = create_change_event(param, current_value, historical_value)
|
154
|
+
event.status = "failure"
|
155
|
+
event.message = param.format(_("change from %s to %s failed: "),
|
156
|
+
param.is_to_s(current_value),
|
157
|
+
param.should_to_s(param.should)) + detail.to_s
|
158
|
+
raise
|
159
|
+
ensure
|
160
|
+
if event
|
161
|
+
event.calculate_corrective_change(@persistence.get_system_value(context.resource.ref, param.name.to_s))
|
162
|
+
context.record(event)
|
163
|
+
event.send_log
|
164
|
+
context.synced_params << param.name
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def create_change_event(property, current_value, historical_value)
|
170
|
+
options = {}
|
171
|
+
should = property.should
|
172
|
+
|
173
|
+
if property.sensitive
|
174
|
+
options[:previous_value] = current_value.nil? ? nil : '[redacted]'
|
175
|
+
options[:desired_value] = should.nil? ? nil : '[redacted]'
|
176
|
+
options[:historical_value] = historical_value.nil? ? nil : '[redacted]'
|
177
|
+
else
|
178
|
+
options[:previous_value] = current_value
|
179
|
+
options[:desired_value] = should
|
180
|
+
options[:historical_value] = historical_value
|
181
|
+
end
|
182
|
+
|
183
|
+
property.event(options)
|
184
|
+
end
|
185
|
+
|
186
|
+
# This method is an ugly hack because, given a Time object with nanosecond
|
187
|
+
# resolution, roundtripped through YAML serialization, the Time object will
|
188
|
+
# be truncated to microseconds.
|
189
|
+
# For audit purposes, this code special cases this comparison, and compares
|
190
|
+
# the two objects by their second and microsecond components. tv_sec is the
|
191
|
+
# number of seconds since the epoch, and tv_usec is only the microsecond
|
192
|
+
# portion of time.
|
193
|
+
def are_audited_values_equal(a, b)
|
194
|
+
a == b || (a.is_a?(Time) && b.is_a?(Time) && a.tv_sec == b.tv_sec && a.tv_usec == b.tv_usec)
|
195
|
+
end
|
196
|
+
private :are_audited_values_equal
|
197
|
+
|
198
|
+
# Populate an existing event with audit information.
|
199
|
+
#
|
200
|
+
# @param event [Puppet::Transaction::Event] The event to be populated.
|
201
|
+
# @param property [Puppet::Property] The property being audited.
|
202
|
+
# @param context [ResourceApplicationContext]
|
203
|
+
#
|
204
|
+
# @return [Puppet::Transaction::Event] The given event, populated with the audit information.
|
205
|
+
def audit_event(event, property, context)
|
206
|
+
event.audited = true
|
207
|
+
event.status = "audit"
|
208
|
+
|
209
|
+
# The event we've been provided might have been redacted so we need to use the state stored within
|
210
|
+
# the resource application context to see if an event was actually generated.
|
211
|
+
if !are_audited_values_equal(context.historical_values[property.name], context.current_values[property.name])
|
212
|
+
event.message = property.format(_("audit change: previously recorded value %s has been changed to %s"),
|
213
|
+
property.is_to_s(event.historical_value),
|
214
|
+
property.is_to_s(event.previous_value))
|
215
|
+
end
|
216
|
+
|
217
|
+
event
|
218
|
+
end
|
219
|
+
|
220
|
+
def audit_message(param, do_audit, historical_value, current_value)
|
221
|
+
if do_audit && historical_value && !are_audited_values_equal(historical_value, current_value)
|
222
|
+
param.format(_(" (previously recorded value was %s)"), param.is_to_s(historical_value))
|
223
|
+
else
|
224
|
+
""
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def noop(event, param, current_value, audit_message)
|
229
|
+
event.message = param.format(_("current_value %s, should be %s (noop)"),
|
230
|
+
param.is_to_s(current_value),
|
231
|
+
param.should_to_s(param.should)) + audit_message.to_s
|
232
|
+
event.status = "noop"
|
233
|
+
end
|
234
|
+
|
235
|
+
def sync(event, param, current_value, audit_message)
|
236
|
+
param.sync
|
237
|
+
if param.sensitive
|
238
|
+
event.message = param.format(_("changed %s to %s"),
|
239
|
+
param.is_to_s(current_value),
|
240
|
+
param.should_to_s(param.should)) + audit_message.to_s
|
241
|
+
else
|
242
|
+
event.message = "#{param.change_to_s(current_value, param.should)}#{audit_message}"
|
243
|
+
end
|
244
|
+
event.status = "success"
|
245
|
+
end
|
246
|
+
|
247
|
+
def capture_audit_events(resource, context)
|
248
|
+
context.audited_params.each do |param_name|
|
249
|
+
if context.historical_values.include?(param_name)
|
250
|
+
if !are_audited_values_equal(context.historical_values[param_name], context.current_values[param_name]) && !context.synced_params.include?(param_name)
|
251
|
+
parameter = resource.parameter(param_name)
|
252
|
+
event = audit_event(create_change_event(parameter,
|
253
|
+
context.current_values[param_name],
|
254
|
+
context.historical_values[param_name]),
|
255
|
+
parameter, context)
|
256
|
+
event.send_log
|
257
|
+
context.record(event)
|
258
|
+
end
|
259
|
+
else
|
260
|
+
property = resource.property(param_name)
|
261
|
+
property.notice(property.format(_("audit change: newly-recorded value %s"), context.current_values[param_name]))
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Given an event and its property, calculate the system_value to persist
|
267
|
+
# for future calculations.
|
268
|
+
# @param [Puppet::Transaction::Event] event event to use for processing
|
269
|
+
# @param [Puppet::Property] property correlating property
|
270
|
+
# @param [Object] old_system_value system_value from last transaction
|
271
|
+
# @return [Object] system_value to be used for next transaction
|
272
|
+
def new_system_value(property, event, old_system_value)
|
273
|
+
if event && event.status != "success"
|
274
|
+
# For non-success events, we persist the old_system_value if it is defined,
|
275
|
+
# or use the event previous_value.
|
276
|
+
# If we're using the event previous_value, we ensure that it's
|
277
|
+
# an array. This is needed because properties assume that their
|
278
|
+
# `should` value is an array, and we will use this value later
|
279
|
+
# on in property insync? logic.
|
280
|
+
event_value = [event.previous_value] unless event.previous_value.is_a?(Array)
|
281
|
+
old_system_value.nil? ? event_value : old_system_value
|
282
|
+
else
|
283
|
+
# For non events, or for success cases, we just want to store
|
284
|
+
# the parameters agent value.
|
285
|
+
# We use instance_variable_get here because we want this process to bypass any
|
286
|
+
# munging/unmunging or validation that the property might try to do, since those
|
287
|
+
# operations may not be correctly implemented for custom types.
|
288
|
+
property.instance_variable_get(:@should)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
# @api private
|
293
|
+
ResourceApplicationContext = Struct.new(:resource,
|
294
|
+
:current_values,
|
295
|
+
:historical_values,
|
296
|
+
:audited_params,
|
297
|
+
:synced_params,
|
298
|
+
:status,
|
299
|
+
:system_value_params) do
|
300
|
+
def self.from_resource(resource, status)
|
301
|
+
ResourceApplicationContext.new(resource,
|
302
|
+
resource.retrieve_resource.to_hash,
|
303
|
+
Puppet::Util::Storage.cache(resource).dup,
|
304
|
+
(resource[:audit] || []).map { |p| p.to_sym },
|
305
|
+
[],
|
306
|
+
status,
|
307
|
+
resource.parameters.select { |n,p| p.is_a?(Puppet::Property) && !p.sensitive })
|
308
|
+
end
|
309
|
+
|
310
|
+
def resource_present?
|
311
|
+
resource.present?(current_values)
|
312
|
+
end
|
313
|
+
|
314
|
+
def record(event)
|
315
|
+
status << event
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
@@ -0,0 +1,2665 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'puppet'
|
3
|
+
require 'puppet/util/log'
|
4
|
+
require 'puppet/util/metric'
|
5
|
+
require 'puppet/property'
|
6
|
+
require 'puppet/parameter'
|
7
|
+
require 'puppet/util'
|
8
|
+
require 'puppet/util/autoload'
|
9
|
+
require 'puppet/metatype/manager'
|
10
|
+
require 'puppet/util/errors'
|
11
|
+
require 'puppet/util/logging'
|
12
|
+
require 'puppet/util/tagging'
|
13
|
+
|
14
|
+
# see the bottom of the file for the rest of the inclusions
|
15
|
+
|
16
|
+
|
17
|
+
module Puppet
|
18
|
+
# The base class for all Puppet types.
|
19
|
+
#
|
20
|
+
# A type describes:
|
21
|
+
#--
|
22
|
+
# * **Attributes** - properties, parameters, and meta-parameters are different types of attributes of a type.
|
23
|
+
# * **Properties** - these are the properties of the managed resource (attributes of the entity being managed; like
|
24
|
+
# a file's owner, group and mode). A property describes two states; the 'is' (current state) and the 'should' (wanted
|
25
|
+
# state).
|
26
|
+
# * **Ensurable** - a set of traits that control the lifecycle (create, remove, etc.) of a managed entity.
|
27
|
+
# There is a default set of operations associated with being _ensurable_, but this can be changed.
|
28
|
+
# * **Name/Identity** - one property is the name/identity of a resource, the _namevar_ that uniquely identifies
|
29
|
+
# one instance of a type from all others.
|
30
|
+
# * **Parameters** - additional attributes of the type (that does not directly related to an instance of the managed
|
31
|
+
# resource; if an operation is recursive or not, where to look for things, etc.). A Parameter (in contrast to Property)
|
32
|
+
# has one current value where a Property has two (current-state and wanted-state).
|
33
|
+
# * **Meta-Parameters** - parameters that are available across all types. A meta-parameter typically has
|
34
|
+
# additional semantics; like the `require` meta-parameter. A new type typically does not add new meta-parameters,
|
35
|
+
# but you need to be aware of their existence so you do not inadvertently shadow an existing meta-parameters.
|
36
|
+
# * **Parent** - a type can have a super type (that it inherits from).
|
37
|
+
# * **Validation** - If not just a basic data type, or an enumeration of symbolic values, it is possible to provide
|
38
|
+
# validation logic for a type, properties and parameters.
|
39
|
+
# * **Munging** - munging/unmunging is the process of turning a value in external representation (as used
|
40
|
+
# by a provider) into an internal representation and vice versa. A Type supports adding custom logic for these.
|
41
|
+
# * **Auto Requirements** - a type can specify automatic relationships to resources to ensure that if they are being
|
42
|
+
# managed, they will be processed before this type.
|
43
|
+
# * **Providers** - a provider is an implementation of a type's behavior - the management of a resource in the
|
44
|
+
# system being managed. A provider is often platform specific and is selected at runtime based on
|
45
|
+
# criteria/predicates specified in the configured providers. See {Puppet::Provider} for details.
|
46
|
+
# * **Device Support** - A type has some support for being applied to a device; i.e. something that is managed
|
47
|
+
# by running logic external to the device itself. There are several methods that deals with type
|
48
|
+
# applicability for these special cases such as {apply_to_device}.
|
49
|
+
#
|
50
|
+
# Additional Concepts:
|
51
|
+
# --
|
52
|
+
# * **Resource-type** - A _resource type_ is a term used to denote the type of a resource; internally a resource
|
53
|
+
# is really an instance of a Ruby class i.e. {Puppet::Resource} which defines its behavior as "resource data".
|
54
|
+
# Conceptually however, a resource is an instance of a subclass of Type (e.g. File), where such a class describes
|
55
|
+
# its interface (what can be said/what is known about a resource of this type),
|
56
|
+
# * **Managed Entity** - This is not a term in general use, but is used here when there is a need to make
|
57
|
+
# a distinction between a resource (a description of what/how something should be managed), and what it is
|
58
|
+
# managing (a file in the file system). The term _managed entity_ is a reference to the "file in the file system"
|
59
|
+
# * **Isomorphism** - the quality of being _isomorphic_ means that two resource instances with the same name
|
60
|
+
# refers to the same managed entity. Or put differently; _an isomorphic name is the identity of a resource_.
|
61
|
+
# As an example, `exec` resources (that executes some command) have the command (i.e. the command line string) as
|
62
|
+
# their name, and these resources are said to be non-isomorphic.
|
63
|
+
#
|
64
|
+
# @note The Type class deals with multiple concerns; some methods provide an internal DSL for convenient definition
|
65
|
+
# of types, other methods deal with various aspects while running; wiring up a resource (expressed in Puppet DSL)
|
66
|
+
# with its _resource type_ (i.e. an instance of Type) to enable validation, transformation of values
|
67
|
+
# (munge/unmunge), etc. Lastly, Type is also responsible for dealing with Providers; the concrete implementations
|
68
|
+
# of the behavior that constitutes how a particular Type behaves on a particular type of system (e.g. how
|
69
|
+
# commands are executed on a flavor of Linux, on Windows, etc.). This means that as you are reading through the
|
70
|
+
# documentation of this class, you will be switching between these concepts, as well as switching between
|
71
|
+
# the conceptual level "a resource is an instance of a resource-type" and the actual implementation classes
|
72
|
+
# (Type, Resource, Provider, and various utility and helper classes).
|
73
|
+
#
|
74
|
+
# @api public
|
75
|
+
#
|
76
|
+
#
|
77
|
+
class Type
|
78
|
+
extend Puppet::CompilableResourceType
|
79
|
+
include Puppet::Util
|
80
|
+
include Puppet::Util::Errors
|
81
|
+
include Puppet::Util::Logging
|
82
|
+
include Puppet::Util::Tagging
|
83
|
+
|
84
|
+
# Comparing type instances.
|
85
|
+
include Comparable
|
86
|
+
|
87
|
+
# Compares this type against the given _other_ (type) and returns -1, 0, or +1 depending on the order.
|
88
|
+
# @param other [Object] the object to compare against (produces nil, if not kind of Type}
|
89
|
+
# @return [-1, 0, +1, nil] produces -1 if this type is before the given _other_ type, 0 if equals, and 1 if after.
|
90
|
+
# Returns nil, if the given _other_ is not a kind of Type.
|
91
|
+
# @see Comparable
|
92
|
+
#
|
93
|
+
def <=>(other)
|
94
|
+
# Order is only maintained against other types, not arbitrary objects.
|
95
|
+
# The natural order is based on the reference name used when comparing
|
96
|
+
return nil unless other.is_a?(Puppet::CompilableResourceType) || other.class.is_a?(Puppet::CompilableResourceType)
|
97
|
+
# against other type instances.
|
98
|
+
self.ref <=> other.ref
|
99
|
+
end
|
100
|
+
|
101
|
+
# Code related to resource type attributes.
|
102
|
+
class << self
|
103
|
+
include Puppet::Util::ClassGen
|
104
|
+
include Puppet::Util::Warnings
|
105
|
+
|
106
|
+
# @return [Array<Puppet::Property>] The list of declared properties for the resource type.
|
107
|
+
# The returned lists contains instances if Puppet::Property or its subclasses.
|
108
|
+
attr_reader :properties
|
109
|
+
end
|
110
|
+
|
111
|
+
# Allow declaring that a type is actually a capability
|
112
|
+
class << self
|
113
|
+
attr_accessor :is_capability
|
114
|
+
|
115
|
+
def is_capability?
|
116
|
+
c = is_capability
|
117
|
+
c.nil? ? false : c
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# Returns whether this type represents an application instance; since
|
122
|
+
# only defined types, i.e., instances of Puppet::Resource::Type can
|
123
|
+
# represent application instances, this implementation always returns
|
124
|
+
# +false+. Having this method though makes code checking whether a
|
125
|
+
# resource is an application instance simpler
|
126
|
+
def self.application?
|
127
|
+
false
|
128
|
+
end
|
129
|
+
|
130
|
+
# Returns all the attribute names of the type in the appropriate order.
|
131
|
+
# The {key_attributes} come first, then the {provider}, then the {properties}, and finally
|
132
|
+
# the {parameters} and {metaparams},
|
133
|
+
# all in the order they were specified in the respective files.
|
134
|
+
# @return [Array<String>] all type attribute names in a defined order.
|
135
|
+
#
|
136
|
+
def self.allattrs
|
137
|
+
key_attributes | (parameters & [:provider]) | properties.collect { |property| property.name } | parameters | metaparams
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns the class associated with the given attribute name.
|
141
|
+
# @param name [String] the name of the attribute to obtain the class for
|
142
|
+
# @return [Class, nil] the class for the given attribute, or nil if the name does not refer to an existing attribute
|
143
|
+
#
|
144
|
+
def self.attrclass(name)
|
145
|
+
@attrclasses ||= {}
|
146
|
+
|
147
|
+
# We cache the value, since this method gets called such a huge number
|
148
|
+
# of times (as in, hundreds of thousands in a given run).
|
149
|
+
unless @attrclasses.include?(name)
|
150
|
+
@attrclasses[name] = case self.attrtype(name)
|
151
|
+
when :property; @validproperties[name]
|
152
|
+
when :meta; @@metaparamhash[name]
|
153
|
+
when :param; @paramhash[name]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
@attrclasses[name]
|
157
|
+
end
|
158
|
+
|
159
|
+
# Returns the attribute type (`:property`, `;param`, `:meta`).
|
160
|
+
# @comment What type of parameter are we dealing with? Cache the results, because
|
161
|
+
# this method gets called so many times.
|
162
|
+
# @return [Symbol] a symbol describing the type of attribute (`:property`, `;param`, `:meta`)
|
163
|
+
#
|
164
|
+
def self.attrtype(attr)
|
165
|
+
@attrtypes ||= {}
|
166
|
+
unless @attrtypes.include?(attr)
|
167
|
+
@attrtypes[attr] = case
|
168
|
+
when @validproperties.include?(attr); :property
|
169
|
+
when @paramhash.include?(attr); :param
|
170
|
+
when @@metaparamhash.include?(attr); :meta
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
@attrtypes[attr]
|
175
|
+
end
|
176
|
+
|
177
|
+
# Provides iteration over meta-parameters.
|
178
|
+
# @yieldparam p [Puppet::Parameter] each meta parameter
|
179
|
+
# @return [void]
|
180
|
+
#
|
181
|
+
def self.eachmetaparam
|
182
|
+
@@metaparams.each { |p| yield p.name }
|
183
|
+
end
|
184
|
+
|
185
|
+
# Creates a new `ensure` property with configured default values or with configuration by an optional block.
|
186
|
+
# This method is a convenience method for creating a property `ensure` with default accepted values.
|
187
|
+
# If no block is specified, the new `ensure` property will accept the default symbolic
|
188
|
+
# values `:present`, and `:absent` - see {Puppet::Property::Ensure}.
|
189
|
+
# If something else is wanted, pass a block and make calls to {Puppet::Property.newvalue} from this block
|
190
|
+
# to define each possible value. If a block is passed, the defaults are not automatically added to the set of
|
191
|
+
# valid values.
|
192
|
+
#
|
193
|
+
# @note This method will be automatically called without a block if the type implements the methods
|
194
|
+
# specified by {ensurable?}. It is recommended to always call this method and not rely on this automatic
|
195
|
+
# specification to clearly state that the type is ensurable.
|
196
|
+
#
|
197
|
+
# @overload ensurable()
|
198
|
+
# @overload ensurable({|| ... })
|
199
|
+
# @yield [ ] A block evaluated in scope of the new Parameter
|
200
|
+
# @yieldreturn [void]
|
201
|
+
# @return [void]
|
202
|
+
# @dsl type
|
203
|
+
# @api public
|
204
|
+
#
|
205
|
+
def self.ensurable(&block)
|
206
|
+
if block_given?
|
207
|
+
self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block)
|
208
|
+
else
|
209
|
+
self.newproperty(:ensure, :parent => Puppet::Property::Ensure) do
|
210
|
+
self.defaultvalues
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns true if the type implements the default behavior expected by being _ensurable_ "by default".
|
216
|
+
# A type is _ensurable_ by default if it responds to `:exists`, `:create`, and `:destroy`.
|
217
|
+
# If a type implements these methods and have not already specified that it is _ensurable_, it will be
|
218
|
+
# made so with the defaults specified in {ensurable}.
|
219
|
+
# @return [Boolean] whether the type is _ensurable_ or not.
|
220
|
+
#
|
221
|
+
def self.ensurable?
|
222
|
+
# If the class has all three of these methods defined, then it's
|
223
|
+
# ensurable.
|
224
|
+
[:exists?, :create, :destroy].all? { |method|
|
225
|
+
self.public_method_defined?(method)
|
226
|
+
}
|
227
|
+
end
|
228
|
+
|
229
|
+
# @comment These `apply_to` methods are horrible. They should really be implemented
|
230
|
+
# as part of the usual system of constraints that apply to a type and
|
231
|
+
# provider pair, but were implemented as a separate shadow system.
|
232
|
+
#
|
233
|
+
# @comment We should rip them out in favour of a real constraint pattern around the
|
234
|
+
# target device - whatever that looks like - and not have this additional
|
235
|
+
# magic here. --daniel 2012-03-08
|
236
|
+
#
|
237
|
+
# Makes this type applicable to `:device`.
|
238
|
+
# @return [Symbol] Returns `:device`
|
239
|
+
# @api private
|
240
|
+
#
|
241
|
+
def self.apply_to_device
|
242
|
+
@apply_to = :device
|
243
|
+
end
|
244
|
+
|
245
|
+
# Makes this type applicable to `:host`.
|
246
|
+
# @return [Symbol] Returns `:host`
|
247
|
+
# @api private
|
248
|
+
#
|
249
|
+
def self.apply_to_host
|
250
|
+
@apply_to = :host
|
251
|
+
end
|
252
|
+
|
253
|
+
# Makes this type applicable to `:both` (i.e. `:host` and `:device`).
|
254
|
+
# @return [Symbol] Returns `:both`
|
255
|
+
# @api private
|
256
|
+
#
|
257
|
+
def self.apply_to_all
|
258
|
+
@apply_to = :both
|
259
|
+
end
|
260
|
+
|
261
|
+
# Makes this type apply to `:host` if not already applied to something else.
|
262
|
+
# @return [Symbol] a `:device`, `:host`, or `:both` enumeration
|
263
|
+
# @api private
|
264
|
+
def self.apply_to
|
265
|
+
@apply_to ||= :host
|
266
|
+
end
|
267
|
+
|
268
|
+
# Returns true if this type is applicable to the given target.
|
269
|
+
# @param target [Symbol] should be :device, :host or :target, if anything else, :host is enforced
|
270
|
+
# @return [Boolean] true
|
271
|
+
# @api private
|
272
|
+
#
|
273
|
+
def self.can_apply_to(target)
|
274
|
+
[ target == :device ? :device : :host, :both ].include?(apply_to)
|
275
|
+
end
|
276
|
+
|
277
|
+
# Processes the options for a named parameter.
|
278
|
+
# @param name [String] the name of a parameter
|
279
|
+
# @param options [Hash] a hash of options
|
280
|
+
# @option options [Boolean] :boolean if option set to true, an access method on the form _name_? is added for the param
|
281
|
+
# @return [void]
|
282
|
+
#
|
283
|
+
def self.handle_param_options(name, options)
|
284
|
+
# If it's a boolean parameter, create a method to test the value easily
|
285
|
+
if options[:boolean]
|
286
|
+
define_method(name.to_s + "?") do
|
287
|
+
val = self[name]
|
288
|
+
if val == :true or val == true
|
289
|
+
return true
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
# Is the given parameter a meta-parameter?
|
296
|
+
# @return [Boolean] true if the given parameter is a meta-parameter.
|
297
|
+
#
|
298
|
+
def self.metaparam?(param)
|
299
|
+
@@metaparamhash.include?(param.intern)
|
300
|
+
end
|
301
|
+
|
302
|
+
# Returns the meta-parameter class associated with the given meta-parameter name.
|
303
|
+
# Accepts a `nil` name, and return nil.
|
304
|
+
# @param name [String, nil] the name of a meta-parameter
|
305
|
+
# @return [Class,nil] the class for the given meta-parameter, or `nil` if no such meta-parameter exists, (or if
|
306
|
+
# the given meta-parameter name is `nil`.
|
307
|
+
#
|
308
|
+
def self.metaparamclass(name)
|
309
|
+
return nil if name.nil?
|
310
|
+
@@metaparamhash[name.intern]
|
311
|
+
end
|
312
|
+
|
313
|
+
# Returns all meta-parameter names.
|
314
|
+
# @return [Array<String>] all meta-parameter names
|
315
|
+
#
|
316
|
+
def self.metaparams
|
317
|
+
@@metaparams.collect { |param| param.name }
|
318
|
+
end
|
319
|
+
|
320
|
+
# Returns the documentation for a given meta-parameter of this type.
|
321
|
+
# @param metaparam [Puppet::Parameter] the meta-parameter to get documentation for.
|
322
|
+
# @return [String] the documentation associated with the given meta-parameter, or nil of no such documentation
|
323
|
+
# exists.
|
324
|
+
# @raise if the given metaparam is not a meta-parameter in this type
|
325
|
+
#
|
326
|
+
def self.metaparamdoc(metaparam)
|
327
|
+
@@metaparamhash[metaparam].doc
|
328
|
+
end
|
329
|
+
|
330
|
+
# Creates a new meta-parameter.
|
331
|
+
# This creates a new meta-parameter that is added to this and all inheriting types.
|
332
|
+
# @param name [Symbol] the name of the parameter
|
333
|
+
# @param options [Hash] a hash with options.
|
334
|
+
# @option options [Class<inherits Puppet::Parameter>] :parent (Puppet::Parameter) the super class of this parameter
|
335
|
+
# @option options [Hash{String => Object}] :attributes a hash that is applied to the generated class
|
336
|
+
# by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
|
337
|
+
# block is evaluated.
|
338
|
+
# @option options [Boolean] :boolean (false) specifies if this is a boolean parameter
|
339
|
+
# @option options [Boolean] :namevar (false) specifies if this parameter is the namevar
|
340
|
+
# @option options [Symbol, Array<Symbol>] :required_features specifies required provider features by name
|
341
|
+
# @return [Class<inherits Puppet::Parameter>] the created parameter
|
342
|
+
# @yield [ ] a required block that is evaluated in the scope of the new meta-parameter
|
343
|
+
# @api public
|
344
|
+
# @dsl type
|
345
|
+
# @todo Verify that this description is ok
|
346
|
+
#
|
347
|
+
def self.newmetaparam(name, options = {}, &block)
|
348
|
+
@@metaparams ||= []
|
349
|
+
@@metaparamhash ||= {}
|
350
|
+
name = name.intern
|
351
|
+
|
352
|
+
param = genclass(
|
353
|
+
name,
|
354
|
+
:parent => options[:parent] || Puppet::Parameter,
|
355
|
+
:prefix => "MetaParam",
|
356
|
+
:hash => @@metaparamhash,
|
357
|
+
:array => @@metaparams,
|
358
|
+
:attributes => options[:attributes],
|
359
|
+
&block
|
360
|
+
)
|
361
|
+
|
362
|
+
# Grr.
|
363
|
+
param.required_features = options[:required_features] if options[:required_features]
|
364
|
+
|
365
|
+
handle_param_options(name, options)
|
366
|
+
|
367
|
+
param.metaparam = true
|
368
|
+
|
369
|
+
param
|
370
|
+
end
|
371
|
+
|
372
|
+
# Returns the list of parameters that comprise the composite key / "uniqueness key".
|
373
|
+
# All parameters that return true from #isnamevar? or is named `:name` are included in the returned result.
|
374
|
+
# @see uniqueness_key
|
375
|
+
# @return [Array<Puppet::Parameter>] WARNING: this return type is uncertain
|
376
|
+
def self.key_attribute_parameters
|
377
|
+
@key_attribute_parameters ||= (
|
378
|
+
@parameters.find_all { |param|
|
379
|
+
param.isnamevar? or param.name == :name
|
380
|
+
}
|
381
|
+
)
|
382
|
+
end
|
383
|
+
|
384
|
+
# Returns cached {key_attribute_parameters} names.
|
385
|
+
# Key attributes are properties and parameters that comprise a composite key
|
386
|
+
# or "uniqueness key".
|
387
|
+
# @return [Array<String>] cached key_attribute names
|
388
|
+
#
|
389
|
+
def self.key_attributes
|
390
|
+
# This is a cache miss around 0.05 percent of the time. --daniel 2012-07-17
|
391
|
+
@key_attributes_cache ||= key_attribute_parameters.collect { |p| p.name }
|
392
|
+
end
|
393
|
+
|
394
|
+
# Returns a mapping from the title string to setting of attribute values.
|
395
|
+
# This default implementation provides a mapping of title to the one and only _namevar_ present
|
396
|
+
# in the type's definition.
|
397
|
+
# @note Advanced: some logic requires this mapping to be done differently, using a different
|
398
|
+
# validation/pattern, breaking up the title
|
399
|
+
# into several parts assigning each to an individual attribute, or even use a composite identity where
|
400
|
+
# all namevars are seen as part of the unique identity (such computation is done by the {#uniqueness} method.
|
401
|
+
# These advanced options are rarely used (only one of the built in puppet types use this, and then only
|
402
|
+
# a small part of the available functionality), and the support for these advanced mappings is not
|
403
|
+
# implemented in a straight forward way. For these reasons, this method has been marked as private).
|
404
|
+
#
|
405
|
+
# @raise [Puppet::DevError] if there is no title pattern and there are two or more key attributes
|
406
|
+
# @return [Array<Array<Regexp, Array<Array <Symbol, Proc>>>>, nil] a structure with a regexp and the first key_attribute ???
|
407
|
+
# @comment This wonderful piece of logic creates a structure used by Resource.parse_title which
|
408
|
+
# has the capability to assign parts of the title to one or more attributes; It looks like an implementation
|
409
|
+
# of a composite identity key (all parts of the key_attributes array are in the key). This can also
|
410
|
+
# be seen in the method uniqueness_key.
|
411
|
+
# The implementation in this method simply assigns the title to the one and only namevar (which is name
|
412
|
+
# or a variable marked as namevar).
|
413
|
+
# If there are multiple namevars (any in addition to :name?) then this method MUST be implemented
|
414
|
+
# as it raises an exception if there is more than 1. Note that in puppet, it is only File that uses this
|
415
|
+
# to create a different pattern for assigning to the :path attribute
|
416
|
+
# This requires further digging.
|
417
|
+
# The entire construct is somewhat strange, since resource checks if the method "title_patterns" is
|
418
|
+
# implemented (it seems it always is) - why take this more expensive regexp mathching route for all
|
419
|
+
# other types?
|
420
|
+
# @api private
|
421
|
+
#
|
422
|
+
def self.title_patterns
|
423
|
+
case key_attributes.length
|
424
|
+
when 0; []
|
425
|
+
when 1;
|
426
|
+
[ [ /(.*)/m, [ [key_attributes.first] ] ] ]
|
427
|
+
else
|
428
|
+
raise Puppet::DevError, _("you must specify title patterns when there are two or more key attributes")
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
# Produces a resource's _uniqueness_key_ (or composite key).
|
433
|
+
# This key is an array of all key attributes' values. Each distinct tuple must be unique for each resource type.
|
434
|
+
# @see key_attributes
|
435
|
+
# @return [Object] an object that is a _uniqueness_key_ for this object
|
436
|
+
#
|
437
|
+
def uniqueness_key
|
438
|
+
self.class.key_attributes.sort_by { |attribute_name| attribute_name.to_s }.map{ |attribute_name| self[attribute_name] }
|
439
|
+
end
|
440
|
+
|
441
|
+
# Creates a new parameter.
|
442
|
+
# @param name [Symbol] the name of the parameter
|
443
|
+
# @param options [Hash] a hash with options.
|
444
|
+
# @option options [Class<inherits Puppet::Parameter>] :parent (Puppet::Parameter) the super class of this parameter
|
445
|
+
# @option options [Hash{String => Object}] :attributes a hash that is applied to the generated class
|
446
|
+
# by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
|
447
|
+
# block is evaluated.
|
448
|
+
# @option options [Boolean] :boolean (false) specifies if this is a boolean parameter
|
449
|
+
# @option options [Boolean] :namevar (false) specifies if this parameter is the namevar
|
450
|
+
# @option options [Symbol, Array<Symbol>] :required_features specifies required provider features by name
|
451
|
+
# @return [Class<inherits Puppet::Parameter>] the created parameter
|
452
|
+
# @yield [ ] a required block that is evaluated in the scope of the new parameter
|
453
|
+
# @api public
|
454
|
+
# @dsl type
|
455
|
+
#
|
456
|
+
def self.newparam(name, options = {}, &block)
|
457
|
+
options[:attributes] ||= {}
|
458
|
+
|
459
|
+
param = genclass(
|
460
|
+
name,
|
461
|
+
:parent => options[:parent] || Puppet::Parameter,
|
462
|
+
:attributes => options[:attributes],
|
463
|
+
:block => block,
|
464
|
+
:prefix => "Parameter",
|
465
|
+
:array => @parameters,
|
466
|
+
:hash => @paramhash
|
467
|
+
)
|
468
|
+
|
469
|
+
handle_param_options(name, options)
|
470
|
+
|
471
|
+
# Grr.
|
472
|
+
param.required_features = options[:required_features] if options[:required_features]
|
473
|
+
|
474
|
+
param.isnamevar if options[:namevar]
|
475
|
+
|
476
|
+
param
|
477
|
+
end
|
478
|
+
|
479
|
+
# Creates a new property.
|
480
|
+
# @param name [Symbol] the name of the property
|
481
|
+
# @param options [Hash] a hash with options.
|
482
|
+
# @option options [Symbol] :array_matching (:first) specifies how the current state is matched against
|
483
|
+
# the wanted state. Use `:first` if the property is single valued, and (`:all`) otherwise.
|
484
|
+
# @option options [Class<inherits Puppet::Property>] :parent (Puppet::Property) the super class of this property
|
485
|
+
# @option options [Hash{String => Object}] :attributes a hash that is applied to the generated class
|
486
|
+
# by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
|
487
|
+
# block is evaluated.
|
488
|
+
# @option options [Boolean] :boolean (false) specifies if this is a boolean parameter
|
489
|
+
# @option options [Symbol] :retrieve the method to call on the provider (or `parent` if `provider` is not set)
|
490
|
+
# to retrieve the current value of this property.
|
491
|
+
# @option options [Symbol, Array<Symbol>] :required_features specifies required provider features by name
|
492
|
+
# @return [Class<inherits Puppet::Property>] the created property
|
493
|
+
# @yield [ ] a required block that is evaluated in the scope of the new property
|
494
|
+
# @api public
|
495
|
+
# @dsl type
|
496
|
+
#
|
497
|
+
def self.newproperty(name, options = {}, &block)
|
498
|
+
name = name.intern
|
499
|
+
|
500
|
+
# This is here for types that might still have the old method of defining
|
501
|
+
# a parent class.
|
502
|
+
unless options.is_a? Hash
|
503
|
+
raise Puppet::DevError, _("Options must be a hash, not %{type}") % { type: options.inspect }
|
504
|
+
end
|
505
|
+
|
506
|
+
raise Puppet::DevError, _("Class %{class_name} already has a property named %{property}") % { class_name: self.name, property: name } if @validproperties.include?(name)
|
507
|
+
|
508
|
+
if parent = options[:parent]
|
509
|
+
options.delete(:parent)
|
510
|
+
else
|
511
|
+
parent = Puppet::Property
|
512
|
+
end
|
513
|
+
|
514
|
+
# We have to create our own, new block here because we want to define
|
515
|
+
# an initial :retrieve method, if told to, and then eval the passed
|
516
|
+
# block if available.
|
517
|
+
prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
|
518
|
+
# If they've passed a retrieve method, then override the retrieve
|
519
|
+
# method on the class.
|
520
|
+
if options[:retrieve]
|
521
|
+
define_method(:retrieve) do
|
522
|
+
provider.send(options[:retrieve])
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
class_eval(&block) if block
|
527
|
+
end
|
528
|
+
|
529
|
+
# If it's the 'ensure' property, always put it first.
|
530
|
+
if name == :ensure
|
531
|
+
@properties.unshift prop
|
532
|
+
else
|
533
|
+
@properties << prop
|
534
|
+
end
|
535
|
+
|
536
|
+
prop
|
537
|
+
end
|
538
|
+
|
539
|
+
def self.paramdoc(param)
|
540
|
+
@paramhash[param].doc
|
541
|
+
end
|
542
|
+
|
543
|
+
# @return [Array<String>] Returns the parameter names
|
544
|
+
def self.parameters
|
545
|
+
return [] unless defined?(@parameters)
|
546
|
+
@parameters.collect { |klass| klass.name }
|
547
|
+
end
|
548
|
+
|
549
|
+
# @return [Puppet::Parameter] Returns the parameter class associated with the given parameter name.
|
550
|
+
def self.paramclass(name)
|
551
|
+
@paramhash[name]
|
552
|
+
end
|
553
|
+
|
554
|
+
# @return [Puppet::Property] Returns the property class ??? associated with the given property name
|
555
|
+
def self.propertybyname(name)
|
556
|
+
@validproperties[name]
|
557
|
+
end
|
558
|
+
|
559
|
+
# Returns whether or not the given name is the name of a property, parameter or meta-parameter
|
560
|
+
# @return [Boolean] true if the given attribute name is the name of an existing property, parameter or meta-parameter
|
561
|
+
#
|
562
|
+
def self.validattr?(name)
|
563
|
+
name = name.intern
|
564
|
+
return true if name == :name
|
565
|
+
@validattrs ||= {}
|
566
|
+
|
567
|
+
unless @validattrs.include?(name)
|
568
|
+
@validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name))
|
569
|
+
end
|
570
|
+
|
571
|
+
@validattrs[name]
|
572
|
+
end
|
573
|
+
|
574
|
+
# @return [Boolean] Returns true if the given name is the name of an existing property
|
575
|
+
def self.validproperty?(name)
|
576
|
+
name = name.intern
|
577
|
+
@validproperties.include?(name) && @validproperties[name]
|
578
|
+
end
|
579
|
+
|
580
|
+
# @return [Array<Symbol>, {}] Returns a list of valid property names, or an empty hash if there are none.
|
581
|
+
# @todo An empty hash is returned if there are no defined parameters (not an empty array). This looks like
|
582
|
+
# a bug.
|
583
|
+
#
|
584
|
+
def self.validproperties
|
585
|
+
return {} unless defined?(@parameters)
|
586
|
+
|
587
|
+
@validproperties.keys
|
588
|
+
end
|
589
|
+
|
590
|
+
# @return [Boolean] Returns true if the given name is the name of an existing parameter
|
591
|
+
def self.validparameter?(name)
|
592
|
+
raise Puppet::DevError, _("Class %{class_name} has not defined parameters") % { class_name: self } unless defined?(@parameters)
|
593
|
+
!!(@paramhash.include?(name) or @@metaparamhash.include?(name))
|
594
|
+
end
|
595
|
+
|
596
|
+
# (see validattr?)
|
597
|
+
# @note see comment in code - how should this be documented? Are some of the other query methods deprecated?
|
598
|
+
# (or should be).
|
599
|
+
# @comment This is a forward-compatibility method - it's the validity interface we'll use in Puppet::Resource.
|
600
|
+
def self.valid_parameter?(name)
|
601
|
+
validattr?(name)
|
602
|
+
end
|
603
|
+
|
604
|
+
# @return [Boolean] Returns true if the wanted state of the resource is that it should be absent (i.e. to be deleted).
|
605
|
+
def deleting?
|
606
|
+
obj = @parameters[:ensure] and obj.should == :absent
|
607
|
+
end
|
608
|
+
|
609
|
+
# Creates a new property value holder for the resource if it is valid and does not already exist
|
610
|
+
# @return [Boolean] true if a new parameter was added, false otherwise
|
611
|
+
def add_property_parameter(prop_name)
|
612
|
+
if self.class.validproperty?(prop_name) && !@parameters[prop_name]
|
613
|
+
self.newattr(prop_name)
|
614
|
+
return true
|
615
|
+
end
|
616
|
+
false
|
617
|
+
end
|
618
|
+
|
619
|
+
# @return [Symbol, Boolean] Returns the name of the namevar if there is only one or false otherwise.
|
620
|
+
# @comment This is really convoluted and part of the support for multiple namevars (?).
|
621
|
+
# If there is only one namevar, the produced value is naturally this namevar, but if there are several?
|
622
|
+
# The logic caches the name of the namevar if it is a single name, but otherwise always
|
623
|
+
# calls key_attributes, and then caches the first if there was only one, otherwise it returns
|
624
|
+
# false and caches this (which is then subsequently returned as a cache hit).
|
625
|
+
#
|
626
|
+
def name_var
|
627
|
+
return @name_var_cache unless @name_var_cache.nil?
|
628
|
+
key_attributes = self.class.key_attributes
|
629
|
+
@name_var_cache = (key_attributes.length == 1) && key_attributes.first
|
630
|
+
end
|
631
|
+
|
632
|
+
# Gets the 'should' (wanted state) value of a parameter or property by name.
|
633
|
+
# To explicitly get the 'is' (current state) value use `o.is(:name)`, and to explicitly get the 'should' value
|
634
|
+
# use `o.should(:name)`
|
635
|
+
# @param name [String] the name of the attribute to obtain the 'should' value for.
|
636
|
+
# @return [Object] 'should'/wanted value of the given attribute
|
637
|
+
def [](name)
|
638
|
+
name = name.intern
|
639
|
+
fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name)
|
640
|
+
|
641
|
+
if name == :name && nv = name_var
|
642
|
+
name = nv
|
643
|
+
end
|
644
|
+
|
645
|
+
if obj = @parameters[name]
|
646
|
+
# Note that if this is a property, then the value is the "should" value,
|
647
|
+
# not the current value.
|
648
|
+
obj.value
|
649
|
+
else
|
650
|
+
return nil
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
# Sets the 'should' (wanted state) value of a property, or the value of a parameter.
|
655
|
+
# @return
|
656
|
+
# @raise [Puppet::Error] if the setting of the value fails, or if the given name is nil.
|
657
|
+
# @raise [Puppet::ResourceError] when the parameter validation raises Puppet::Error or
|
658
|
+
# ArgumentError
|
659
|
+
def []=(name,value)
|
660
|
+
name = name.intern
|
661
|
+
|
662
|
+
fail("no parameter named '#{name}'") unless self.class.validattr?(name)
|
663
|
+
|
664
|
+
if name == :name && nv = name_var
|
665
|
+
name = nv
|
666
|
+
end
|
667
|
+
raise Puppet::Error.new("Got nil value for #{name}") if value.nil?
|
668
|
+
|
669
|
+
property = self.newattr(name)
|
670
|
+
|
671
|
+
if property
|
672
|
+
begin
|
673
|
+
# make sure the parameter doesn't have any errors
|
674
|
+
property.value = value
|
675
|
+
rescue Puppet::Error, ArgumentError => detail
|
676
|
+
error = Puppet::ResourceError.new(_("Parameter %{name} failed on %{ref}: %{detail}") %
|
677
|
+
{ name: name, ref: ref, detail: detail })
|
678
|
+
adderrorcontext(error, detail)
|
679
|
+
raise error
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
nil
|
684
|
+
end
|
685
|
+
|
686
|
+
# Removes an attribute from the object; useful in testing or in cleanup
|
687
|
+
# when an error has been encountered
|
688
|
+
# @todo Don't know what the attr is (name or Property/Parameter?). Guessing it is a String name...
|
689
|
+
# @todo Is it possible to delete a meta-parameter?
|
690
|
+
# @todo What does delete mean? Is it deleted from the type or is its value state 'is'/'should' deleted?
|
691
|
+
# @param attr [String] the attribute to delete from this object. WHAT IS THE TYPE?
|
692
|
+
# @raise [Puppet::DecError] when an attempt is made to delete an attribute that does not exists.
|
693
|
+
#
|
694
|
+
def delete(attr)
|
695
|
+
attr = attr.intern
|
696
|
+
if @parameters.has_key?(attr)
|
697
|
+
@parameters.delete(attr)
|
698
|
+
else
|
699
|
+
raise Puppet::DevError.new(_("Undefined attribute '%{attribute}' in %{name}") % { attribute: attr, name: self})
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
# Iterates over the properties that were set on this resource.
|
704
|
+
# @yieldparam property [Puppet::Property] each property
|
705
|
+
# @return [void]
|
706
|
+
def eachproperty
|
707
|
+
# properties is a private method
|
708
|
+
properties.each { |property|
|
709
|
+
yield property
|
710
|
+
}
|
711
|
+
end
|
712
|
+
|
713
|
+
# Return the parameters, metaparams, and properties that have a value or were set by a default. Properties are
|
714
|
+
# included since they are a subclass of parameter.
|
715
|
+
# @return [Array<Puppet::Parameter>] Array of parameter objects ( or subclass thereof )
|
716
|
+
def parameters_with_value
|
717
|
+
self.class.allattrs.collect { |attr| parameter(attr) }.compact
|
718
|
+
end
|
719
|
+
|
720
|
+
# Iterates over all parameters with value currently set.
|
721
|
+
# @yieldparam parameter [Puppet::Parameter] or a subclass thereof
|
722
|
+
# @return [void]
|
723
|
+
def eachparameter
|
724
|
+
parameters_with_value.each { |parameter| yield parameter }
|
725
|
+
end
|
726
|
+
|
727
|
+
# Creates a transaction event.
|
728
|
+
# Called by Transaction or by a property.
|
729
|
+
# Merges the given options with the options `:resource`, `:file`, `:line`, and `:tags`, initialized from
|
730
|
+
# values in this object. For possible options to pass (if any ????) see {Puppet::Transaction::Event}.
|
731
|
+
# @todo Needs a better explanation "Why should I care who is calling this method?", What do I need to know
|
732
|
+
# about events and how they work? Where can I read about them?
|
733
|
+
# @param options [Hash] options merged with a fixed set of options defined by this method, passed on to {Puppet::Transaction::Event}.
|
734
|
+
# @return [Puppet::Transaction::Event] the created event
|
735
|
+
def event(options = {})
|
736
|
+
Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags}.merge(options))
|
737
|
+
end
|
738
|
+
|
739
|
+
# @return [Object, nil] Returns the 'should' (wanted state) value for a specified property, or nil if the
|
740
|
+
# given attribute name is not a property (i.e. if it is a parameter, meta-parameter, or does not exist).
|
741
|
+
def should(name)
|
742
|
+
name = name.intern
|
743
|
+
(prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil
|
744
|
+
end
|
745
|
+
|
746
|
+
# Registers an attribute to this resource type instance.
|
747
|
+
# Requires either the attribute name or class as its argument.
|
748
|
+
# This is a noop if the named property/parameter is not supported
|
749
|
+
# by this resource. Otherwise, an attribute instance is created
|
750
|
+
# and kept in this resource's parameters hash.
|
751
|
+
# @overload newattr(name)
|
752
|
+
# @param name [Symbol] symbolic name of the attribute
|
753
|
+
# @overload newattr(klass)
|
754
|
+
# @param klass [Class] a class supported as an attribute class, i.e. a subclass of
|
755
|
+
# Parameter or Property
|
756
|
+
# @return [Object] An instance of the named Parameter or Property class associated
|
757
|
+
# to this resource type instance, or nil if the attribute is not supported
|
758
|
+
#
|
759
|
+
def newattr(name)
|
760
|
+
if name.is_a?(Class)
|
761
|
+
klass = name
|
762
|
+
name = klass.name
|
763
|
+
end
|
764
|
+
|
765
|
+
unless klass = self.class.attrclass(name)
|
766
|
+
raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}"
|
767
|
+
end
|
768
|
+
|
769
|
+
if provider and ! provider.class.supports_parameter?(klass)
|
770
|
+
missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) }
|
771
|
+
debug "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name]
|
772
|
+
return nil
|
773
|
+
end
|
774
|
+
|
775
|
+
return @parameters[name] if @parameters.include?(name)
|
776
|
+
|
777
|
+
@parameters[name] = klass.new(:resource => self)
|
778
|
+
end
|
779
|
+
|
780
|
+
# Returns a string representation of the resource's containment path in
|
781
|
+
# the catalog.
|
782
|
+
# @return [String]
|
783
|
+
def path
|
784
|
+
@path ||= '/' + pathbuilder.join('/')
|
785
|
+
end
|
786
|
+
|
787
|
+
# Returns the value of this object's parameter given by name
|
788
|
+
# @param name [String] the name of the parameter
|
789
|
+
# @return [Object] the value
|
790
|
+
def parameter(name)
|
791
|
+
@parameters[name.to_sym]
|
792
|
+
end
|
793
|
+
|
794
|
+
# Returns a shallow copy of this object's hash of attributes by name.
|
795
|
+
# Note that his not only comprises parameters, but also properties and metaparameters.
|
796
|
+
# Changes to the contained parameters will have an effect on the parameters of this type, but changes to
|
797
|
+
# the returned hash does not.
|
798
|
+
# @return [Hash{String => Object}] a new hash being a shallow copy of the parameters map name to parameter
|
799
|
+
def parameters
|
800
|
+
@parameters.dup
|
801
|
+
end
|
802
|
+
|
803
|
+
# @return [Boolean] Returns whether the attribute given by name has been added
|
804
|
+
# to this resource or not.
|
805
|
+
def propertydefined?(name)
|
806
|
+
name = name.intern unless name.is_a? Symbol
|
807
|
+
@parameters.include?(name)
|
808
|
+
end
|
809
|
+
|
810
|
+
# Returns a {Puppet::Property} instance by name.
|
811
|
+
# To return the value, use 'resource[param]'
|
812
|
+
# @todo LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
|
813
|
+
# this one should probably go away at some point. - Does this mean it should be deprecated ?
|
814
|
+
# @return [Puppet::Property] the property with the given name, or nil if not a property or does not exist.
|
815
|
+
def property(name)
|
816
|
+
(obj = @parameters[name.intern] and obj.is_a?(Puppet::Property)) ? obj : nil
|
817
|
+
end
|
818
|
+
|
819
|
+
# @todo comment says "For any parameters or properties that have defaults and have not yet been
|
820
|
+
# set, set them now. This method can be handed a list of attributes,
|
821
|
+
# and if so it will only set defaults for those attributes."
|
822
|
+
# @todo Needs a better explanation, and investigation about the claim an array can be passed (it is passed
|
823
|
+
# to self.class.attrclass to produce a class on which a check is made if it has a method class :default (does
|
824
|
+
# not seem to support an array...
|
825
|
+
# @return [void]
|
826
|
+
#
|
827
|
+
def set_default(attr)
|
828
|
+
return unless klass = self.class.attrclass(attr)
|
829
|
+
return unless klass.method_defined?(:default)
|
830
|
+
return if @parameters.include?(klass.name)
|
831
|
+
|
832
|
+
return unless parameter = newattr(klass.name)
|
833
|
+
|
834
|
+
if value = parameter.default and ! value.nil?
|
835
|
+
parameter.value = value
|
836
|
+
else
|
837
|
+
@parameters.delete(parameter.name)
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
# @todo the comment says: "Convert our object to a hash. This just includes properties."
|
842
|
+
# @todo this is confused, again it is the @parameters instance variable that is consulted, and
|
843
|
+
# each value is copied - does it contain "properties" and "parameters" or both? Does it contain
|
844
|
+
# meta-parameters?
|
845
|
+
#
|
846
|
+
# @return [Hash{ ??? => ??? }] a hash of WHAT?. The hash is a shallow copy, any changes to the
|
847
|
+
# objects returned in this hash will be reflected in the original resource having these attributes.
|
848
|
+
#
|
849
|
+
def to_hash
|
850
|
+
rethash = {}
|
851
|
+
|
852
|
+
@parameters.each do |name, obj|
|
853
|
+
rethash[name] = obj.value
|
854
|
+
end
|
855
|
+
|
856
|
+
rethash
|
857
|
+
end
|
858
|
+
|
859
|
+
# @return [String] the name of this object's class
|
860
|
+
# @todo Would that be "file" for the "File" resource type? of "File" or something else?
|
861
|
+
#
|
862
|
+
def type
|
863
|
+
self.class.name
|
864
|
+
end
|
865
|
+
|
866
|
+
# @todo Comment says "Return a specific value for an attribute.", as opposed to what "An unspecific value"???
|
867
|
+
# @todo is this the 'is' or the 'should' value?
|
868
|
+
# @todo why is the return restricted to things that respond to :value? (Only non structural basic data types
|
869
|
+
# supported?
|
870
|
+
#
|
871
|
+
# @return [Object, nil] the value of the attribute having the given name, or nil if the given name is not
|
872
|
+
# an attribute, or the referenced attribute does not respond to `:value`.
|
873
|
+
def value(name)
|
874
|
+
name = name.intern
|
875
|
+
|
876
|
+
(obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil
|
877
|
+
end
|
878
|
+
|
879
|
+
# @todo What is this used for? Needs a better explanation.
|
880
|
+
# @return [???] the version of the catalog or 0 if there is no catalog.
|
881
|
+
def version
|
882
|
+
return 0 unless catalog
|
883
|
+
catalog.version
|
884
|
+
end
|
885
|
+
|
886
|
+
# @return [Array<Puppet::Property>] Returns all of the property objects, in the order specified in the
|
887
|
+
# class.
|
888
|
+
# @todo "what does the 'order specified in the class' mean? The order the properties where added in the
|
889
|
+
# ruby file adding a new type with new properties?
|
890
|
+
#
|
891
|
+
def properties
|
892
|
+
self.class.properties.collect { |prop| @parameters[prop.name] }.compact
|
893
|
+
end
|
894
|
+
|
895
|
+
# Returns true if the type's notion of name is the identity of a resource.
|
896
|
+
# See the overview of this class for a longer explanation of the concept _isomorphism_.
|
897
|
+
# Defaults to true.
|
898
|
+
#
|
899
|
+
# @return [Boolean] true, if this type's name is isomorphic with the object
|
900
|
+
def self.isomorphic?
|
901
|
+
if defined?(@isomorphic)
|
902
|
+
return @isomorphic
|
903
|
+
else
|
904
|
+
return true
|
905
|
+
end
|
906
|
+
end
|
907
|
+
|
908
|
+
# @todo check that this gets documentation (it is at the class level as well as instance).
|
909
|
+
# (see isomorphic?)
|
910
|
+
def isomorphic?
|
911
|
+
self.class.isomorphic?
|
912
|
+
end
|
913
|
+
|
914
|
+
# Returns true if the instance is a managed instance.
|
915
|
+
# A 'yes' here means that the instance was created from the language, vs. being created
|
916
|
+
# in order resolve other questions, such as finding a package in a list.
|
917
|
+
# @note An object that is managed always stays managed, but an object that is not managed
|
918
|
+
# may become managed later in its lifecycle.
|
919
|
+
# @return [Boolean] true if the object is managed
|
920
|
+
def managed?
|
921
|
+
# Once an object is managed, it always stays managed; but an object
|
922
|
+
# that is listed as unmanaged might become managed later in the process,
|
923
|
+
# so we have to check that every time
|
924
|
+
if @managed
|
925
|
+
return @managed
|
926
|
+
else
|
927
|
+
@managed = false
|
928
|
+
properties.each { |property|
|
929
|
+
s = property.should
|
930
|
+
if s and ! property.class.unmanaged
|
931
|
+
@managed = true
|
932
|
+
break
|
933
|
+
end
|
934
|
+
}
|
935
|
+
return @managed
|
936
|
+
end
|
937
|
+
end
|
938
|
+
|
939
|
+
###############################
|
940
|
+
# Code related to the container behaviour.
|
941
|
+
|
942
|
+
# Returns true if the search should be done in depth-first order.
|
943
|
+
# This implementation always returns false.
|
944
|
+
# @todo What is this used for?
|
945
|
+
#
|
946
|
+
# @return [Boolean] true if the search should be done in depth first order.
|
947
|
+
#
|
948
|
+
def depthfirst?
|
949
|
+
false
|
950
|
+
end
|
951
|
+
|
952
|
+
# Removes this object (FROM WHERE?)
|
953
|
+
# @todo removes if from where?
|
954
|
+
# @return [void]
|
955
|
+
def remove()
|
956
|
+
# This is hackish (mmm, cut and paste), but it works for now, and it's
|
957
|
+
# better than warnings.
|
958
|
+
@parameters.each do |name, obj|
|
959
|
+
obj.remove
|
960
|
+
end
|
961
|
+
@parameters.clear
|
962
|
+
|
963
|
+
@parent = nil
|
964
|
+
|
965
|
+
# Remove the reference to the provider.
|
966
|
+
if self.provider
|
967
|
+
@provider.clear
|
968
|
+
@provider = nil
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
###############################
|
973
|
+
# Code related to evaluating the resources.
|
974
|
+
|
975
|
+
# Returns the ancestors - WHAT?
|
976
|
+
# This implementation always returns an empty list.
|
977
|
+
# @todo WHAT IS THIS ?
|
978
|
+
# @return [Array<???>] returns a list of ancestors.
|
979
|
+
def ancestors
|
980
|
+
[]
|
981
|
+
end
|
982
|
+
|
983
|
+
# Lifecycle method for a resource. This is called during graph creation.
|
984
|
+
# It should perform any consistency checking of the catalog and raise a
|
985
|
+
# Puppet::Error if the transaction should be aborted.
|
986
|
+
#
|
987
|
+
# It differs from the validate method, since it is called later during
|
988
|
+
# initialization and can rely on self.catalog to have references to all
|
989
|
+
# resources that comprise the catalog.
|
990
|
+
#
|
991
|
+
# @see Puppet::Transaction#add_vertex
|
992
|
+
# @raise [Puppet::Error] If the pre-run check failed.
|
993
|
+
# @return [void]
|
994
|
+
# @abstract a resource type may implement this method to perform
|
995
|
+
# validation checks that can query the complete catalog
|
996
|
+
def pre_run_check
|
997
|
+
end
|
998
|
+
|
999
|
+
# Flushes the provider if supported by the provider, else no action.
|
1000
|
+
# This is called by the transaction.
|
1001
|
+
# @todo What does Flushing the provider mean? Why is it interesting to know that this is
|
1002
|
+
# called by the transaction? (It is not explained anywhere what a transaction is).
|
1003
|
+
#
|
1004
|
+
# @return [???, nil] WHAT DOES IT RETURN? GUESS IS VOID
|
1005
|
+
def flush
|
1006
|
+
self.provider.flush if self.provider and self.provider.respond_to?(:flush)
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
# Returns true if all contained objects are in sync.
|
1010
|
+
# @todo "contained in what?" in the given "in" parameter?
|
1011
|
+
#
|
1012
|
+
# @todo deal with the comment _"FIXME I don't think this is used on the type instances any more,
|
1013
|
+
# it's really only used for testing"_
|
1014
|
+
# @return [Boolean] true if in sync, false otherwise.
|
1015
|
+
#
|
1016
|
+
def insync?(is)
|
1017
|
+
insync = true
|
1018
|
+
|
1019
|
+
if property = @parameters[:ensure]
|
1020
|
+
unless is.include? property
|
1021
|
+
#TRANSLATORS 'is' is a variable name and should not be translated
|
1022
|
+
raise Puppet::DevError, _("The 'is' value is not in the 'is' array for '%{name}'") % { name: property.name }
|
1023
|
+
end
|
1024
|
+
ensureis = is[property]
|
1025
|
+
if property.safe_insync?(ensureis) and property.should == :absent
|
1026
|
+
return true
|
1027
|
+
end
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
properties.each { |prop|
|
1031
|
+
unless is.include? prop
|
1032
|
+
#TRANSLATORS 'is' is a variable name and should not be translated
|
1033
|
+
raise Puppet::DevError, _("The 'is' value is not in the 'is' array for '%{name}'") % { name: prop.name }
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
propis = is[prop]
|
1037
|
+
unless prop.safe_insync?(propis)
|
1038
|
+
prop.debug("Not in sync: #{propis.inspect} vs #{prop.should.inspect}")
|
1039
|
+
insync = false
|
1040
|
+
#else
|
1041
|
+
# property.debug("In sync")
|
1042
|
+
end
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
#self.debug("#{self} sync status is #{insync}")
|
1046
|
+
insync
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
# Says if the ensure property should be retrieved if the resource is ensurable
|
1050
|
+
# Defaults to true. Some resource type classes can override it
|
1051
|
+
def self.needs_ensure_retrieved
|
1052
|
+
true
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
# Retrieves the current value of all contained properties.
|
1056
|
+
# Parameters and meta-parameters are not included in the result.
|
1057
|
+
# @todo As opposed to all non contained properties? How is this different than any of the other
|
1058
|
+
# methods that also "gets" properties/parameters/etc. ?
|
1059
|
+
# @return [Puppet::Resource] array of all property values (mix of types)
|
1060
|
+
# @raise [fail???] if there is a provider and it is not suitable for the host this is evaluated for.
|
1061
|
+
def retrieve
|
1062
|
+
fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable?
|
1063
|
+
|
1064
|
+
result = Puppet::Resource.new(self.class, title)
|
1065
|
+
|
1066
|
+
# Provide the name, so we know we'll always refer to a real thing
|
1067
|
+
result[:name] = self[:name] unless self[:name] == title
|
1068
|
+
|
1069
|
+
if ensure_prop = property(:ensure) or (self.class.needs_ensure_retrieved and self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
|
1070
|
+
result[:ensure] = ensure_state = ensure_prop.retrieve
|
1071
|
+
else
|
1072
|
+
ensure_state = nil
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
properties.each do |property|
|
1076
|
+
next if property.name == :ensure
|
1077
|
+
if ensure_state == :absent
|
1078
|
+
result[property] = :absent
|
1079
|
+
else
|
1080
|
+
result[property] = property.retrieve
|
1081
|
+
end
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
result
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
# Retrieve the current state of the system as a Puppet::Resource. For
|
1088
|
+
# the base Puppet::Type this does the same thing as #retrieve, but
|
1089
|
+
# specific types are free to implement #retrieve as returning a hash,
|
1090
|
+
# and this will call #retrieve and convert the hash to a resource.
|
1091
|
+
# This is used when determining when syncing a resource.
|
1092
|
+
#
|
1093
|
+
# @return [Puppet::Resource] A resource representing the current state
|
1094
|
+
# of the system.
|
1095
|
+
#
|
1096
|
+
# @api private
|
1097
|
+
def retrieve_resource
|
1098
|
+
resource = retrieve
|
1099
|
+
resource = Resource.new(self.class, title, :parameters => resource) if resource.is_a? Hash
|
1100
|
+
resource
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
# Given the hash of current properties, should this resource be treated as if it
|
1104
|
+
# currently exists on the system. May need to be overridden by types that offer up
|
1105
|
+
# more than just :absent and :present.
|
1106
|
+
def present?(current_values)
|
1107
|
+
current_values[:ensure] != :absent
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
# Returns a hash of the current properties and their values.
|
1111
|
+
# If a resource is absent, its value is the symbol `:absent`
|
1112
|
+
# @return [Hash{Puppet::Property => Object}] mapping of property instance to its value
|
1113
|
+
#
|
1114
|
+
def currentpropvalues
|
1115
|
+
# It's important to use the 'properties' method here, as it follows the order
|
1116
|
+
# in which they're defined in the class. It also guarantees that 'ensure'
|
1117
|
+
# is the first property, which is important for skipping 'retrieve' on
|
1118
|
+
# all the properties if the resource is absent.
|
1119
|
+
ensure_state = false
|
1120
|
+
return properties.inject({}) do | prophash, property|
|
1121
|
+
if property.name == :ensure
|
1122
|
+
ensure_state = property.retrieve
|
1123
|
+
prophash[property] = ensure_state
|
1124
|
+
else
|
1125
|
+
if ensure_state == :absent
|
1126
|
+
prophash[property] = :absent
|
1127
|
+
else
|
1128
|
+
prophash[property] = property.retrieve
|
1129
|
+
end
|
1130
|
+
end
|
1131
|
+
prophash
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
# Returns the `noop` run mode status of this.
|
1136
|
+
# @return [Boolean] true if running in noop mode.
|
1137
|
+
def noop?
|
1138
|
+
# If we're not a host_config, we're almost certainly part of
|
1139
|
+
# Settings, and we want to ignore 'noop'
|
1140
|
+
return false if catalog and ! catalog.host_config?
|
1141
|
+
|
1142
|
+
if defined?(@noop)
|
1143
|
+
@noop
|
1144
|
+
else
|
1145
|
+
Puppet[:noop]
|
1146
|
+
end
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
# (see #noop?)
|
1150
|
+
def noop
|
1151
|
+
noop?
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
# Retrieves all known instances.
|
1155
|
+
# @todo Retrieves them from where? Known to whom?
|
1156
|
+
# Either requires providers or must be overridden.
|
1157
|
+
# @raise [Puppet::DevError] when there are no providers and the implementation has not overridden this method.
|
1158
|
+
def self.instances
|
1159
|
+
raise Puppet::DevError, _("%{name} has no providers and has not overridden 'instances'") % { name: self.name } if provider_hash.empty?
|
1160
|
+
|
1161
|
+
# Put the default provider first, then the rest of the suitable providers.
|
1162
|
+
provider_instances = {}
|
1163
|
+
providers_by_source.collect do |provider|
|
1164
|
+
provider.instances.collect do |instance|
|
1165
|
+
# We always want to use the "first" provider instance we find, unless the resource
|
1166
|
+
# is already managed and has a different provider set
|
1167
|
+
if other = provider_instances[instance.name]
|
1168
|
+
Puppet.debug "%s %s found in both %s and %s; skipping the %s version" %
|
1169
|
+
[self.name.to_s.capitalize, instance.name, other.class.name, instance.class.name, instance.class.name]
|
1170
|
+
next
|
1171
|
+
end
|
1172
|
+
provider_instances[instance.name] = instance
|
1173
|
+
|
1174
|
+
result = new(:name => instance.name, :provider => instance)
|
1175
|
+
properties.each { |name| result.newattr(name) }
|
1176
|
+
result
|
1177
|
+
end
|
1178
|
+
end.flatten.compact
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
# Returns a list of one suitable provider per source, with the default provider first.
|
1182
|
+
# @todo Needs better explanation; what does "source" mean in this context?
|
1183
|
+
# @return [Array<Puppet::Provider>] list of providers
|
1184
|
+
#
|
1185
|
+
def self.providers_by_source
|
1186
|
+
# Put the default provider first (can be nil), then the rest of the suitable providers.
|
1187
|
+
sources = []
|
1188
|
+
[defaultprovider, suitableprovider].flatten.uniq.collect do |provider|
|
1189
|
+
next if provider.nil?
|
1190
|
+
next if sources.include?(provider.source)
|
1191
|
+
|
1192
|
+
sources << provider.source
|
1193
|
+
provider
|
1194
|
+
end.compact
|
1195
|
+
end
|
1196
|
+
|
1197
|
+
# Converts a simple hash into a Resource instance.
|
1198
|
+
# @todo as opposed to a complex hash? Other raised exceptions?
|
1199
|
+
# @param [Hash{Symbol, String => Object}] hash resource attribute to value map to initialize the created resource from
|
1200
|
+
# @return [Puppet::Resource] the resource created from the hash
|
1201
|
+
# @raise [Puppet::Error] if a title is missing in the given hash
|
1202
|
+
def self.hash2resource(hash)
|
1203
|
+
hash = hash.inject({}) { |result, ary| result[ary[0].to_sym] = ary[1]; result }
|
1204
|
+
|
1205
|
+
title = hash.delete(:title)
|
1206
|
+
title ||= hash[:name]
|
1207
|
+
title ||= hash[key_attributes.first] if key_attributes.length == 1
|
1208
|
+
|
1209
|
+
raise Puppet::Error, "Title or name must be provided" unless title
|
1210
|
+
|
1211
|
+
# Now create our resource.
|
1212
|
+
resource = Puppet::Resource.new(self, title)
|
1213
|
+
resource.catalog = hash.delete(:catalog)
|
1214
|
+
|
1215
|
+
if sensitive = hash.delete(:sensitive_parameters)
|
1216
|
+
resource.sensitive_parameters = sensitive
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
hash.each do |param, value|
|
1220
|
+
resource[param] = value
|
1221
|
+
end
|
1222
|
+
resource
|
1223
|
+
end
|
1224
|
+
|
1225
|
+
|
1226
|
+
# Returns an array of strings representing the containment hierarchy
|
1227
|
+
# (types/classes) that make up the path to the resource from the root
|
1228
|
+
# of the catalog. This is mostly used for logging purposes.
|
1229
|
+
#
|
1230
|
+
# @api private
|
1231
|
+
def pathbuilder
|
1232
|
+
if p = parent
|
1233
|
+
[p.pathbuilder, self.ref].flatten
|
1234
|
+
else
|
1235
|
+
[self.ref]
|
1236
|
+
end
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
###############################
|
1240
|
+
# Add all of the meta-parameters.
|
1241
|
+
newmetaparam(:noop) do
|
1242
|
+
desc "Whether to apply this resource in noop mode.
|
1243
|
+
|
1244
|
+
When applying a resource in noop mode, Puppet will check whether it is in sync,
|
1245
|
+
like it does when running normally. However, if a resource attribute is not in
|
1246
|
+
the desired state (as declared in the catalog), Puppet will take no
|
1247
|
+
action, and will instead report the changes it _would_ have made. These
|
1248
|
+
simulated changes will appear in the report sent to the puppet master, or
|
1249
|
+
be shown on the console if running puppet agent or puppet apply in the
|
1250
|
+
foreground. The simulated changes will not send refresh events to any
|
1251
|
+
subscribing or notified resources, although Puppet will log that a refresh
|
1252
|
+
event _would_ have been sent.
|
1253
|
+
|
1254
|
+
**Important note:**
|
1255
|
+
[The `noop` setting](https://docs.puppetlabs.com/puppet/latest/reference/configuration.html#noop)
|
1256
|
+
allows you to globally enable or disable noop mode, but it will _not_ override
|
1257
|
+
the `noop` metaparameter on individual resources. That is, the value of the
|
1258
|
+
global `noop` setting will _only_ affect resources that do not have an explicit
|
1259
|
+
value set for their `noop` attribute."
|
1260
|
+
|
1261
|
+
newvalues(:true, :false)
|
1262
|
+
munge do |value|
|
1263
|
+
case value
|
1264
|
+
when true, :true, "true"; @resource.noop = true
|
1265
|
+
when false, :false, "false"; @resource.noop = false
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
newmetaparam(:schedule) do
|
1271
|
+
desc "A schedule to govern when Puppet is allowed to manage this resource.
|
1272
|
+
The value of this metaparameter must be the `name` of a `schedule`
|
1273
|
+
resource. This means you must declare a schedule resource, then
|
1274
|
+
refer to it by name; see
|
1275
|
+
[the docs for the `schedule` type](https://docs.puppetlabs.com/puppet/latest/reference/type.html#schedule)
|
1276
|
+
for more info.
|
1277
|
+
|
1278
|
+
schedule { 'everyday':
|
1279
|
+
period => daily,
|
1280
|
+
range => \"2-4\"
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
exec { \"/usr/bin/apt-get update\":
|
1284
|
+
schedule => 'everyday'
|
1285
|
+
}
|
1286
|
+
|
1287
|
+
Note that you can declare the schedule resource anywhere in your
|
1288
|
+
manifests, as long as it ends up in the final compiled catalog."
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
newmetaparam(:audit) do
|
1292
|
+
desc "Marks a subset of this resource's unmanaged attributes for auditing. Accepts an
|
1293
|
+
attribute name, an array of attribute names, or `all`.
|
1294
|
+
|
1295
|
+
Auditing a resource attribute has two effects: First, whenever a catalog
|
1296
|
+
is applied with puppet apply or puppet agent, Puppet will check whether
|
1297
|
+
that attribute of the resource has been modified, comparing its current
|
1298
|
+
value to the previous run; any change will be logged alongside any actions
|
1299
|
+
performed by Puppet while applying the catalog.
|
1300
|
+
|
1301
|
+
Secondly, marking a resource attribute for auditing will include that
|
1302
|
+
attribute in inspection reports generated by puppet inspect; see the
|
1303
|
+
puppet inspect documentation for more details.
|
1304
|
+
|
1305
|
+
Managed attributes for a resource can also be audited, but note that
|
1306
|
+
changes made by Puppet will be logged as additional modifications. (I.e.
|
1307
|
+
if a user manually edits a file whose contents are audited and managed,
|
1308
|
+
puppet agent's next two runs will both log an audit notice: the first run
|
1309
|
+
will log the user's edit and then revert the file to the desired state,
|
1310
|
+
and the second run will log the edit made by Puppet.)"
|
1311
|
+
|
1312
|
+
validate do |list|
|
1313
|
+
list = Array(list).collect {|p| p.to_sym}
|
1314
|
+
unless list == [:all]
|
1315
|
+
list.each do |param|
|
1316
|
+
next if @resource.class.validattr?(param)
|
1317
|
+
fail "Cannot audit #{param}: not a valid attribute for #{resource}"
|
1318
|
+
end
|
1319
|
+
end
|
1320
|
+
end
|
1321
|
+
|
1322
|
+
munge do |args|
|
1323
|
+
properties_to_audit(args).each do |param|
|
1324
|
+
next unless resource.class.validproperty?(param)
|
1325
|
+
resource.newattr(param)
|
1326
|
+
end
|
1327
|
+
end
|
1328
|
+
|
1329
|
+
def all_properties
|
1330
|
+
resource.class.properties.find_all do |property|
|
1331
|
+
resource.provider.nil? or resource.provider.class.supports_parameter?(property)
|
1332
|
+
end.collect do |property|
|
1333
|
+
property.name
|
1334
|
+
end
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
def properties_to_audit(list)
|
1338
|
+
if !list.kind_of?(Array) && list.to_sym == :all
|
1339
|
+
all_properties
|
1340
|
+
else
|
1341
|
+
Array(list).collect { |p| p.to_sym }
|
1342
|
+
end
|
1343
|
+
end
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
newmetaparam(:loglevel) do
|
1347
|
+
desc "Sets the level that information will be logged.
|
1348
|
+
The log levels have the biggest impact when logs are sent to
|
1349
|
+
syslog (which is currently the default).
|
1350
|
+
|
1351
|
+
The order of the log levels, in decreasing priority, is:
|
1352
|
+
|
1353
|
+
* `emerg`
|
1354
|
+
* `alert`
|
1355
|
+
* `crit`
|
1356
|
+
* `err`
|
1357
|
+
* `warning`
|
1358
|
+
* `notice`
|
1359
|
+
* `info` / `verbose`
|
1360
|
+
* `debug`
|
1361
|
+
"
|
1362
|
+
defaultto :notice
|
1363
|
+
|
1364
|
+
newvalues(*Puppet::Util::Log.levels)
|
1365
|
+
newvalues(:verbose)
|
1366
|
+
|
1367
|
+
munge do |loglevel|
|
1368
|
+
val = super(loglevel)
|
1369
|
+
if val == :verbose
|
1370
|
+
val = :info
|
1371
|
+
end
|
1372
|
+
val
|
1373
|
+
end
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
newmetaparam(:alias) do
|
1377
|
+
desc %q{Creates an alias for the resource. Puppet uses this internally when you
|
1378
|
+
provide a symbolic title and an explicit namevar value:
|
1379
|
+
|
1380
|
+
file { 'sshdconfig':
|
1381
|
+
path => $operatingsystem ? {
|
1382
|
+
solaris => '/usr/local/etc/ssh/sshd_config',
|
1383
|
+
default => '/etc/ssh/sshd_config',
|
1384
|
+
},
|
1385
|
+
source => '...'
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
service { 'sshd':
|
1389
|
+
subscribe => File['sshdconfig'],
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
When you use this feature, the parser sets `sshdconfig` as the title,
|
1393
|
+
and the library sets that as an alias for the file so the dependency
|
1394
|
+
lookup in `Service['sshd']` works. You can use this metaparameter yourself,
|
1395
|
+
but note that aliases generally only work for creating relationships; anything
|
1396
|
+
else that refers to an existing resource (such as amending or overriding
|
1397
|
+
resource attributes in an inherited class) must use the resource's exact
|
1398
|
+
title. For example, the following code will not work:
|
1399
|
+
|
1400
|
+
file { '/etc/ssh/sshd_config':
|
1401
|
+
owner => root,
|
1402
|
+
group => root,
|
1403
|
+
alias => 'sshdconfig',
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
File['sshdconfig'] {
|
1407
|
+
mode => '0644',
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
There's no way here for the Puppet parser to know that these two stanzas
|
1411
|
+
should be affecting the same file.
|
1412
|
+
|
1413
|
+
}
|
1414
|
+
|
1415
|
+
munge do |aliases|
|
1416
|
+
aliases = [aliases] unless aliases.is_a?(Array)
|
1417
|
+
|
1418
|
+
raise(ArgumentError, _("Cannot add aliases without a catalog")) unless @resource.catalog
|
1419
|
+
|
1420
|
+
aliases.each do |other|
|
1421
|
+
if obj = @resource.catalog.resource(@resource.class.name, other)
|
1422
|
+
unless obj.object_id == @resource.object_id
|
1423
|
+
self.fail("#{@resource.title} can not create alias #{other}: object already exists")
|
1424
|
+
end
|
1425
|
+
next
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
# Newschool, add it to the catalog.
|
1429
|
+
@resource.catalog.alias(@resource, other)
|
1430
|
+
end
|
1431
|
+
end
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
newmetaparam(:tag) do
|
1435
|
+
desc "Add the specified tags to the associated resource. While all resources
|
1436
|
+
are automatically tagged with as much information as possible
|
1437
|
+
(e.g., each class and definition containing the resource), it can
|
1438
|
+
be useful to add your own tags to a given resource.
|
1439
|
+
|
1440
|
+
Multiple tags can be specified as an array:
|
1441
|
+
|
1442
|
+
file {'/etc/hosts':
|
1443
|
+
ensure => file,
|
1444
|
+
source => 'puppet:///modules/site/hosts',
|
1445
|
+
mode => '0644',
|
1446
|
+
tag => ['bootstrap', 'minimumrun', 'mediumrun'],
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
Tags are useful for things like applying a subset of a host's configuration
|
1450
|
+
with [the `tags` setting](/puppet/latest/reference/configuration.html#tags)
|
1451
|
+
(e.g. `puppet agent --test --tags bootstrap`)."
|
1452
|
+
|
1453
|
+
munge do |tags|
|
1454
|
+
tags = [tags] unless tags.is_a? Array
|
1455
|
+
|
1456
|
+
tags.each do |tag|
|
1457
|
+
@resource.tag(tag)
|
1458
|
+
end
|
1459
|
+
end
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
# RelationshipMetaparam is an implementation supporting the meta-parameters `:require`, `:subscribe`,
|
1463
|
+
# `:notify`, and `:before`.
|
1464
|
+
#
|
1465
|
+
#
|
1466
|
+
class RelationshipMetaparam < Puppet::Parameter
|
1467
|
+
class << self
|
1468
|
+
attr_accessor :direction, :events, :callback, :subclasses
|
1469
|
+
end
|
1470
|
+
|
1471
|
+
@subclasses = []
|
1472
|
+
|
1473
|
+
def self.inherited(sub)
|
1474
|
+
@subclasses << sub
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
# @return [Array<Puppet::Resource>] turns attribute values into list of resources
|
1478
|
+
def munge(references)
|
1479
|
+
references = [references] unless references.is_a?(Array)
|
1480
|
+
references.collect do |ref|
|
1481
|
+
if ref.is_a?(Puppet::Resource)
|
1482
|
+
ref
|
1483
|
+
else
|
1484
|
+
Puppet::Resource.new(ref)
|
1485
|
+
end
|
1486
|
+
end
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
# Checks each reference to assert that what it references exists in the catalog.
|
1490
|
+
#
|
1491
|
+
# @raise [???fail] if the referenced resource can not be found
|
1492
|
+
# @return [void]
|
1493
|
+
def validate_relationship
|
1494
|
+
@value.each do |ref|
|
1495
|
+
unless @resource.catalog.resource(ref.to_s)
|
1496
|
+
description = self.class.direction == :in ? "dependency" : "dependent"
|
1497
|
+
fail ResourceError, _("Could not find %{description} %{ref} for %{resource}") %
|
1498
|
+
{ description: description, ref: ref, resource: resource.ref }
|
1499
|
+
end
|
1500
|
+
end
|
1501
|
+
end
|
1502
|
+
|
1503
|
+
# Creates edges for all relationships.
|
1504
|
+
# The `:in` relationships are specified by the event-receivers, and `:out`
|
1505
|
+
# relationships are specified by the event generator.
|
1506
|
+
# @todo references to "event-receivers" and "event generator" means in this context - are those just
|
1507
|
+
# the resources at the two ends of the relationship?
|
1508
|
+
# This way 'source' and 'target' are consistent terms in both edges
|
1509
|
+
# and events, i.e. an event targets edges whose source matches
|
1510
|
+
# the event's source. The direction of the relationship determines
|
1511
|
+
# which resource is applied first and which resource is considered
|
1512
|
+
# to be the event generator.
|
1513
|
+
# @return [Array<Puppet::Relationship>]
|
1514
|
+
# @raise [???fail] when a reference can not be resolved
|
1515
|
+
#
|
1516
|
+
def to_edges
|
1517
|
+
@value.collect do |reference|
|
1518
|
+
reference.catalog = resource.catalog
|
1519
|
+
|
1520
|
+
# Either of the two retrieval attempts could have returned
|
1521
|
+
# nil.
|
1522
|
+
unless related_resource = reference.resolve
|
1523
|
+
self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
|
1524
|
+
end
|
1525
|
+
|
1526
|
+
# Are we requiring them, or vice versa? See the method docs
|
1527
|
+
# for further info on this.
|
1528
|
+
if self.class.direction == :in
|
1529
|
+
source = related_resource
|
1530
|
+
target = @resource
|
1531
|
+
else
|
1532
|
+
source = @resource
|
1533
|
+
target = related_resource
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
if method = self.class.callback
|
1537
|
+
subargs = {
|
1538
|
+
:event => self.class.events,
|
1539
|
+
:callback => method
|
1540
|
+
}
|
1541
|
+
else
|
1542
|
+
# If there's no callback, there's no point in even adding
|
1543
|
+
# a label.
|
1544
|
+
subargs = nil
|
1545
|
+
end
|
1546
|
+
|
1547
|
+
## Corrected syntax of debug statement to reflect the way this was called.
|
1548
|
+
# i.e. before, after, subscribe, notify
|
1549
|
+
self.debug do
|
1550
|
+
relation = case self.class.name
|
1551
|
+
when "subscribe"
|
1552
|
+
"subscribes"
|
1553
|
+
when "notify"
|
1554
|
+
"notifies"
|
1555
|
+
else
|
1556
|
+
self.class.name
|
1557
|
+
end
|
1558
|
+
|
1559
|
+
"#{relation} to #{related_resource.ref}"
|
1560
|
+
end
|
1561
|
+
|
1562
|
+
Puppet::Relationship.new(source, target, subargs)
|
1563
|
+
end
|
1564
|
+
end
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
# @todo document this, have no clue what this does... it returns "RelationshipMetaparam.subclasses"
|
1568
|
+
#
|
1569
|
+
def self.relationship_params
|
1570
|
+
RelationshipMetaparam.subclasses
|
1571
|
+
end
|
1572
|
+
|
1573
|
+
|
1574
|
+
# Note that the order in which the relationships params is defined
|
1575
|
+
# matters. The labeled params (notify and subscribe) must be later,
|
1576
|
+
# so that if both params are used, those ones win. It's a hackish
|
1577
|
+
# solution, but it works.
|
1578
|
+
|
1579
|
+
newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
1580
|
+
desc "One or more resources that this resource depends on, expressed as
|
1581
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1582
|
+
Multiple resources can be specified as an array of references. When this
|
1583
|
+
attribute is present:
|
1584
|
+
|
1585
|
+
* The required resources will be applied **before** this resource.
|
1586
|
+
|
1587
|
+
This is one of the four relationship metaparameters, along with
|
1588
|
+
`before`, `notify`, and `subscribe`. For more context, including the
|
1589
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1590
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1591
|
+
end
|
1592
|
+
|
1593
|
+
newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1594
|
+
desc "One or more resources that this resource depends on, expressed as
|
1595
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1596
|
+
Multiple resources can be specified as an array of references. When this
|
1597
|
+
attribute is present:
|
1598
|
+
|
1599
|
+
* The subscribed resources will be applied _before_ this resource.
|
1600
|
+
* If Puppet makes changes to any of the subscribed resources, it will cause
|
1601
|
+
this resource to _refresh._ (Refresh behavior varies by resource
|
1602
|
+
type: services will restart, mounts will unmount and re-mount, etc. Not
|
1603
|
+
all types can refresh.)
|
1604
|
+
|
1605
|
+
This is one of the four relationship metaparameters, along with
|
1606
|
+
`before`, `require`, and `notify`. For more context, including the
|
1607
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1608
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1609
|
+
end
|
1610
|
+
|
1611
|
+
newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
1612
|
+
desc "One or more resources that depend on this resource, expressed as
|
1613
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1614
|
+
Multiple resources can be specified as an array of references. When this
|
1615
|
+
attribute is present:
|
1616
|
+
|
1617
|
+
* This resource will be applied _before_ the dependent resources.
|
1618
|
+
|
1619
|
+
This is one of the four relationship metaparameters, along with
|
1620
|
+
`require`, `notify`, and `subscribe`. For more context, including the
|
1621
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1622
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1626
|
+
desc "One or more resources that depend on this resource, expressed as
|
1627
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1628
|
+
Multiple resources can be specified as an array of references. When this
|
1629
|
+
attribute is present:
|
1630
|
+
|
1631
|
+
* This resource will be applied _before_ the notified resources.
|
1632
|
+
* If Puppet makes changes to this resource, it will cause all of the
|
1633
|
+
notified resources to _refresh._ (Refresh behavior varies by resource
|
1634
|
+
type: services will restart, mounts will unmount and re-mount, etc. Not
|
1635
|
+
all types can refresh.)
|
1636
|
+
|
1637
|
+
This is one of the four relationship metaparameters, along with
|
1638
|
+
`before`, `require`, and `subscribe`. For more context, including the
|
1639
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1640
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1641
|
+
end
|
1642
|
+
|
1643
|
+
newmetaparam(:stage) do
|
1644
|
+
desc %{Which run stage this class should reside in.
|
1645
|
+
|
1646
|
+
**Note: This metaparameter can only be used on classes,** and only when
|
1647
|
+
declaring them with the resource-like syntax. It cannot be used on normal
|
1648
|
+
resources or on classes declared with `include`.
|
1649
|
+
|
1650
|
+
By default, all classes are declared in the `main` stage. To assign a class
|
1651
|
+
to a different stage, you must:
|
1652
|
+
|
1653
|
+
* Declare the new stage as a [`stage` resource](https://docs.puppetlabs.com/puppet/latest/reference/type.html#stage).
|
1654
|
+
* Declare an order relationship between the new stage and the `main` stage.
|
1655
|
+
* Use the resource-like syntax to declare the class, and set the `stage`
|
1656
|
+
metaparameter to the name of the desired stage.
|
1657
|
+
|
1658
|
+
For example:
|
1659
|
+
|
1660
|
+
stage { 'pre':
|
1661
|
+
before => Stage['main'],
|
1662
|
+
}
|
1663
|
+
|
1664
|
+
class { 'apt-updates':
|
1665
|
+
stage => 'pre',
|
1666
|
+
}
|
1667
|
+
}
|
1668
|
+
end
|
1669
|
+
|
1670
|
+
newmetaparam(:export, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
1671
|
+
desc <<EOS
|
1672
|
+
Export a capability resource.
|
1673
|
+
|
1674
|
+
The value of this parameter must be a reference to a capability resource,
|
1675
|
+
or an array of such references. Each capability resource referenced here
|
1676
|
+
will be instantiated in the node catalog and exported to consumers of this
|
1677
|
+
resource. The title of the capability resource will be the title given in
|
1678
|
+
the reference, and all other attributes of the resource will be filled
|
1679
|
+
according to the corresponding produces statement.
|
1680
|
+
|
1681
|
+
It is an error if this metaparameter references resources whose type is not
|
1682
|
+
a capability type, or of there is no produces clause for the type of the
|
1683
|
+
current resource and the capability resource mentioned in this parameter.
|
1684
|
+
|
1685
|
+
For example:
|
1686
|
+
|
1687
|
+
define web(..) { .. }
|
1688
|
+
Web produces Http { .. }
|
1689
|
+
web { server:
|
1690
|
+
export => Http[main_server]
|
1691
|
+
}
|
1692
|
+
EOS
|
1693
|
+
end
|
1694
|
+
|
1695
|
+
newmetaparam(:consume, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
1696
|
+
desc <<EOS
|
1697
|
+
Consume a capability resource.
|
1698
|
+
|
1699
|
+
The value of this parameter must be a reference to a capability resource,
|
1700
|
+
or an array of such references. Each capability resource referenced here
|
1701
|
+
must have been exported by another resource in the same environment.
|
1702
|
+
|
1703
|
+
The referenced capability resources will be looked up, added to the
|
1704
|
+
current node catalog, and processed following the underlying consumes
|
1705
|
+
clause.
|
1706
|
+
|
1707
|
+
It is an error if this metaparameter references resources whose type is not
|
1708
|
+
a capability type, or of there is no consumes clause for the type of the
|
1709
|
+
current resource and the capability resource mentioned in this parameter.
|
1710
|
+
|
1711
|
+
For example:
|
1712
|
+
|
1713
|
+
define web(..) { .. }
|
1714
|
+
Web consumes Sql { .. }
|
1715
|
+
web { server:
|
1716
|
+
consume => Sql[my_db]
|
1717
|
+
}
|
1718
|
+
EOS
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
###############################
|
1722
|
+
# All of the provider plumbing for the resource types.
|
1723
|
+
require 'puppet/provider'
|
1724
|
+
require 'puppet/util/provider_features'
|
1725
|
+
|
1726
|
+
# Add the feature handling module.
|
1727
|
+
extend Puppet::Util::ProviderFeatures
|
1728
|
+
|
1729
|
+
# The provider that has been selected for the instance of the resource type.
|
1730
|
+
# @return [Puppet::Provider,nil] the selected provider or nil, if none has been selected
|
1731
|
+
#
|
1732
|
+
attr_reader :provider
|
1733
|
+
|
1734
|
+
# the Type class attribute accessors
|
1735
|
+
class << self
|
1736
|
+
# The loader of providers to use when loading providers from disk.
|
1737
|
+
# Although it looks like this attribute provides a way to operate with different loaders of
|
1738
|
+
# providers that is not the case; the attribute is written when a new type is created,
|
1739
|
+
# and should not be changed thereafter.
|
1740
|
+
# @api private
|
1741
|
+
#
|
1742
|
+
attr_accessor :providerloader
|
1743
|
+
|
1744
|
+
# @todo Don't know if this is a name, or a reference to a Provider instance (now marked up as an instance
|
1745
|
+
# of Provider.
|
1746
|
+
# @return [Puppet::Provider, nil] The default provider for this type, or nil if non is defines
|
1747
|
+
#
|
1748
|
+
attr_writer :defaultprovider
|
1749
|
+
end
|
1750
|
+
|
1751
|
+
# The default provider, or the most suitable provider if no default provider was set.
|
1752
|
+
# @note a warning will be issued if no default provider has been configured and a search for the most
|
1753
|
+
# suitable provider returns more than one equally suitable provider.
|
1754
|
+
# @return [Puppet::Provider, nil] the default or most suitable provider, or nil if no provider was found
|
1755
|
+
#
|
1756
|
+
def self.defaultprovider
|
1757
|
+
return @defaultprovider if @defaultprovider
|
1758
|
+
|
1759
|
+
suitable = suitableprovider
|
1760
|
+
|
1761
|
+
# Find which providers are a default for this system.
|
1762
|
+
defaults = suitable.find_all { |provider| provider.default? }
|
1763
|
+
|
1764
|
+
# If we don't have any default we use suitable providers
|
1765
|
+
defaults = suitable if defaults.empty?
|
1766
|
+
max = defaults.collect { |provider| provider.specificity }.max
|
1767
|
+
defaults = defaults.find_all { |provider| provider.specificity == max }
|
1768
|
+
|
1769
|
+
if defaults.length > 1
|
1770
|
+
Puppet.warning(_("Found multiple default providers for %{name}: %{provider_list}; using %{selected_provider}") %
|
1771
|
+
{ name: self.name, provider_list: defaults.collect { |i| i.name.to_s }.join(", "), selected_provider: defaults[0].name })
|
1772
|
+
end
|
1773
|
+
|
1774
|
+
@defaultprovider = defaults.shift unless defaults.empty?
|
1775
|
+
end
|
1776
|
+
|
1777
|
+
# @return [Hash{??? => Puppet::Provider}] Returns a hash of WHAT EXACTLY for the given type
|
1778
|
+
# @todo what goes into this hash?
|
1779
|
+
def self.provider_hash_by_type(type)
|
1780
|
+
@provider_hashes ||= {}
|
1781
|
+
@provider_hashes[type] ||= {}
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
# @return [Hash{ ??? => Puppet::Provider}] Returns a hash of WHAT EXACTLY for this type.
|
1785
|
+
# @see provider_hash_by_type method to get the same for some other type
|
1786
|
+
def self.provider_hash
|
1787
|
+
Puppet::Type.provider_hash_by_type(self.name)
|
1788
|
+
end
|
1789
|
+
|
1790
|
+
# Returns the provider having the given name.
|
1791
|
+
# This will load a provider if it is not already loaded. The returned provider is the first found provider
|
1792
|
+
# having the given name, where "first found" semantics is defined by the {providerloader} in use.
|
1793
|
+
#
|
1794
|
+
# @param name [String] the name of the provider to get
|
1795
|
+
# @return [Puppet::Provider, nil] the found provider, or nil if no provider of the given name was found
|
1796
|
+
#
|
1797
|
+
def self.provider(name)
|
1798
|
+
name = name.intern
|
1799
|
+
|
1800
|
+
# If we don't have it yet, try loading it.
|
1801
|
+
@providerloader.load(name) unless provider_hash.has_key?(name)
|
1802
|
+
provider_hash[name]
|
1803
|
+
end
|
1804
|
+
|
1805
|
+
# Returns a list of loaded providers by name.
|
1806
|
+
# This method will not load/search for available providers.
|
1807
|
+
# @return [Array<String>] list of loaded provider names
|
1808
|
+
#
|
1809
|
+
def self.providers
|
1810
|
+
provider_hash.keys
|
1811
|
+
end
|
1812
|
+
|
1813
|
+
# Returns true if the given name is a reference to a provider and if this is a suitable provider for
|
1814
|
+
# this type.
|
1815
|
+
# @todo How does the provider know if it is suitable for the type? Is it just suitable for the platform/
|
1816
|
+
# environment where this method is executing?
|
1817
|
+
# @param name [String] the name of the provider for which validity is checked
|
1818
|
+
# @return [Boolean] true if the given name references a provider that is suitable
|
1819
|
+
#
|
1820
|
+
def self.validprovider?(name)
|
1821
|
+
name = name.intern
|
1822
|
+
|
1823
|
+
(provider_hash.has_key?(name) && provider_hash[name].suitable?)
|
1824
|
+
end
|
1825
|
+
|
1826
|
+
# Creates a new provider of a type.
|
1827
|
+
# This method must be called directly on the type that it's implementing.
|
1828
|
+
# @todo Fix Confusing Explanations!
|
1829
|
+
# Is this a new provider of a Type (metatype), or a provider of an instance of Type (a resource), or
|
1830
|
+
# a Provider (the implementation of a Type's behavior). CONFUSED. It calls magically named methods like
|
1831
|
+
# "providify" ...
|
1832
|
+
# @param name [String, Symbol] the name of the WHAT? provider? type?
|
1833
|
+
# @param options [Hash{Symbol => Object}] a hash of options, used by this method, and passed on to {#genclass}, (see
|
1834
|
+
# it for additional options to pass).
|
1835
|
+
# @option options [Puppet::Provider] :parent the parent provider (what is this?)
|
1836
|
+
# @option options [Puppet::Type] :resource_type the resource type, defaults to this type if unspecified
|
1837
|
+
# @return [Puppet::Provider] a provider ???
|
1838
|
+
# @raise [Puppet::DevError] when the parent provider could not be found.
|
1839
|
+
#
|
1840
|
+
def self.provide(name, options = {}, &block)
|
1841
|
+
name = name.intern
|
1842
|
+
|
1843
|
+
if unprovide(name)
|
1844
|
+
Puppet.debug "Reloading #{name} #{self.name} provider"
|
1845
|
+
end
|
1846
|
+
|
1847
|
+
parent = if pname = options[:parent]
|
1848
|
+
options.delete(:parent)
|
1849
|
+
if pname.is_a? Class
|
1850
|
+
pname
|
1851
|
+
else
|
1852
|
+
if provider = self.provider(pname)
|
1853
|
+
provider
|
1854
|
+
else
|
1855
|
+
raise Puppet::DevError, _("Could not find parent provider %{parent} of %{name}") % { parent: pname, name: name }
|
1856
|
+
end
|
1857
|
+
end
|
1858
|
+
else
|
1859
|
+
Puppet::Provider
|
1860
|
+
end
|
1861
|
+
|
1862
|
+
options[:resource_type] ||= self
|
1863
|
+
|
1864
|
+
self.providify
|
1865
|
+
|
1866
|
+
provider = genclass(
|
1867
|
+
name,
|
1868
|
+
:parent => parent,
|
1869
|
+
:hash => provider_hash,
|
1870
|
+
:prefix => "Provider",
|
1871
|
+
:block => block,
|
1872
|
+
:include => feature_module,
|
1873
|
+
:extend => feature_module,
|
1874
|
+
:attributes => options
|
1875
|
+
)
|
1876
|
+
|
1877
|
+
provider
|
1878
|
+
end
|
1879
|
+
|
1880
|
+
# Ensures there is a `:provider` parameter defined.
|
1881
|
+
# Should only be called if there are providers.
|
1882
|
+
# @return [void]
|
1883
|
+
def self.providify
|
1884
|
+
return if @paramhash.has_key? :provider
|
1885
|
+
|
1886
|
+
param = newparam(:provider) do
|
1887
|
+
# We're using a hacky way to get the name of our type, since there doesn't
|
1888
|
+
# seem to be a correct way to introspect this at the time this code is run.
|
1889
|
+
# We expect that the class in which this code is executed will be something
|
1890
|
+
# like Puppet::Type::Ssh_authorized_key::ParameterProvider.
|
1891
|
+
desc <<-EOT
|
1892
|
+
The specific backend to use for this `#{self.to_s.split('::')[2].downcase}`
|
1893
|
+
resource. You will seldom need to specify this --- Puppet will usually
|
1894
|
+
discover the appropriate provider for your platform.
|
1895
|
+
EOT
|
1896
|
+
|
1897
|
+
# This is so we can refer back to the type to get a list of
|
1898
|
+
# providers for documentation.
|
1899
|
+
class << self
|
1900
|
+
# The reference to a parent type for the parameter `:provider` used to get a list of
|
1901
|
+
# providers for documentation purposes.
|
1902
|
+
#
|
1903
|
+
attr_accessor :parenttype
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
# Provides the ability to add documentation to a provider.
|
1907
|
+
#
|
1908
|
+
def self.doc
|
1909
|
+
# Since we're mixing @doc with text from other sources, we must normalize
|
1910
|
+
# its indentation with scrub. But we don't need to manually scrub the
|
1911
|
+
# provider's doc string, since markdown_definitionlist sanitizes its inputs.
|
1912
|
+
scrub(@doc) + "Available providers are:\n\n" + parenttype.providers.sort { |a,b|
|
1913
|
+
a.to_s <=> b.to_s
|
1914
|
+
}.collect { |i|
|
1915
|
+
markdown_definitionlist( i, scrub(parenttype().provider(i).doc) )
|
1916
|
+
}.join
|
1917
|
+
end
|
1918
|
+
|
1919
|
+
# For each resource, the provider param defaults to
|
1920
|
+
# the type's default provider
|
1921
|
+
defaultto {
|
1922
|
+
prov = @resource.class.defaultprovider
|
1923
|
+
prov.name if prov
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
validate do |provider_class|
|
1927
|
+
provider_class = provider_class[0] if provider_class.is_a? Array
|
1928
|
+
provider_class = provider_class.class.name if provider_class.is_a?(Puppet::Provider)
|
1929
|
+
|
1930
|
+
unless @resource.class.provider(provider_class)
|
1931
|
+
raise ArgumentError, _("Invalid %{resource} provider '%{provider_class}'") % { resource: @resource.class.name, provider_class: provider_class}
|
1932
|
+
end
|
1933
|
+
end
|
1934
|
+
|
1935
|
+
munge do |provider|
|
1936
|
+
provider = provider[0] if provider.is_a? Array
|
1937
|
+
provider = provider.intern if provider.is_a? String
|
1938
|
+
@resource.provider = provider
|
1939
|
+
|
1940
|
+
if provider.is_a?(Puppet::Provider)
|
1941
|
+
provider.class.name
|
1942
|
+
else
|
1943
|
+
provider
|
1944
|
+
end
|
1945
|
+
end
|
1946
|
+
end
|
1947
|
+
param.parenttype = self
|
1948
|
+
end
|
1949
|
+
|
1950
|
+
# @todo this needs a better explanation
|
1951
|
+
# Removes the implementation class of a given provider.
|
1952
|
+
# @return [Object] returns what {Puppet::Util::ClassGen#rmclass} returns
|
1953
|
+
def self.unprovide(name)
|
1954
|
+
if @defaultprovider and @defaultprovider.name == name
|
1955
|
+
@defaultprovider = nil
|
1956
|
+
end
|
1957
|
+
|
1958
|
+
rmclass(name, :hash => provider_hash, :prefix => "Provider")
|
1959
|
+
end
|
1960
|
+
|
1961
|
+
# Returns a list of suitable providers for the given type.
|
1962
|
+
# A call to this method will load all providers if not already loaded and ask each if it is
|
1963
|
+
# suitable - those that are are included in the result.
|
1964
|
+
# @note This method also does some special processing which rejects a provider named `:fake` (for testing purposes).
|
1965
|
+
# @return [Array<Puppet::Provider>] Returns an array of all suitable providers.
|
1966
|
+
#
|
1967
|
+
def self.suitableprovider
|
1968
|
+
providerloader.loadall if provider_hash.empty?
|
1969
|
+
provider_hash.find_all { |name, provider|
|
1970
|
+
provider.suitable?
|
1971
|
+
}.collect { |name, provider|
|
1972
|
+
provider
|
1973
|
+
}.reject { |p| p.name == :fake } # For testing
|
1974
|
+
end
|
1975
|
+
|
1976
|
+
# @return [Boolean] Returns true if this is something else than a `:provider`, or if it
|
1977
|
+
# is a provider and it is suitable, or if there is a default provider. Otherwise, false is returned.
|
1978
|
+
#
|
1979
|
+
def suitable?
|
1980
|
+
# If we don't use providers, then we consider it suitable.
|
1981
|
+
return true unless self.class.paramclass(:provider)
|
1982
|
+
|
1983
|
+
# We have a provider and it is suitable.
|
1984
|
+
return true if provider && provider.class.suitable?
|
1985
|
+
|
1986
|
+
# We're using the default provider and there is one.
|
1987
|
+
if !provider and self.class.defaultprovider
|
1988
|
+
self.provider = self.class.defaultprovider.name
|
1989
|
+
return true
|
1990
|
+
end
|
1991
|
+
|
1992
|
+
# We specified an unsuitable provider, or there isn't any suitable
|
1993
|
+
# provider.
|
1994
|
+
false
|
1995
|
+
end
|
1996
|
+
|
1997
|
+
# Sets the provider to the given provider/name.
|
1998
|
+
# @overload provider=(name)
|
1999
|
+
# Sets the provider to the result of resolving the name to an instance of Provider.
|
2000
|
+
# @param name [String] the name of the provider
|
2001
|
+
# @overload provider=(provider)
|
2002
|
+
# Sets the provider to the given instances of Provider.
|
2003
|
+
# @param provider [Puppet::Provider] the provider to set
|
2004
|
+
# @return [Puppet::Provider] the provider set
|
2005
|
+
# @raise [ArgumentError] if the provider could not be found/resolved.
|
2006
|
+
#
|
2007
|
+
def provider=(name)
|
2008
|
+
if name.is_a?(Puppet::Provider)
|
2009
|
+
@provider = name
|
2010
|
+
@provider.resource = self
|
2011
|
+
elsif klass = self.class.provider(name)
|
2012
|
+
@provider = klass.new(self)
|
2013
|
+
else
|
2014
|
+
raise ArgumentError, _("Could not find %{name} provider of %{provider}") % { name: name, provider: self.class.name }
|
2015
|
+
end
|
2016
|
+
end
|
2017
|
+
|
2018
|
+
###############################
|
2019
|
+
# All of the relationship code.
|
2020
|
+
|
2021
|
+
# Adds a block producing a single name (or list of names) of the given
|
2022
|
+
# resource type name to autorelate.
|
2023
|
+
#
|
2024
|
+
# The four relationship types require, before, notify, and subscribe are all
|
2025
|
+
# supported.
|
2026
|
+
#
|
2027
|
+
# Be *careful* with notify and subscribe as they may have unintended
|
2028
|
+
# consequences.
|
2029
|
+
#
|
2030
|
+
# Resources in the catalog that have the named type and a title that is
|
2031
|
+
# included in the result will be linked to the calling resource as a
|
2032
|
+
# requirement.
|
2033
|
+
#
|
2034
|
+
# @example Autorequire the files File['foo', 'bar']
|
2035
|
+
# autorequire( 'file', {|| ['foo', 'bar'] })
|
2036
|
+
#
|
2037
|
+
# @example Autobefore the files File['foo', 'bar']
|
2038
|
+
# autobefore( 'file', {|| ['foo', 'bar'] })
|
2039
|
+
#
|
2040
|
+
# @example Autosubscribe the files File['foo', 'bar']
|
2041
|
+
# autosubscribe( 'file', {|| ['foo', 'bar'] })
|
2042
|
+
#
|
2043
|
+
# @example Autonotify the files File['foo', 'bar']
|
2044
|
+
# autonotify( 'file', {|| ['foo', 'bar'] })
|
2045
|
+
#
|
2046
|
+
# @param name [String] the name of a type of which one or several resources should be autorelated e.g. "file"
|
2047
|
+
# @yield [ ] a block returning list of names of given type to auto require
|
2048
|
+
# @yieldreturn [String, Array<String>] one or several resource names for the named type
|
2049
|
+
# @return [void]
|
2050
|
+
# @dsl type
|
2051
|
+
# @api public
|
2052
|
+
#
|
2053
|
+
def self.autorequire(name, &block)
|
2054
|
+
@autorequires ||= {}
|
2055
|
+
@autorequires[name] = block
|
2056
|
+
end
|
2057
|
+
|
2058
|
+
def self.autobefore(name, &block)
|
2059
|
+
@autobefores ||= {}
|
2060
|
+
@autobefores[name] = block
|
2061
|
+
end
|
2062
|
+
|
2063
|
+
def self.autosubscribe(name, &block)
|
2064
|
+
@autosubscribes ||= {}
|
2065
|
+
@autosubscribes[name] = block
|
2066
|
+
end
|
2067
|
+
|
2068
|
+
def self.autonotify(name, &block)
|
2069
|
+
@autonotifies ||= {}
|
2070
|
+
@autonotifies[name] = block
|
2071
|
+
end
|
2072
|
+
|
2073
|
+
# Provides iteration over added auto-requirements (see {autorequire}).
|
2074
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2075
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autorequire}).
|
2076
|
+
# @yieldreturn [void]
|
2077
|
+
# @return [void]
|
2078
|
+
def self.eachautorequire
|
2079
|
+
@autorequires ||= {}
|
2080
|
+
@autorequires.each { |type, block|
|
2081
|
+
yield(type, block)
|
2082
|
+
}
|
2083
|
+
end
|
2084
|
+
|
2085
|
+
# Provides iteration over added auto-requirements (see {autobefore}).
|
2086
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2087
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autobefore}).
|
2088
|
+
# @yieldreturn [void]
|
2089
|
+
# @return [void]
|
2090
|
+
def self.eachautobefore
|
2091
|
+
@autobefores ||= {}
|
2092
|
+
@autobefores.each { |type,block|
|
2093
|
+
yield(type, block)
|
2094
|
+
}
|
2095
|
+
end
|
2096
|
+
|
2097
|
+
# Provides iteration over added auto-requirements (see {autosubscribe}).
|
2098
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2099
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autosubscribe}).
|
2100
|
+
# @yieldreturn [void]
|
2101
|
+
# @return [void]
|
2102
|
+
def self.eachautosubscribe
|
2103
|
+
@autosubscribes ||= {}
|
2104
|
+
@autosubscribes.each { |type,block|
|
2105
|
+
yield(type, block)
|
2106
|
+
}
|
2107
|
+
end
|
2108
|
+
|
2109
|
+
# Provides iteration over added auto-requirements (see {autonotify}).
|
2110
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2111
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autonotify}).
|
2112
|
+
# @yieldreturn [void]
|
2113
|
+
# @return [void]
|
2114
|
+
def self.eachautonotify
|
2115
|
+
@autonotifies ||= {}
|
2116
|
+
@autonotifies.each { |type,block|
|
2117
|
+
yield(type, block)
|
2118
|
+
}
|
2119
|
+
end
|
2120
|
+
|
2121
|
+
# Adds dependencies to the catalog from added autorelations.
|
2122
|
+
# See {autorequire} for how to add an auto-requirement.
|
2123
|
+
# @todo needs details - see the param rel_catalog, and type of this param
|
2124
|
+
# @param rel_catalog [Puppet::Resource::Catalog, nil] the catalog to
|
2125
|
+
# add dependencies to. Defaults to the current catalog (set when the
|
2126
|
+
# type instance was added to a catalog)
|
2127
|
+
# @raise [Puppet::DevError] if there is no catalog
|
2128
|
+
#
|
2129
|
+
def autorelation(rel_type, rel_catalog = nil)
|
2130
|
+
rel_catalog ||= catalog
|
2131
|
+
raise Puppet::DevError, _("You cannot add relationships without a catalog") unless rel_catalog
|
2132
|
+
|
2133
|
+
reqs = []
|
2134
|
+
|
2135
|
+
auto_rel = "eachauto#{rel_type}".to_sym
|
2136
|
+
|
2137
|
+
self.class.send(auto_rel) { |type, block|
|
2138
|
+
# Ignore any types we can't find, although that would be a bit odd.
|
2139
|
+
next unless Puppet::Type.type(type)
|
2140
|
+
|
2141
|
+
# Retrieve the list of names from the block.
|
2142
|
+
next unless list = self.instance_eval(&block)
|
2143
|
+
list = [list] unless list.is_a?(Array)
|
2144
|
+
|
2145
|
+
# Collect the current prereqs
|
2146
|
+
list.each { |dep|
|
2147
|
+
next if dep.nil?
|
2148
|
+
|
2149
|
+
# Support them passing objects directly, to save some effort.
|
2150
|
+
unless dep.is_a?(Puppet::Type)
|
2151
|
+
# Skip autorelation that we aren't managing
|
2152
|
+
unless dep = rel_catalog.resource(type, dep)
|
2153
|
+
next
|
2154
|
+
end
|
2155
|
+
end
|
2156
|
+
|
2157
|
+
if [:require, :subscribe].include?(rel_type)
|
2158
|
+
reqs << Puppet::Relationship.new(dep, self)
|
2159
|
+
else
|
2160
|
+
reqs << Puppet::Relationship.new(self, dep)
|
2161
|
+
end
|
2162
|
+
}
|
2163
|
+
}
|
2164
|
+
|
2165
|
+
reqs
|
2166
|
+
end
|
2167
|
+
|
2168
|
+
def autorequire(rel_catalog = nil)
|
2169
|
+
autorelation(:require, rel_catalog)
|
2170
|
+
end
|
2171
|
+
|
2172
|
+
def autobefore(rel_catalog = nil)
|
2173
|
+
autorelation(:before, rel_catalog)
|
2174
|
+
end
|
2175
|
+
|
2176
|
+
def autosubscribe(rel_catalog = nil)
|
2177
|
+
autorelation(:subscribe, rel_catalog)
|
2178
|
+
end
|
2179
|
+
|
2180
|
+
def autonotify(rel_catalog = nil)
|
2181
|
+
autorelation(:notify, rel_catalog)
|
2182
|
+
end
|
2183
|
+
|
2184
|
+
# Builds the dependencies associated with this resource.
|
2185
|
+
#
|
2186
|
+
# @return [Array<Puppet::Relationship>] list of relationships to other resources
|
2187
|
+
def builddepends
|
2188
|
+
# Handle the requires
|
2189
|
+
self.class.relationship_params.collect do |klass|
|
2190
|
+
if param = @parameters[klass.name]
|
2191
|
+
param.to_edges
|
2192
|
+
end
|
2193
|
+
end.flatten.reject { |r| r.nil? }
|
2194
|
+
end
|
2195
|
+
|
2196
|
+
# Sets the initial list of tags to associate to this resource.
|
2197
|
+
#
|
2198
|
+
# @return [void] ???
|
2199
|
+
def tags=(list)
|
2200
|
+
tag(self.class.name)
|
2201
|
+
tag(*list)
|
2202
|
+
end
|
2203
|
+
|
2204
|
+
# @comment - these two comments were floating around here, and turned up as documentation
|
2205
|
+
# for the attribute "title", much to my surprise and amusement. Clearly these comments
|
2206
|
+
# are orphaned ... I think they can just be removed as what they say should be covered
|
2207
|
+
# by the now added yardoc. <irony>(Yo! to quote some of the other actual awesome specific comments applicable
|
2208
|
+
# to objects called from elsewhere, or not. ;-)</irony>
|
2209
|
+
#
|
2210
|
+
# @comment Types (which map to resources in the languages) are entirely composed of
|
2211
|
+
# attribute value pairs. Generally, Puppet calls any of these things an
|
2212
|
+
# 'attribute', but these attributes always take one of three specific
|
2213
|
+
# forms: parameters, metaparams, or properties.
|
2214
|
+
|
2215
|
+
# @comment In naming methods, I have tried to consistently name the method so
|
2216
|
+
# that it is clear whether it operates on all attributes (thus has 'attr' in
|
2217
|
+
# the method name, or whether it operates on a specific type of attributes.
|
2218
|
+
|
2219
|
+
# The title attribute of WHAT ???
|
2220
|
+
# @todo Figure out what this is the title attribute of (it appears on line 1926 currently).
|
2221
|
+
# @return [String] the title
|
2222
|
+
attr_writer :title
|
2223
|
+
|
2224
|
+
# The noop attribute of WHAT ??? does WHAT???
|
2225
|
+
# @todo Figure out what this is the noop attribute of (it appears on line 1931 currently).
|
2226
|
+
# @return [???] the noop WHAT ??? (mode? if so of what, or noop for an instance of the type, or for all
|
2227
|
+
# instances of a type, or for what???
|
2228
|
+
#
|
2229
|
+
attr_writer :noop
|
2230
|
+
|
2231
|
+
include Enumerable
|
2232
|
+
|
2233
|
+
# class methods dealing with Type management
|
2234
|
+
|
2235
|
+
# The Type class attribute accessors
|
2236
|
+
class << self
|
2237
|
+
# @return [String] the name of the resource type; e.g., "File"
|
2238
|
+
#
|
2239
|
+
attr_reader :name
|
2240
|
+
|
2241
|
+
# @return [Boolean] true if the type should send itself a refresh event on change.
|
2242
|
+
#
|
2243
|
+
attr_accessor :self_refresh
|
2244
|
+
include Enumerable, Puppet::Util::ClassGen
|
2245
|
+
include Puppet::MetaType::Manager
|
2246
|
+
|
2247
|
+
include Puppet::Util
|
2248
|
+
include Puppet::Util::Logging
|
2249
|
+
end
|
2250
|
+
|
2251
|
+
# Initializes all of the variables that must be initialized for each subclass.
|
2252
|
+
# @todo Does the explanation make sense?
|
2253
|
+
# @return [void]
|
2254
|
+
def self.initvars
|
2255
|
+
# all of the instances of this class
|
2256
|
+
@objects = Hash.new
|
2257
|
+
@aliases = Hash.new
|
2258
|
+
|
2259
|
+
@defaults = {}
|
2260
|
+
|
2261
|
+
@parameters ||= []
|
2262
|
+
|
2263
|
+
@validproperties = {}
|
2264
|
+
@properties = []
|
2265
|
+
@parameters = []
|
2266
|
+
@paramhash = {}
|
2267
|
+
|
2268
|
+
@paramdoc = Hash.new { |hash,key|
|
2269
|
+
key = key.intern if key.is_a?(String)
|
2270
|
+
if hash.include?(key)
|
2271
|
+
hash[key]
|
2272
|
+
else
|
2273
|
+
"Param Documentation for #{key} not found"
|
2274
|
+
end
|
2275
|
+
}
|
2276
|
+
|
2277
|
+
@doc ||= ""
|
2278
|
+
|
2279
|
+
end
|
2280
|
+
|
2281
|
+
# Returns the name of this type (if specified) or the parent type #to_s.
|
2282
|
+
# The returned name is on the form "Puppet::Type::<name>", where the first letter of name is
|
2283
|
+
# capitalized.
|
2284
|
+
# @return [String] the fully qualified name Puppet::Type::<name> where the first letter of name is capitalized
|
2285
|
+
#
|
2286
|
+
def self.to_s
|
2287
|
+
if defined?(@name)
|
2288
|
+
"Puppet::Type::#{@name.to_s.capitalize}"
|
2289
|
+
else
|
2290
|
+
super
|
2291
|
+
end
|
2292
|
+
end
|
2293
|
+
|
2294
|
+
# Creates a `validate` method that is used to validate a resource before it is operated on.
|
2295
|
+
# The validation should raise exceptions if the validation finds errors. (It is not recommended to
|
2296
|
+
# issue warnings as this typically just ends up in a logfile - you should fail if a validation fails).
|
2297
|
+
# The easiest way to raise an appropriate exception is to call the method {Puppet::Util::Errors.fail} with
|
2298
|
+
# the message as an argument.
|
2299
|
+
#
|
2300
|
+
# @yield [ ] a required block called with self set to the instance of a Type class representing a resource.
|
2301
|
+
# @return [void]
|
2302
|
+
# @dsl type
|
2303
|
+
# @api public
|
2304
|
+
#
|
2305
|
+
def self.validate(&block)
|
2306
|
+
define_method(:validate, &block)
|
2307
|
+
end
|
2308
|
+
|
2309
|
+
# @return [String] The file from which this type originates from
|
2310
|
+
attr_accessor :file
|
2311
|
+
|
2312
|
+
# @return [Integer] The line in {#file} from which this type originates from
|
2313
|
+
attr_accessor :line
|
2314
|
+
|
2315
|
+
# @todo what does this mean "this resource" (sounds like this if for an instance of the type, not the meta Type),
|
2316
|
+
# but not sure if this is about the catalog where the meta Type is included)
|
2317
|
+
# @return [??? TODO] The catalog that this resource is stored in.
|
2318
|
+
attr_accessor :catalog
|
2319
|
+
|
2320
|
+
# @return [Boolean] Flag indicating if this type is exported
|
2321
|
+
attr_accessor :exported
|
2322
|
+
|
2323
|
+
# @return [Boolean] Flag indicating if the type is virtual (it should not be).
|
2324
|
+
attr_accessor :virtual
|
2325
|
+
|
2326
|
+
# Creates a log entry with the given message at the log level specified by the parameter `loglevel`
|
2327
|
+
# @return [void]
|
2328
|
+
#
|
2329
|
+
def log(msg)
|
2330
|
+
|
2331
|
+
Puppet::Util::Log.create(
|
2332
|
+
|
2333
|
+
:level => @parameters[:loglevel].value,
|
2334
|
+
:message => msg,
|
2335
|
+
|
2336
|
+
:source => self
|
2337
|
+
)
|
2338
|
+
end
|
2339
|
+
|
2340
|
+
|
2341
|
+
# instance methods related to instance intrinsics
|
2342
|
+
# e.g., initialize and name
|
2343
|
+
|
2344
|
+
# @return [Hash] hash of parameters originally defined
|
2345
|
+
# @api private
|
2346
|
+
attr_reader :original_parameters
|
2347
|
+
|
2348
|
+
# Creates an instance of Type from a hash or a {Puppet::Resource}.
|
2349
|
+
# @todo Unclear if this is a new Type or a new instance of a given type (the initialization ends
|
2350
|
+
# with calling validate - which seems like validation of an instance of a given type, not a new
|
2351
|
+
# meta type.
|
2352
|
+
#
|
2353
|
+
# @todo Explain what the Hash and Resource are. There seems to be two different types of
|
2354
|
+
# resources; one that causes the title to be set to resource.title, and one that
|
2355
|
+
# causes the title to be resource.ref ("for components") - what is a component?
|
2356
|
+
#
|
2357
|
+
# @overload initialize(hash)
|
2358
|
+
# @param [Hash] hash
|
2359
|
+
# @raise [Puppet::ResourceError] when the type validation raises
|
2360
|
+
# Puppet::Error or ArgumentError
|
2361
|
+
# @overload initialize(resource)
|
2362
|
+
# @param resource [Puppet:Resource]
|
2363
|
+
# @raise [Puppet::ResourceError] when the type validation raises
|
2364
|
+
# Puppet::Error or ArgumentError
|
2365
|
+
#
|
2366
|
+
def initialize(resource)
|
2367
|
+
resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
|
2368
|
+
|
2369
|
+
# The list of parameter/property instances.
|
2370
|
+
@parameters = {}
|
2371
|
+
|
2372
|
+
# Set the title first, so any failures print correctly.
|
2373
|
+
if resource.type.to_s.downcase.to_sym == self.class.name
|
2374
|
+
self.title = resource.title
|
2375
|
+
else
|
2376
|
+
# This should only ever happen for components
|
2377
|
+
self.title = resource.ref
|
2378
|
+
end
|
2379
|
+
|
2380
|
+
[:file, :line, :catalog, :exported, :virtual].each do |getter|
|
2381
|
+
setter = getter.to_s + "="
|
2382
|
+
if val = resource.send(getter)
|
2383
|
+
self.send(setter, val)
|
2384
|
+
end
|
2385
|
+
end
|
2386
|
+
|
2387
|
+
merge_tags_from(resource)
|
2388
|
+
|
2389
|
+
@original_parameters = resource.to_hash
|
2390
|
+
|
2391
|
+
set_name(@original_parameters)
|
2392
|
+
|
2393
|
+
set_default(:provider)
|
2394
|
+
|
2395
|
+
set_parameters(@original_parameters)
|
2396
|
+
|
2397
|
+
begin
|
2398
|
+
self.validate if self.respond_to?(:validate)
|
2399
|
+
rescue Puppet::Error, ArgumentError => detail
|
2400
|
+
error = Puppet::ResourceError.new("Validation of #{ref} failed: #{detail}")
|
2401
|
+
adderrorcontext(error, detail)
|
2402
|
+
raise error
|
2403
|
+
end
|
2404
|
+
|
2405
|
+
set_sensitive_parameters(resource.sensitive_parameters)
|
2406
|
+
end
|
2407
|
+
|
2408
|
+
protected
|
2409
|
+
|
2410
|
+
# Mark parameters associated with this type as sensitive, based on the associated resource.
|
2411
|
+
#
|
2412
|
+
# Currently, only instances of `Puppet::Property` can be easily marked for sensitive data handling
|
2413
|
+
# and information redaction is limited to redacting events generated while synchronizing
|
2414
|
+
# properties. While support for redaction will be broadened in the future we can't automatically
|
2415
|
+
# deduce how to redact arbitrary parameters, so if a parameter is marked for redaction the best
|
2416
|
+
# we can do is warn that we can't handle treating that parameter as sensitive and move on.
|
2417
|
+
#
|
2418
|
+
# In some unusual cases a given parameter will be marked as sensitive but that sensitive context
|
2419
|
+
# needs to be transferred to another parameter. In this case resource types may need to override
|
2420
|
+
# this method in order to copy the sensitive context from one parameter to another (and in the
|
2421
|
+
# process force the early generation of a parameter that might otherwise be lazily generated.)
|
2422
|
+
# See `Puppet::Type.type(:file)#set_sensitive_parameters` for an example of this.
|
2423
|
+
#
|
2424
|
+
# @note This method visibility is protected since it should only be called by #initialize, but is
|
2425
|
+
# marked as public as subclasses may need to override this method.
|
2426
|
+
#
|
2427
|
+
# @api public
|
2428
|
+
#
|
2429
|
+
# @param sensitive_parameters [Array<Symbol>] A list of parameters to mark as sensitive.
|
2430
|
+
#
|
2431
|
+
# @return [void]
|
2432
|
+
def set_sensitive_parameters(sensitive_parameters)
|
2433
|
+
sensitive_parameters.each do |name|
|
2434
|
+
p = parameter(name)
|
2435
|
+
if p.is_a?(Puppet::Property)
|
2436
|
+
p.sensitive = true
|
2437
|
+
elsif p.is_a?(Puppet::Parameter)
|
2438
|
+
warning(_("Unable to mark '%{name}' as sensitive: %{name} is a parameter and not a property, and cannot be automatically redacted.") %
|
2439
|
+
{ name: name })
|
2440
|
+
elsif self.class.attrclass(name)
|
2441
|
+
warning(_("Unable to mark '%{name}' as sensitive: the property itself was not assigned a value.") % { name: name })
|
2442
|
+
else
|
2443
|
+
err(_("Unable to mark '%{name}' as sensitive: the property itself is not defined on %{type}.") % { name: name, type: type })
|
2444
|
+
end
|
2445
|
+
end
|
2446
|
+
end
|
2447
|
+
|
2448
|
+
private
|
2449
|
+
|
2450
|
+
# Sets the name of the resource from a hash containing a mapping of `name_var` to value.
|
2451
|
+
# Sets the value of the property/parameter appointed by the `name_var` (if it is defined). The value set is
|
2452
|
+
# given by the corresponding entry in the given hash - e.g. if name_var appoints the name `:path` the value
|
2453
|
+
# of `:path` is set to the value at the key `:path` in the given hash. As a side effect this key/value is then
|
2454
|
+
# removed from the given hash.
|
2455
|
+
#
|
2456
|
+
# @note This method mutates the given hash by removing the entry with a key equal to the value
|
2457
|
+
# returned from name_var!
|
2458
|
+
# @param hash [Hash] a hash of what
|
2459
|
+
# @return [void]
|
2460
|
+
def set_name(hash)
|
2461
|
+
self[name_var] = hash.delete(name_var) if name_var
|
2462
|
+
end
|
2463
|
+
|
2464
|
+
# Sets parameters from the given hash.
|
2465
|
+
# Values are set in _attribute order_ i.e. higher priority attributes before others, otherwise in
|
2466
|
+
# the order they were specified (as opposed to just setting them in the order they happen to appear in
|
2467
|
+
# when iterating over the given hash).
|
2468
|
+
#
|
2469
|
+
# Attributes that are not included in the given hash are set to their default value.
|
2470
|
+
#
|
2471
|
+
# @todo Is this description accurate? Is "ensure" an example of such a higher priority attribute?
|
2472
|
+
# @return [void]
|
2473
|
+
# @raise [Puppet::DevError] when impossible to set the value due to some problem
|
2474
|
+
# @raise [ArgumentError, TypeError, Puppet::Error] when faulty arguments have been passed
|
2475
|
+
#
|
2476
|
+
def set_parameters(hash)
|
2477
|
+
# Use the order provided by allattrs, but add in any
|
2478
|
+
# extra attributes from the resource so we get failures
|
2479
|
+
# on invalid attributes.
|
2480
|
+
no_values = []
|
2481
|
+
(self.class.allattrs + hash.keys).uniq.each do |attr|
|
2482
|
+
begin
|
2483
|
+
# Set any defaults immediately. This is mostly done so
|
2484
|
+
# that the default provider is available for any other
|
2485
|
+
# property validation.
|
2486
|
+
if hash.has_key?(attr)
|
2487
|
+
self[attr] = hash[attr]
|
2488
|
+
else
|
2489
|
+
no_values << attr
|
2490
|
+
end
|
2491
|
+
rescue ArgumentError, Puppet::Error, TypeError
|
2492
|
+
raise
|
2493
|
+
rescue => detail
|
2494
|
+
error = Puppet::DevError.new(_("Could not set %{attribute} on %{class_name}: %{detail}") % { attribute: attr, class_name: self.class.name, detail: detail })
|
2495
|
+
error.set_backtrace(detail.backtrace)
|
2496
|
+
raise error
|
2497
|
+
end
|
2498
|
+
end
|
2499
|
+
no_values.each do |attr|
|
2500
|
+
set_default(attr)
|
2501
|
+
end
|
2502
|
+
end
|
2503
|
+
|
2504
|
+
public
|
2505
|
+
|
2506
|
+
# Finishes any outstanding processing.
|
2507
|
+
# This method should be called as a final step in setup,
|
2508
|
+
# to allow the parameters that have associated auto-require needs to be processed.
|
2509
|
+
#
|
2510
|
+
# @todo what is the expected sequence here - who is responsible for calling this? When?
|
2511
|
+
# Is the returned type correct?
|
2512
|
+
# @return [Array<Puppet::Parameter>] the validated list/set of attributes
|
2513
|
+
#
|
2514
|
+
def finish
|
2515
|
+
# Call post_compile hook on every parameter that implements it. This includes all subclasses
|
2516
|
+
# of parameter including, but not limited to, regular parameters, metaparameters, relationship
|
2517
|
+
# parameters, and properties.
|
2518
|
+
eachparameter do |parameter|
|
2519
|
+
parameter.post_compile if parameter.respond_to? :post_compile
|
2520
|
+
end
|
2521
|
+
|
2522
|
+
# Make sure all of our relationships are valid. Again, must be done
|
2523
|
+
# when the entire catalog is instantiated.
|
2524
|
+
self.class.relationship_params.collect do |klass|
|
2525
|
+
if param = @parameters[klass.name]
|
2526
|
+
param.validate_relationship
|
2527
|
+
end
|
2528
|
+
end.flatten.reject { |r| r.nil? }
|
2529
|
+
end
|
2530
|
+
|
2531
|
+
# @comment For now, leave the 'name' method functioning like it used to. Once 'title'
|
2532
|
+
# works everywhere, I'll switch it.
|
2533
|
+
# Returns the resource's name
|
2534
|
+
# @todo There is a comment in source that this is not quite the same as ':title' and that a switch should
|
2535
|
+
# be made...
|
2536
|
+
# @return [String] the name of a resource
|
2537
|
+
def name
|
2538
|
+
self[:name]
|
2539
|
+
end
|
2540
|
+
|
2541
|
+
# Returns the parent of this in the catalog. In case of an erroneous catalog
|
2542
|
+
# where multiple parents have been produced, the first found (non
|
2543
|
+
# deterministic) parent is returned.
|
2544
|
+
# @return [Puppet::Type, nil] the
|
2545
|
+
# containing resource or nil if there is no catalog or no containing
|
2546
|
+
# resource.
|
2547
|
+
def parent
|
2548
|
+
return nil unless catalog
|
2549
|
+
|
2550
|
+
@parent ||=
|
2551
|
+
if parents = catalog.adjacent(self, :direction => :in)
|
2552
|
+
parents.shift
|
2553
|
+
else
|
2554
|
+
nil
|
2555
|
+
end
|
2556
|
+
end
|
2557
|
+
|
2558
|
+
# Returns a reference to this as a string in "Type[name]" format.
|
2559
|
+
# @return [String] a reference to this object on the form 'Type[name]'
|
2560
|
+
#
|
2561
|
+
def ref
|
2562
|
+
# memoizing this is worthwhile ~ 3 percent of calls are the "first time
|
2563
|
+
# around" in an average run of Puppet. --daniel 2012-07-17
|
2564
|
+
@ref ||= "#{self.class.name.to_s.capitalize}[#{self.title}]"
|
2565
|
+
end
|
2566
|
+
|
2567
|
+
# (see self_refresh)
|
2568
|
+
# @todo check that meaningful yardoc is produced - this method delegates to "self.class.self_refresh"
|
2569
|
+
# @return [Boolean] - ??? returns true when ... what?
|
2570
|
+
#
|
2571
|
+
def self_refresh?
|
2572
|
+
self.class.self_refresh
|
2573
|
+
end
|
2574
|
+
|
2575
|
+
# Marks the object as "being purged".
|
2576
|
+
# This method is used by transactions to forbid deletion when there are dependencies.
|
2577
|
+
# @todo what does this mean; "mark that we are purging" (purging what from where). How to use/when?
|
2578
|
+
# Is this internal API in transactions?
|
2579
|
+
# @see purging?
|
2580
|
+
def purging
|
2581
|
+
@purging = true
|
2582
|
+
end
|
2583
|
+
|
2584
|
+
# Returns whether this resource is being purged or not.
|
2585
|
+
# This method is used by transactions to forbid deletion when there are dependencies.
|
2586
|
+
# @return [Boolean] the current "purging" state
|
2587
|
+
#
|
2588
|
+
def purging?
|
2589
|
+
if defined?(@purging)
|
2590
|
+
@purging
|
2591
|
+
else
|
2592
|
+
false
|
2593
|
+
end
|
2594
|
+
end
|
2595
|
+
|
2596
|
+
# Returns the title of this object, or its name if title was not explicitly set.
|
2597
|
+
# If the title is not already set, it will be computed by looking up the {#name_var} and using
|
2598
|
+
# that value as the title.
|
2599
|
+
# @todo it is somewhat confusing that if the name_var is a valid parameter, it is assumed to
|
2600
|
+
# be the name_var called :name, but if it is a property, it uses the name_var.
|
2601
|
+
# It is further confusing as Type in some respects supports multiple namevars.
|
2602
|
+
#
|
2603
|
+
# @return [String] Returns the title of this object, or its name if title was not explicitly set.
|
2604
|
+
# @raise [??? devfail] if title is not set, and name_var can not be found.
|
2605
|
+
def title
|
2606
|
+
unless @title
|
2607
|
+
if self.class.validparameter?(name_var)
|
2608
|
+
@title = self[:name]
|
2609
|
+
elsif self.class.validproperty?(name_var)
|
2610
|
+
@title = self.should(name_var)
|
2611
|
+
else
|
2612
|
+
self.devfail "Could not find namevar #{name_var} for #{self.class.name}"
|
2613
|
+
end
|
2614
|
+
end
|
2615
|
+
|
2616
|
+
@title
|
2617
|
+
end
|
2618
|
+
|
2619
|
+
# Produces a reference to this in reference format.
|
2620
|
+
# @see #ref
|
2621
|
+
#
|
2622
|
+
def to_s
|
2623
|
+
self.ref
|
2624
|
+
end
|
2625
|
+
|
2626
|
+
# Convert this resource type instance to a Puppet::Resource.
|
2627
|
+
# @return [Puppet::Resource] Returns a serializable representation of this resource
|
2628
|
+
#
|
2629
|
+
def to_resource
|
2630
|
+
resource = self.retrieve_resource
|
2631
|
+
resource.merge_tags_from(self)
|
2632
|
+
|
2633
|
+
@parameters.each do |name, param|
|
2634
|
+
# Avoid adding each instance name twice
|
2635
|
+
next if param.class.isnamevar? and param.value == self.title
|
2636
|
+
|
2637
|
+
# We've already got property values
|
2638
|
+
next if param.is_a?(Puppet::Property)
|
2639
|
+
resource[name] = param.value
|
2640
|
+
end
|
2641
|
+
|
2642
|
+
resource
|
2643
|
+
end
|
2644
|
+
|
2645
|
+
# @return [Boolean] Returns whether the resource is virtual or not
|
2646
|
+
def virtual?; !!@virtual; end
|
2647
|
+
# @return [Boolean] Returns whether the resource is exported or not
|
2648
|
+
def exported?; !!@exported; end
|
2649
|
+
|
2650
|
+
# @return [Boolean] Returns whether the resource is applicable to `:device`
|
2651
|
+
# Returns true if a resource of this type can be evaluated on a 'network device' kind
|
2652
|
+
# of hosts.
|
2653
|
+
# @api private
|
2654
|
+
def appliable_to_device?
|
2655
|
+
self.class.can_apply_to(:device)
|
2656
|
+
end
|
2657
|
+
|
2658
|
+
# @return [Boolean] Returns whether the resource is applicable to `:host`
|
2659
|
+
# Returns true if a resource of this type can be evaluated on a regular generalized computer (ie not an appliance like a network device)
|
2660
|
+
# @api private
|
2661
|
+
def appliable_to_host?
|
2662
|
+
self.class.can_apply_to(:host)
|
2663
|
+
end
|
2664
|
+
end
|
2665
|
+
end
|