bolt 0.0.1 → 0.5.0
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/.gitignore +33 -0
- data/.gitmodules +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +61 -0
- data/.travis.yml +18 -0
- data/Gemfile +9 -0
- data/INSTALL.md +70 -0
- data/LICENSE +201 -0
- data/README.md +372 -0
- data/Rakefile +27 -0
- data/Vagrantfile +13 -0
- data/appveyor.yml +29 -0
- data/bolt.gemspec +50 -0
- data/docs/writing_tasks_and_plans.pdf +0 -0
- data/exe/bolt +15 -0
- data/lib/bolt.rb +13 -0
- data/lib/bolt/cli.rb +409 -0
- data/lib/bolt/executor.rb +71 -0
- data/lib/bolt/node.rb +79 -0
- data/lib/bolt/node/formatter.rb +15 -0
- data/lib/bolt/node/orch.rb +118 -0
- data/lib/bolt/node/result.rb +110 -0
- data/lib/bolt/node/ssh.rb +145 -0
- data/lib/bolt/node/winrm.rb +237 -0
- data/lib/bolt/node_uri.rb +42 -0
- data/lib/bolt/result.rb +139 -0
- data/lib/bolt/version.rb +3 -0
- data/metadata.json +13 -0
- data/tasks/init.json +3 -0
- data/tasks/init.rb +44 -0
- data/ux/bolt-CLI-spec.md +186 -0
- 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 +328 -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 +81 -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 +311 -0
- data/vendored/puppet/lib/puppet/agent.rb +114 -0
- data/vendored/puppet/lib/puppet/agent/disabler.rb +53 -0
- data/vendored/puppet/lib/puppet/agent/locker.rb +52 -0
- data/vendored/puppet/lib/puppet/application.rb +485 -0
- data/vendored/puppet/lib/puppet/application/agent.rb +468 -0
- data/vendored/puppet/lib/puppet/application/apply.rb +358 -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 +334 -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 +4 -0
- data/vendored/puppet/lib/puppet/application/describe.rb +258 -0
- data/vendored/puppet/lib/puppet/application/device.rb +292 -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 +4 -0
- data/vendored/puppet/lib/puppet/application/filebucket.rb +262 -0
- data/vendored/puppet/lib/puppet/application/generate.rb +5 -0
- data/vendored/puppet/lib/puppet/application/help.rb +4 -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 +361 -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 +255 -0
- data/vendored/puppet/lib/puppet/application/status.rb +4 -0
- data/vendored/puppet/lib/puppet/application_support.rb +57 -0
- data/vendored/puppet/lib/puppet/bindings.rb +147 -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 +447 -0
- data/vendored/puppet/lib/puppet/configurer/downloader.rb +67 -0
- data/vendored/puppet/lib/puppet/configurer/downloader_factory.rb +34 -0
- data/vendored/puppet/lib/puppet/configurer/fact_handler.rb +46 -0
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +25 -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/defaults.rb +1957 -0
- data/vendored/puppet/lib/puppet/environments.rb +509 -0
- data/vendored/puppet/lib/puppet/error.rb +117 -0
- data/vendored/puppet/lib/puppet/etc.rb +161 -0
- data/vendored/puppet/lib/puppet/external/dot.rb +326 -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/grammar.ry +248 -0
- data/vendored/puppet/lib/puppet/external/nagios/makefile +9 -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 +119 -0
- data/vendored/puppet/lib/puppet/face/epp.rb +527 -0
- data/vendored/puppet/lib/puppet/face/facts.rb +38 -0
- data/vendored/puppet/lib/puppet/face/generate.rb +64 -0
- data/vendored/puppet/lib/puppet/face/help.rb +205 -0
- data/vendored/puppet/lib/puppet/face/help/action.erb +86 -0
- data/vendored/puppet/lib/puppet/face/help/face.erb +114 -0
- data/vendored/puppet/lib/puppet/face/help/global.erb +16 -0
- data/vendored/puppet/lib/puppet/face/help/man.erb +152 -0
- data/vendored/puppet/lib/puppet/face/key.rb +16 -0
- data/vendored/puppet/lib/puppet/face/man.rb +101 -0
- data/vendored/puppet/lib/puppet/face/module.rb +19 -0
- data/vendored/puppet/lib/puppet/face/module/build.rb +63 -0
- data/vendored/puppet/lib/puppet/face/module/changes.rb +42 -0
- data/vendored/puppet/lib/puppet/face/module/generate.rb +251 -0
- data/vendored/puppet/lib/puppet/face/module/install.rb +149 -0
- data/vendored/puppet/lib/puppet/face/module/list.rb +279 -0
- data/vendored/puppet/lib/puppet/face/module/search.rb +94 -0
- data/vendored/puppet/lib/puppet/face/module/uninstall.rb +81 -0
- data/vendored/puppet/lib/puppet/face/module/upgrade.rb +90 -0
- data/vendored/puppet/lib/puppet/face/node.rb +42 -0
- data/vendored/puppet/lib/puppet/face/node/clean.rb +96 -0
- data/vendored/puppet/lib/puppet/face/parser.rb +161 -0
- data/vendored/puppet/lib/puppet/face/plugin.rb +58 -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 +50 -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 +174 -0
- data/vendored/puppet/lib/puppet/file_bucket/file.rb +131 -0
- data/vendored/puppet/lib/puppet/file_serving.rb +3 -0
- data/vendored/puppet/lib/puppet/file_serving/base.rb +85 -0
- data/vendored/puppet/lib/puppet/file_serving/configuration.rb +112 -0
- data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +123 -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/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 +229 -0
- data/vendored/puppet/lib/puppet/forge/cache.rb +60 -0
- data/vendored/puppet/lib/puppet/forge/errors.rb +112 -0
- data/vendored/puppet/lib/puppet/forge/repository.rb +155 -0
- data/vendored/puppet/lib/puppet/functions.rb +745 -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 +19 -0
- data/vendored/puppet/lib/puppet/functions/break.rb +22 -0
- data/vendored/puppet/lib/puppet/functions/call.rb +42 -0
- data/vendored/puppet/lib/puppet/functions/contain.rb +39 -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 +160 -0
- data/vendored/puppet/lib/puppet/functions/dig.rb +23 -0
- data/vendored/puppet/lib/puppet/functions/each.rb +163 -0
- data/vendored/puppet/lib/puppet/functions/emerg.rb +14 -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 +94 -0
- data/vendored/puppet/lib/puppet/functions/file_upload.rb +48 -0
- data/vendored/puppet/lib/puppet/functions/filter.rb +143 -0
- data/vendored/puppet/lib/puppet/functions/find_file.rb +31 -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 +27 -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/json_data.rb +33 -0
- data/vendored/puppet/lib/puppet/functions/lest.rb +17 -0
- data/vendored/puppet/lib/puppet/functions/lookup.rb +223 -0
- data/vendored/puppet/lib/puppet/functions/map.rb +126 -0
- data/vendored/puppet/lib/puppet/functions/match.rb +120 -0
- data/vendored/puppet/lib/puppet/functions/new.rb +32 -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 +76 -0
- data/vendored/puppet/lib/puppet/functions/require.rb +43 -0
- data/vendored/puppet/lib/puppet/functions/return.rb +22 -0
- data/vendored/puppet/lib/puppet/functions/reverse_each.rb +25 -0
- data/vendored/puppet/lib/puppet/functions/run_command.rb +41 -0
- data/vendored/puppet/lib/puppet/functions/run_plan.rb +40 -0
- data/vendored/puppet/lib/puppet/functions/run_script.rb +50 -0
- data/vendored/puppet/lib/puppet/functions/run_task.rb +73 -0
- data/vendored/puppet/lib/puppet/functions/scanf.rb +44 -0
- data/vendored/puppet/lib/puppet/functions/slice.rb +111 -0
- data/vendored/puppet/lib/puppet/functions/split.rb +47 -0
- data/vendored/puppet/lib/puppet/functions/step.rb +26 -0
- data/vendored/puppet/lib/puppet/functions/strftime.rb +43 -0
- data/vendored/puppet/lib/puppet/functions/then.rb +14 -0
- data/vendored/puppet/lib/puppet/functions/tree_each.rb +200 -0
- data/vendored/puppet/lib/puppet/functions/type.rb +31 -0
- data/vendored/puppet/lib/puppet/functions/unique.rb +132 -0
- data/vendored/puppet/lib/puppet/functions/unwrap.rb +40 -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 +30 -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/templates/type/pcore.erb +42 -0
- data/vendored/puppet/lib/puppet/generate/type.rb +239 -0
- data/vendored/puppet/lib/puppet/gettext/config.rb +70 -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 +277 -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 +384 -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 +90 -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/store_configs.rb +11 -0
- data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +86 -0
- data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +255 -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 +15 -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 +336 -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 +259 -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 +37 -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 +274 -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 +348 -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 +236 -0
- data/vendored/puppet/lib/puppet/interface/action.rb +374 -0
- data/vendored/puppet/lib/puppet/interface/action_builder.rb +149 -0
- data/vendored/puppet/lib/puppet/interface/action_manager.rb +97 -0
- data/vendored/puppet/lib/puppet/interface/documentation.rb +342 -0
- data/vendored/puppet/lib/puppet/interface/face_collection.rb +130 -0
- data/vendored/puppet/lib/puppet/interface/option.rb +150 -0
- data/vendored/puppet/lib/puppet/interface/option_builder.rb +91 -0
- data/vendored/puppet/lib/puppet/interface/option_manager.rb +99 -0
- data/vendored/puppet/lib/puppet/loaders.rb +26 -0
- data/vendored/puppet/lib/puppet/metatype/manager.rb +195 -0
- data/vendored/puppet/lib/puppet/module.rb +473 -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 +148 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +62 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +352 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/searcher.rb +29 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +118 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +100 -0
- data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +278 -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 +95 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +190 -0
- data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +49 -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 +224 -0
- data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +180 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.fixtures.yml.erb +7 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.gitignore +18 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.rubocop.yml +42 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/.yardopts +1 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +18 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +89 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +32 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/examples/init.pp.erb +12 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +48 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
- data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +6 -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 +53 -0
- data/vendored/puppet/lib/puppet/network.rb +3 -0
- data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +85 -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 +278 -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 +82 -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 +47 -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 +125 -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 +86 -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 +262 -0
- data/vendored/puppet/lib/puppet/node/environment.rb +572 -0
- data/vendored/puppet/lib/puppet/node/facts.rb +128 -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 +788 -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 +278 -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 +21 -0
- data/vendored/puppet/lib/puppet/parser/functions/generate.rb +38 -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 +27 -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 +1006 -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/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 +36 -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 +35 -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 +418 -0
- data/vendored/puppet/lib/puppet/parser/resource/param.rb +22 -0
- data/vendored/puppet/lib/puppet/parser/scope.rb +1112 -0
- data/vendored/puppet/lib/puppet/parser/script_compiler.rb +117 -0
- data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +101 -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 +706 -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 +233 -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 +94 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +1258 -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 +200 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +117 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +538 -0
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +100 -0
- data/vendored/puppet/lib/puppet/pops/functions/dispatcher.rb +71 -0
- data/vendored/puppet/lib/puppet/pops/functions/function.rb +135 -0
- data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +115 -0
- data/vendored/puppet/lib/puppet/pops/issues.rb +888 -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 +204 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +296 -0
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +452 -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_function_instantiator.rb +46 -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 +164 -0
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +117 -0
- data/vendored/puppet/lib/puppet/pops/loader/type_definition_instantiator.rb +97 -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 +517 -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 +594 -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 +472 -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 +434 -0
- data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +58 -0
- data/vendored/puppet/lib/puppet/pops/model/ast.pp +695 -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 +1145 -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 +463 -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/egrammar.ra +937 -0
- data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +3347 -0
- data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +51 -0
- data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +262 -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 +796 -0
- data/vendored/puppet/lib/puppet/pops/parser/lexer_support.rb +220 -0
- data/vendored/puppet/lib/puppet/pops/parser/locatable.rb +23 -0
- data/vendored/puppet/lib/puppet/pops/parser/locator.rb +344 -0
- data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +247 -0
- data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +120 -0
- data/vendored/puppet/lib/puppet/pops/patterns.rb +60 -0
- data/vendored/puppet/lib/puppet/pops/pcore.rb +107 -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/resource/resource_type_set.pcore +22 -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 +176 -0
- data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +215 -0
- data/vendored/puppet/lib/puppet/pops/serialization/deserializer.rb +80 -0
- data/vendored/puppet/lib/puppet/pops/serialization/extension.rb +157 -0
- data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +169 -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 +126 -0
- data/vendored/puppet/lib/puppet/pops/serialization/object.rb +71 -0
- data/vendored/puppet/lib/puppet/pops/serialization/serializer.rb +139 -0
- data/vendored/puppet/lib/puppet/pops/serialization/time_factory.rb +67 -0
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +301 -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 +129 -0
- data/vendored/puppet/lib/puppet/pops/types/enumeration.rb +16 -0
- data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +126 -0
- data/vendored/puppet/lib/puppet/pops/types/implementation_registry.rb +141 -0
- data/vendored/puppet/lib/puppet/pops/types/iterable.rb +330 -0
- data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +226 -0
- data/vendored/puppet/lib/puppet/pops/types/p_error_type.rb +146 -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 +90 -0
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +976 -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 +191 -0
- data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_type.rb +141 -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 +361 -0
- data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +30 -0
- data/vendored/puppet/lib/puppet/pops/types/recursion_guard.rb +136 -0
- data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +432 -0
- data/vendored/puppet/lib/puppet/pops/types/ruby_method.rb +31 -0
- data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +1102 -0
- data/vendored/puppet/lib/puppet/pops/types/task.rb +116 -0
- data/vendored/puppet/lib/puppet/pops/types/tree_iterators.rb +250 -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 +799 -0
- data/vendored/puppet/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +599 -0
- data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +769 -0
- data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +1062 -0
- data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +602 -0
- data/vendored/puppet/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/vendored/puppet/lib/puppet/pops/types/types.rb +3519 -0
- data/vendored/puppet/lib/puppet/pops/utils.rb +119 -0
- data/vendored/puppet/lib/puppet/pops/validation.rb +464 -0
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +996 -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 +600 -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 +603 -0
- data/vendored/puppet/lib/puppet/provider/aixobject.rb +392 -0
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +567 -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 +98 -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 +141 -0
- data/vendored/puppet/lib/puppet/provider/group/directoryservice.rb +22 -0
- data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +85 -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 +109 -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 +59 -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 +317 -0
- data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +507 -0
- data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +33 -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 +110 -0
- data/vendored/puppet/lib/puppet/provider/package/apple.rb +47 -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 +283 -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 +249 -0
- data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +152 -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 +301 -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 +278 -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 +138 -0
- data/vendored/puppet/lib/puppet/provider/service/base.rb +121 -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 +193 -0
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +346 -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 +71 -0
- data/vendored/puppet/lib/puppet/provider/service/runit.rb +111 -0
- data/vendored/puppet/lib/puppet/provider/service/service.rb +42 -0
- data/vendored/puppet/lib/puppet/provider/service/smf.rb +167 -0
- data/vendored/puppet/lib/puppet/provider/service/src.rb +147 -0
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +186 -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 +375 -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 +75 -0
- data/vendored/puppet/lib/puppet/provider/user/pw.rb +98 -0
- data/vendored/puppet/lib/puppet/provider/user/user_role_add.rb +227 -0
- data/vendored/puppet/lib/puppet/provider/user/useradd.rb +231 -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 +304 -0
- data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +84 -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 +82 -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 +114 -0
- data/vendored/puppet/lib/puppet/relationship.rb +88 -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 +669 -0
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +147 -0
- data/vendored/puppet/lib/puppet/resource/catalog.rb +667 -0
- data/vendored/puppet/lib/puppet/resource/status.rb +221 -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 +1457 -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 +177 -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 +143 -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 +204 -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 +200 -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 +46 -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 +153 -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 +327 -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 +27 -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 +187 -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 +41 -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 +417 -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 +84 -0
- data/vendored/puppet/lib/puppet/transaction/report.rb +460 -0
- data/vendored/puppet/lib/puppet/transaction/resource_harness.rb +318 -0
- data/vendored/puppet/lib/puppet/type.rb +2664 -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 +475 -0
- data/vendored/puppet/lib/puppet/type/exec.rb +622 -0
- data/vendored/puppet/lib/puppet/type/file.rb +1039 -0
- data/vendored/puppet/lib/puppet/type/file/checksum.rb +44 -0
- data/vendored/puppet/lib/puppet/type/file/checksum_value.rb +53 -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 +92 -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 +206 -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 +88 -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 +310 -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 +469 -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 +336 -0
- data/vendored/puppet/lib/puppet/type/user.rb +770 -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 +409 -0
- data/vendored/puppet/lib/puppet/type/zfs.rb +150 -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 +705 -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 +158 -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 +282 -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 +185 -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 +824 -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 +108 -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 +377 -0
- data/vendored/puppet/lib/puppet/util/filetype.rb +309 -0
- data/vendored/puppet/lib/puppet/util/http_proxy.rb +197 -0
- data/vendored/puppet/lib/puppet/util/inifile.rb +341 -0
- data/vendored/puppet/lib/puppet/util/instance_loader.rb +81 -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 +278 -0
- data/vendored/puppet/lib/puppet/util/libuser.conf +15 -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 +423 -0
- data/vendored/puppet/lib/puppet/util/log/destination.rb +49 -0
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +249 -0
- data/vendored/puppet/lib/puppet/util/logging.rb +318 -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 +98 -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 +22 -0
- data/vendored/puppet/lib/puppet/util/plist.rb +153 -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 +126 -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 +33 -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 +548 -0
- data/vendored/puppet/lib/puppet/util/windows/api_types.rb +282 -0
- data/vendored/puppet/lib/puppet/util/windows/com.rb +224 -0
- data/vendored/puppet/lib/puppet/util/windows/error.rb +83 -0
- data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +192 -0
- data/vendored/puppet/lib/puppet/util/windows/file.rb +488 -0
- data/vendored/puppet/lib/puppet/util/windows/principal.rb +191 -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 +231 -0
- data/vendored/puppet/lib/puppet/util/windows/string.rb +16 -0
- data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +1276 -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/CHANGELOG +45 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/Gemfile +3 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/LICENSE +21 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/PUPPET_README.md +6 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/README.md +113 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/Rakefile +19 -0
- data/vendored/puppet/lib/puppet/vendor/deep_merge/deep_merge.gemspec +35 -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/CHANGELOG.md +2 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/LICENSE +201 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/PUPPET_README.md +6 -0
- data/vendored/puppet/lib/puppet/vendor/pathspec/README.md +53 -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 +7 -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/vendor/semantic_puppet/locales/config.yaml +21 -0
- data/vendored/puppet/lib/puppet/version.rb +93 -0
- data/vendored/puppet/lib/puppet_pal.rb +290 -0
- data/vendored/puppet/lib/puppet_x.rb +14 -0
- data/vendored/require_vendored.rb +11 -0
- metadata +1501 -9
@@ -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,2664 @@
|
|
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 value(s).
|
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,
|
504
|
+
"Options must be a hash, not #{options.inspect}"
|
505
|
+
end
|
506
|
+
|
507
|
+
raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" if @validproperties.include?(name)
|
508
|
+
|
509
|
+
if parent = options[:parent]
|
510
|
+
options.delete(:parent)
|
511
|
+
else
|
512
|
+
parent = Puppet::Property
|
513
|
+
end
|
514
|
+
|
515
|
+
# We have to create our own, new block here because we want to define
|
516
|
+
# an initial :retrieve method, if told to, and then eval the passed
|
517
|
+
# block if available.
|
518
|
+
prop = genclass(name, :parent => parent, :hash => @validproperties, :attributes => options) do
|
519
|
+
# If they've passed a retrieve method, then override the retrieve
|
520
|
+
# method on the class.
|
521
|
+
if options[:retrieve]
|
522
|
+
define_method(:retrieve) do
|
523
|
+
provider.send(options[:retrieve])
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
class_eval(&block) if block
|
528
|
+
end
|
529
|
+
|
530
|
+
# If it's the 'ensure' property, always put it first.
|
531
|
+
if name == :ensure
|
532
|
+
@properties.unshift prop
|
533
|
+
else
|
534
|
+
@properties << prop
|
535
|
+
end
|
536
|
+
|
537
|
+
prop
|
538
|
+
end
|
539
|
+
|
540
|
+
def self.paramdoc(param)
|
541
|
+
@paramhash[param].doc
|
542
|
+
end
|
543
|
+
|
544
|
+
# @return [Array<String>] Returns the parameter names
|
545
|
+
def self.parameters
|
546
|
+
return [] unless defined?(@parameters)
|
547
|
+
@parameters.collect { |klass| klass.name }
|
548
|
+
end
|
549
|
+
|
550
|
+
# @return [Puppet::Parameter] Returns the parameter class associated with the given parameter name.
|
551
|
+
def self.paramclass(name)
|
552
|
+
@paramhash[name]
|
553
|
+
end
|
554
|
+
|
555
|
+
# @return [Puppet::Property] Returns the property class ??? associated with the given property name
|
556
|
+
def self.propertybyname(name)
|
557
|
+
@validproperties[name]
|
558
|
+
end
|
559
|
+
|
560
|
+
# Returns whether or not the given name is the name of a property, parameter or meta-parameter
|
561
|
+
# @return [Boolean] true if the given attribute name is the name of an existing property, parameter or meta-parameter
|
562
|
+
#
|
563
|
+
def self.validattr?(name)
|
564
|
+
name = name.intern
|
565
|
+
return true if name == :name
|
566
|
+
@validattrs ||= {}
|
567
|
+
|
568
|
+
unless @validattrs.include?(name)
|
569
|
+
@validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name))
|
570
|
+
end
|
571
|
+
|
572
|
+
@validattrs[name]
|
573
|
+
end
|
574
|
+
|
575
|
+
# @return [Boolean] Returns true if the given name is the name of an existing property
|
576
|
+
def self.validproperty?(name)
|
577
|
+
name = name.intern
|
578
|
+
@validproperties.include?(name) && @validproperties[name]
|
579
|
+
end
|
580
|
+
|
581
|
+
# @return [Array<Symbol>, {}] Returns a list of valid property names, or an empty hash if there are none.
|
582
|
+
# @todo An empty hash is returned if there are no defined parameters (not an empty array). This looks like
|
583
|
+
# a bug.
|
584
|
+
#
|
585
|
+
def self.validproperties
|
586
|
+
return {} unless defined?(@parameters)
|
587
|
+
|
588
|
+
@validproperties.keys
|
589
|
+
end
|
590
|
+
|
591
|
+
# @return [Boolean] Returns true if the given name is the name of an existing parameter
|
592
|
+
def self.validparameter?(name)
|
593
|
+
raise Puppet::DevError, "Class #{self} has not defined parameters" unless defined?(@parameters)
|
594
|
+
!!(@paramhash.include?(name) or @@metaparamhash.include?(name))
|
595
|
+
end
|
596
|
+
|
597
|
+
# (see validattr?)
|
598
|
+
# @note see comment in code - how should this be documented? Are some of the other query methods deprecated?
|
599
|
+
# (or should be).
|
600
|
+
# @comment This is a forward-compatibility method - it's the validity interface we'll use in Puppet::Resource.
|
601
|
+
def self.valid_parameter?(name)
|
602
|
+
validattr?(name)
|
603
|
+
end
|
604
|
+
|
605
|
+
# @return [Boolean] Returns true if the wanted state of the resource is that it should be absent (i.e. to be deleted).
|
606
|
+
def deleting?
|
607
|
+
obj = @parameters[:ensure] and obj.should == :absent
|
608
|
+
end
|
609
|
+
|
610
|
+
# Creates a new property value holder for the resource if it is valid and does not already exist
|
611
|
+
# @return [Boolean] true if a new parameter was added, false otherwise
|
612
|
+
def add_property_parameter(prop_name)
|
613
|
+
if self.class.validproperty?(prop_name) && !@parameters[prop_name]
|
614
|
+
self.newattr(prop_name)
|
615
|
+
return true
|
616
|
+
end
|
617
|
+
false
|
618
|
+
end
|
619
|
+
|
620
|
+
# @return [Symbol, Boolean] Returns the name of the namevar if there is only one or false otherwise.
|
621
|
+
# @comment This is really convoluted and part of the support for multiple namevars (?).
|
622
|
+
# If there is only one namevar, the produced value is naturally this namevar, but if there are several?
|
623
|
+
# The logic caches the name of the namevar if it is a single name, but otherwise always
|
624
|
+
# calls key_attributes, and then caches the first if there was only one, otherwise it returns
|
625
|
+
# false and caches this (which is then subsequently returned as a cache hit).
|
626
|
+
#
|
627
|
+
def name_var
|
628
|
+
return @name_var_cache unless @name_var_cache.nil?
|
629
|
+
key_attributes = self.class.key_attributes
|
630
|
+
@name_var_cache = (key_attributes.length == 1) && key_attributes.first
|
631
|
+
end
|
632
|
+
|
633
|
+
# Gets the 'should' (wanted state) value of a parameter or property by name.
|
634
|
+
# To explicitly get the 'is' (current state) value use `o.is(:name)`, and to explicitly get the 'should' value
|
635
|
+
# use `o.should(:name)`
|
636
|
+
# @param name [String] the name of the attribute to obtain the 'should' value for.
|
637
|
+
# @return [Object] 'should'/wanted value of the given attribute
|
638
|
+
def [](name)
|
639
|
+
name = name.intern
|
640
|
+
fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name)
|
641
|
+
|
642
|
+
if name == :name && nv = name_var
|
643
|
+
name = nv
|
644
|
+
end
|
645
|
+
|
646
|
+
if obj = @parameters[name]
|
647
|
+
# Note that if this is a property, then the value is the "should" value,
|
648
|
+
# not the current value.
|
649
|
+
obj.value
|
650
|
+
else
|
651
|
+
return nil
|
652
|
+
end
|
653
|
+
end
|
654
|
+
|
655
|
+
# Sets the 'should' (wanted state) value of a property, or the value of a parameter.
|
656
|
+
# @return
|
657
|
+
# @raise [Puppet::Error] if the setting of the value fails, or if the given name is nil.
|
658
|
+
# @raise [Puppet::ResourceError] when the parameter validation raises Puppet::Error or
|
659
|
+
# ArgumentError
|
660
|
+
def []=(name,value)
|
661
|
+
name = name.intern
|
662
|
+
|
663
|
+
fail("no parameter named '#{name}'") unless self.class.validattr?(name)
|
664
|
+
|
665
|
+
if name == :name && nv = name_var
|
666
|
+
name = nv
|
667
|
+
end
|
668
|
+
raise Puppet::Error.new("Got nil value for #{name}") if value.nil?
|
669
|
+
|
670
|
+
property = self.newattr(name)
|
671
|
+
|
672
|
+
if property
|
673
|
+
begin
|
674
|
+
# make sure the parameter doesn't have any errors
|
675
|
+
property.value = value
|
676
|
+
rescue Puppet::Error, ArgumentError => detail
|
677
|
+
error = Puppet::ResourceError.new("Parameter #{name} failed on #{ref}: #{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 '#{attr}' in #{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
|
+
raise Puppet::DevError,
|
1022
|
+
"The is value is not in the is array for '#{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
|
+
raise Puppet::DevError,
|
1033
|
+
"The is value is not in the is array for '#{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, "#{self.name} has no providers and has not overridden 'instances'" 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 "(This metaparameter is deprecated and will be ignored in a future release.)
|
1293
|
+
|
1294
|
+
Marks a subset of this resource's unmanaged attributes for auditing. Accepts an
|
1295
|
+
attribute name, an array of attribute names, or `all`.
|
1296
|
+
|
1297
|
+
Auditing a resource attribute has two effects: First, whenever a catalog
|
1298
|
+
is applied with puppet apply or puppet agent, Puppet will check whether
|
1299
|
+
that attribute of the resource has been modified, comparing its current
|
1300
|
+
value to the previous run; any change will be logged alongside any actions
|
1301
|
+
performed by Puppet while applying the catalog.
|
1302
|
+
|
1303
|
+
Secondly, marking a resource attribute for auditing will include that
|
1304
|
+
attribute in inspection reports generated by puppet inspect; see the
|
1305
|
+
puppet inspect documentation for more details.
|
1306
|
+
|
1307
|
+
Managed attributes for a resource can also be audited, but note that
|
1308
|
+
changes made by Puppet will be logged as additional modifications. (I.e.
|
1309
|
+
if a user manually edits a file whose contents are audited and managed,
|
1310
|
+
puppet agent's next two runs will both log an audit notice: the first run
|
1311
|
+
will log the user's edit and then revert the file to the desired state,
|
1312
|
+
and the second run will log the edit made by Puppet.)"
|
1313
|
+
|
1314
|
+
validate do |list|
|
1315
|
+
if Puppet.settings[:strict] != :off
|
1316
|
+
# Only warn if `audit` metaparam came from a manifest
|
1317
|
+
if file && line
|
1318
|
+
puppet_deprecation_warning(_("The `audit` metaparameter is deprecated and will be ignored in a future release."), { :line => line, :file => file })
|
1319
|
+
end
|
1320
|
+
end
|
1321
|
+
list = Array(list).collect {|p| p.to_sym}
|
1322
|
+
unless list == [:all]
|
1323
|
+
list.each do |param|
|
1324
|
+
next if @resource.class.validattr?(param)
|
1325
|
+
fail "Cannot audit #{param}: not a valid attribute for #{resource}"
|
1326
|
+
end
|
1327
|
+
end
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
munge do |args|
|
1331
|
+
properties_to_audit(args).each do |param|
|
1332
|
+
next unless resource.class.validproperty?(param)
|
1333
|
+
resource.newattr(param)
|
1334
|
+
end
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
def all_properties
|
1338
|
+
resource.class.properties.find_all do |property|
|
1339
|
+
resource.provider.nil? or resource.provider.class.supports_parameter?(property)
|
1340
|
+
end.collect do |property|
|
1341
|
+
property.name
|
1342
|
+
end
|
1343
|
+
end
|
1344
|
+
|
1345
|
+
def properties_to_audit(list)
|
1346
|
+
if !list.kind_of?(Array) && list.to_sym == :all
|
1347
|
+
list = all_properties
|
1348
|
+
else
|
1349
|
+
list = Array(list).collect { |p| p.to_sym }
|
1350
|
+
end
|
1351
|
+
end
|
1352
|
+
end
|
1353
|
+
|
1354
|
+
newmetaparam(:loglevel) do
|
1355
|
+
desc "Sets the level that information will be logged.
|
1356
|
+
The log levels have the biggest impact when logs are sent to
|
1357
|
+
syslog (which is currently the default).
|
1358
|
+
|
1359
|
+
The order of the log levels, in decreasing priority, is:
|
1360
|
+
|
1361
|
+
* `emerg`
|
1362
|
+
* `alert`
|
1363
|
+
* `crit`
|
1364
|
+
* `err`
|
1365
|
+
* `warning`
|
1366
|
+
* `notice`
|
1367
|
+
* `info` / `verbose`
|
1368
|
+
* `debug`
|
1369
|
+
"
|
1370
|
+
defaultto :notice
|
1371
|
+
|
1372
|
+
newvalues(*Puppet::Util::Log.levels)
|
1373
|
+
newvalues(:verbose)
|
1374
|
+
|
1375
|
+
munge do |loglevel|
|
1376
|
+
val = super(loglevel)
|
1377
|
+
if val == :verbose
|
1378
|
+
val = :info
|
1379
|
+
end
|
1380
|
+
val
|
1381
|
+
end
|
1382
|
+
end
|
1383
|
+
|
1384
|
+
newmetaparam(:alias) do
|
1385
|
+
desc %q{Creates an alias for the resource. Puppet uses this internally when you
|
1386
|
+
provide a symbolic title and an explicit namevar value:
|
1387
|
+
|
1388
|
+
file { 'sshdconfig':
|
1389
|
+
path => $operatingsystem ? {
|
1390
|
+
solaris => '/usr/local/etc/ssh/sshd_config',
|
1391
|
+
default => '/etc/ssh/sshd_config',
|
1392
|
+
},
|
1393
|
+
source => '...'
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
service { 'sshd':
|
1397
|
+
subscribe => File['sshdconfig'],
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
When you use this feature, the parser sets `sshdconfig` as the title,
|
1401
|
+
and the library sets that as an alias for the file so the dependency
|
1402
|
+
lookup in `Service['sshd']` works. You can use this metaparameter yourself,
|
1403
|
+
but note that aliases generally only work for creating relationships; anything
|
1404
|
+
else that refers to an existing resource (such as amending or overriding
|
1405
|
+
resource attributes in an inherited class) must use the resource's exact
|
1406
|
+
title. For example, the following code will not work:
|
1407
|
+
|
1408
|
+
file { '/etc/ssh/sshd_config':
|
1409
|
+
owner => root,
|
1410
|
+
group => root,
|
1411
|
+
alias => 'sshdconfig',
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
File['sshdconfig'] {
|
1415
|
+
mode => '0644',
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
There's no way here for the Puppet parser to know that these two stanzas
|
1419
|
+
should be affecting the same file.
|
1420
|
+
|
1421
|
+
}
|
1422
|
+
|
1423
|
+
munge do |aliases|
|
1424
|
+
aliases = [aliases] unless aliases.is_a?(Array)
|
1425
|
+
|
1426
|
+
raise(ArgumentError, "Cannot add aliases without a catalog") unless @resource.catalog
|
1427
|
+
|
1428
|
+
aliases.each do |other|
|
1429
|
+
if obj = @resource.catalog.resource(@resource.class.name, other)
|
1430
|
+
unless obj.object_id == @resource.object_id
|
1431
|
+
self.fail("#{@resource.title} can not create alias #{other}: object already exists")
|
1432
|
+
end
|
1433
|
+
next
|
1434
|
+
end
|
1435
|
+
|
1436
|
+
# Newschool, add it to the catalog.
|
1437
|
+
@resource.catalog.alias(@resource, other)
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
newmetaparam(:tag) do
|
1443
|
+
desc "Add the specified tags to the associated resource. While all resources
|
1444
|
+
are automatically tagged with as much information as possible
|
1445
|
+
(e.g., each class and definition containing the resource), it can
|
1446
|
+
be useful to add your own tags to a given resource.
|
1447
|
+
|
1448
|
+
Multiple tags can be specified as an array:
|
1449
|
+
|
1450
|
+
file {'/etc/hosts':
|
1451
|
+
ensure => file,
|
1452
|
+
source => 'puppet:///modules/site/hosts',
|
1453
|
+
mode => '0644',
|
1454
|
+
tag => ['bootstrap', 'minimumrun', 'mediumrun'],
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
Tags are useful for things like applying a subset of a host's configuration
|
1458
|
+
with [the `tags` setting](/puppet/latest/reference/configuration.html#tags)
|
1459
|
+
(e.g. `puppet agent --test --tags bootstrap`)."
|
1460
|
+
|
1461
|
+
munge do |tags|
|
1462
|
+
tags = [tags] unless tags.is_a? Array
|
1463
|
+
|
1464
|
+
tags.each do |tag|
|
1465
|
+
@resource.tag(tag)
|
1466
|
+
end
|
1467
|
+
end
|
1468
|
+
end
|
1469
|
+
|
1470
|
+
# RelationshipMetaparam is an implementation supporting the meta-parameters `:require`, `:subscribe`,
|
1471
|
+
# `:notify`, and `:before`.
|
1472
|
+
#
|
1473
|
+
#
|
1474
|
+
class RelationshipMetaparam < Puppet::Parameter
|
1475
|
+
class << self
|
1476
|
+
attr_accessor :direction, :events, :callback, :subclasses
|
1477
|
+
end
|
1478
|
+
|
1479
|
+
@subclasses = []
|
1480
|
+
|
1481
|
+
def self.inherited(sub)
|
1482
|
+
@subclasses << sub
|
1483
|
+
end
|
1484
|
+
|
1485
|
+
# @return [Array<Puppet::Resource>] turns attribute value(s) into list of resources
|
1486
|
+
def munge(references)
|
1487
|
+
references = [references] unless references.is_a?(Array)
|
1488
|
+
references.collect do |ref|
|
1489
|
+
if ref.is_a?(Puppet::Resource)
|
1490
|
+
ref
|
1491
|
+
else
|
1492
|
+
Puppet::Resource.new(ref)
|
1493
|
+
end
|
1494
|
+
end
|
1495
|
+
end
|
1496
|
+
|
1497
|
+
# Checks each reference to assert that what it references exists in the catalog.
|
1498
|
+
#
|
1499
|
+
# @raise [???fail] if the referenced resource can not be found
|
1500
|
+
# @return [void]
|
1501
|
+
def validate_relationship
|
1502
|
+
@value.each do |ref|
|
1503
|
+
unless @resource.catalog.resource(ref.to_s)
|
1504
|
+
description = self.class.direction == :in ? "dependency" : "dependent"
|
1505
|
+
fail ResourceError, "Could not find #{description} #{ref} for #{resource.ref}"
|
1506
|
+
end
|
1507
|
+
end
|
1508
|
+
end
|
1509
|
+
|
1510
|
+
# Creates edges for all relationships.
|
1511
|
+
# The `:in` relationships are specified by the event-receivers, and `:out`
|
1512
|
+
# relationships are specified by the event generator.
|
1513
|
+
# @todo references to "event-receivers" and "event generator" means in this context - are those just
|
1514
|
+
# the resources at the two ends of the relationship?
|
1515
|
+
# This way 'source' and 'target' are consistent terms in both edges
|
1516
|
+
# and events, i.e. an event targets edges whose source matches
|
1517
|
+
# the event's source. The direction of the relationship determines
|
1518
|
+
# which resource is applied first and which resource is considered
|
1519
|
+
# to be the event generator.
|
1520
|
+
# @return [Array<Puppet::Relationship>]
|
1521
|
+
# @raise [???fail] when a reference can not be resolved
|
1522
|
+
#
|
1523
|
+
def to_edges
|
1524
|
+
@value.collect do |reference|
|
1525
|
+
reference.catalog = resource.catalog
|
1526
|
+
|
1527
|
+
# Either of the two retrieval attempts could have returned
|
1528
|
+
# nil.
|
1529
|
+
unless related_resource = reference.resolve
|
1530
|
+
self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}"
|
1531
|
+
end
|
1532
|
+
|
1533
|
+
# Are we requiring them, or vice versa? See the method docs
|
1534
|
+
# for further info on this.
|
1535
|
+
if self.class.direction == :in
|
1536
|
+
source = related_resource
|
1537
|
+
target = @resource
|
1538
|
+
else
|
1539
|
+
source = @resource
|
1540
|
+
target = related_resource
|
1541
|
+
end
|
1542
|
+
|
1543
|
+
if method = self.class.callback
|
1544
|
+
subargs = {
|
1545
|
+
:event => self.class.events,
|
1546
|
+
:callback => method
|
1547
|
+
}
|
1548
|
+
self.debug { "subscribes to #{related_resource.ref}" }
|
1549
|
+
else
|
1550
|
+
# If there's no callback, there's no point in even adding
|
1551
|
+
# a label.
|
1552
|
+
subargs = nil
|
1553
|
+
self.debug { "subscribes to #{related_resource.ref}" }
|
1554
|
+
end
|
1555
|
+
|
1556
|
+
Puppet::Relationship.new(source, target, subargs)
|
1557
|
+
end
|
1558
|
+
end
|
1559
|
+
end
|
1560
|
+
|
1561
|
+
# @todo document this, have no clue what this does... it returns "RelationshipMetaparam.subclasses"
|
1562
|
+
#
|
1563
|
+
def self.relationship_params
|
1564
|
+
RelationshipMetaparam.subclasses
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
|
1568
|
+
# Note that the order in which the relationships params is defined
|
1569
|
+
# matters. The labeled params (notify and subscribe) must be later,
|
1570
|
+
# so that if both params are used, those ones win. It's a hackish
|
1571
|
+
# solution, but it works.
|
1572
|
+
|
1573
|
+
newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
1574
|
+
desc "One or more resources that this resource depends on, expressed as
|
1575
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1576
|
+
Multiple resources can be specified as an array of references. When this
|
1577
|
+
attribute is present:
|
1578
|
+
|
1579
|
+
* The required resource(s) will be applied **before** this resource.
|
1580
|
+
|
1581
|
+
This is one of the four relationship metaparameters, along with
|
1582
|
+
`before`, `notify`, and `subscribe`. For more context, including the
|
1583
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1584
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1585
|
+
end
|
1586
|
+
|
1587
|
+
newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1588
|
+
desc "One or more resources that this resource depends on, expressed as
|
1589
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1590
|
+
Multiple resources can be specified as an array of references. When this
|
1591
|
+
attribute is present:
|
1592
|
+
|
1593
|
+
* The subscribed resource(s) will be applied _before_ this resource.
|
1594
|
+
* If Puppet makes changes to any of the subscribed resources, it will cause
|
1595
|
+
this resource to _refresh._ (Refresh behavior varies by resource
|
1596
|
+
type: services will restart, mounts will unmount and re-mount, etc. Not
|
1597
|
+
all types can refresh.)
|
1598
|
+
|
1599
|
+
This is one of the four relationship metaparameters, along with
|
1600
|
+
`before`, `require`, and `notify`. For more context, including the
|
1601
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1602
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1603
|
+
end
|
1604
|
+
|
1605
|
+
newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
1606
|
+
desc "One or more resources that depend on this resource, expressed as
|
1607
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1608
|
+
Multiple resources can be specified as an array of references. When this
|
1609
|
+
attribute is present:
|
1610
|
+
|
1611
|
+
* This resource will be applied _before_ the dependent resource(s).
|
1612
|
+
|
1613
|
+
This is one of the four relationship metaparameters, along with
|
1614
|
+
`require`, `notify`, and `subscribe`. For more context, including the
|
1615
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1616
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1617
|
+
end
|
1618
|
+
|
1619
|
+
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
|
1620
|
+
desc "One or more resources that depend on this resource, expressed as
|
1621
|
+
[resource references](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_resource_reference.html).
|
1622
|
+
Multiple resources can be specified as an array of references. When this
|
1623
|
+
attribute is present:
|
1624
|
+
|
1625
|
+
* This resource will be applied _before_ the notified resource(s).
|
1626
|
+
* If Puppet makes changes to this resource, it will cause all of the
|
1627
|
+
notified resources to _refresh._ (Refresh behavior varies by resource
|
1628
|
+
type: services will restart, mounts will unmount and re-mount, etc. Not
|
1629
|
+
all types can refresh.)
|
1630
|
+
|
1631
|
+
This is one of the four relationship metaparameters, along with
|
1632
|
+
`before`, `require`, and `subscribe`. For more context, including the
|
1633
|
+
alternate chaining arrow (`->` and `~>`) syntax, see
|
1634
|
+
[the language page on relationships](https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html)."
|
1635
|
+
end
|
1636
|
+
|
1637
|
+
newmetaparam(:stage) do
|
1638
|
+
desc %{Which run stage this class should reside in.
|
1639
|
+
|
1640
|
+
**Note: This metaparameter can only be used on classes,** and only when
|
1641
|
+
declaring them with the resource-like syntax. It cannot be used on normal
|
1642
|
+
resources or on classes declared with `include`.
|
1643
|
+
|
1644
|
+
By default, all classes are declared in the `main` stage. To assign a class
|
1645
|
+
to a different stage, you must:
|
1646
|
+
|
1647
|
+
* Declare the new stage as a [`stage` resource](https://docs.puppetlabs.com/puppet/latest/reference/type.html#stage).
|
1648
|
+
* Declare an order relationship between the new stage and the `main` stage.
|
1649
|
+
* Use the resource-like syntax to declare the class, and set the `stage`
|
1650
|
+
metaparameter to the name of the desired stage.
|
1651
|
+
|
1652
|
+
For example:
|
1653
|
+
|
1654
|
+
stage { 'pre':
|
1655
|
+
before => Stage['main'],
|
1656
|
+
}
|
1657
|
+
|
1658
|
+
class { 'apt-updates':
|
1659
|
+
stage => 'pre',
|
1660
|
+
}
|
1661
|
+
}
|
1662
|
+
end
|
1663
|
+
|
1664
|
+
newmetaparam(:export, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
|
1665
|
+
desc <<EOS
|
1666
|
+
Export a capability resource.
|
1667
|
+
|
1668
|
+
The value of this parameter must be a reference to a capability resource,
|
1669
|
+
or an array of such references. Each capability resource referenced here
|
1670
|
+
will be instantiated in the node catalog and exported to consumers of this
|
1671
|
+
resource. The title of the capability resource will be the title given in
|
1672
|
+
the reference, and all other attributes of the resource will be filled
|
1673
|
+
according to the corresponding produces statement.
|
1674
|
+
|
1675
|
+
It is an error if this metaparameter references resources whose type is not
|
1676
|
+
a capability type, or of there is no produces clause for the type of the
|
1677
|
+
current resource and the capability resource mentioned in this parameter.
|
1678
|
+
|
1679
|
+
For example:
|
1680
|
+
|
1681
|
+
define web(..) { .. }
|
1682
|
+
Web produces Http { .. }
|
1683
|
+
web { server:
|
1684
|
+
export => Http[main_server]
|
1685
|
+
}
|
1686
|
+
EOS
|
1687
|
+
end
|
1688
|
+
|
1689
|
+
newmetaparam(:consume, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
|
1690
|
+
desc <<EOS
|
1691
|
+
Consume a capability resource.
|
1692
|
+
|
1693
|
+
The value of this parameter must be a reference to a capability resource,
|
1694
|
+
or an array of such references. Each capability resource referenced here
|
1695
|
+
must have been exported by another resource in the same environment.
|
1696
|
+
|
1697
|
+
The referenced capability resource(s) will be looked up, added to the
|
1698
|
+
current node catalog, and processed following the underlying consumes
|
1699
|
+
clause.
|
1700
|
+
|
1701
|
+
It is an error if this metaparameter references resources whose type is not
|
1702
|
+
a capability type, or of there is no consumes clause for the type of the
|
1703
|
+
current resource and the capability resource mentioned in this parameter.
|
1704
|
+
|
1705
|
+
For example:
|
1706
|
+
|
1707
|
+
define web(..) { .. }
|
1708
|
+
Web consumes Sql { .. }
|
1709
|
+
web { server:
|
1710
|
+
consume => Sql[my_db]
|
1711
|
+
}
|
1712
|
+
EOS
|
1713
|
+
end
|
1714
|
+
|
1715
|
+
###############################
|
1716
|
+
# All of the provider plumbing for the resource types.
|
1717
|
+
require 'puppet/provider'
|
1718
|
+
require 'puppet/util/provider_features'
|
1719
|
+
|
1720
|
+
# Add the feature handling module.
|
1721
|
+
extend Puppet::Util::ProviderFeatures
|
1722
|
+
|
1723
|
+
# The provider that has been selected for the instance of the resource type.
|
1724
|
+
# @return [Puppet::Provider,nil] the selected provider or nil, if none has been selected
|
1725
|
+
#
|
1726
|
+
attr_reader :provider
|
1727
|
+
|
1728
|
+
# the Type class attribute accessors
|
1729
|
+
class << self
|
1730
|
+
# The loader of providers to use when loading providers from disk.
|
1731
|
+
# Although it looks like this attribute provides a way to operate with different loaders of
|
1732
|
+
# providers that is not the case; the attribute is written when a new type is created,
|
1733
|
+
# and should not be changed thereafter.
|
1734
|
+
# @api private
|
1735
|
+
#
|
1736
|
+
attr_accessor :providerloader
|
1737
|
+
|
1738
|
+
# @todo Don't know if this is a name, or a reference to a Provider instance (now marked up as an instance
|
1739
|
+
# of Provider.
|
1740
|
+
# @return [Puppet::Provider, nil] The default provider for this type, or nil if non is defines
|
1741
|
+
#
|
1742
|
+
attr_writer :defaultprovider
|
1743
|
+
end
|
1744
|
+
|
1745
|
+
# The default provider, or the most suitable provider if no default provider was set.
|
1746
|
+
# @note a warning will be issued if no default provider has been configured and a search for the most
|
1747
|
+
# suitable provider returns more than one equally suitable provider.
|
1748
|
+
# @return [Puppet::Provider, nil] the default or most suitable provider, or nil if no provider was found
|
1749
|
+
#
|
1750
|
+
def self.defaultprovider
|
1751
|
+
return @defaultprovider if @defaultprovider
|
1752
|
+
|
1753
|
+
suitable = suitableprovider
|
1754
|
+
|
1755
|
+
# Find which providers are a default for this system.
|
1756
|
+
defaults = suitable.find_all { |provider| provider.default? }
|
1757
|
+
|
1758
|
+
# If we don't have any default we use suitable providers
|
1759
|
+
defaults = suitable if defaults.empty?
|
1760
|
+
max = defaults.collect { |provider| provider.specificity }.max
|
1761
|
+
defaults = defaults.find_all { |provider| provider.specificity == max }
|
1762
|
+
|
1763
|
+
if defaults.length > 1
|
1764
|
+
Puppet.warning(
|
1765
|
+
"Found multiple default providers for #{self.name}: #{defaults.collect { |i| i.name.to_s }.join(", ")}; using #{defaults[0].name}"
|
1766
|
+
)
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
@defaultprovider = defaults.shift unless defaults.empty?
|
1770
|
+
end
|
1771
|
+
|
1772
|
+
# @return [Hash{??? => Puppet::Provider}] Returns a hash of WHAT EXACTLY for the given type
|
1773
|
+
# @todo what goes into this hash?
|
1774
|
+
def self.provider_hash_by_type(type)
|
1775
|
+
@provider_hashes ||= {}
|
1776
|
+
@provider_hashes[type] ||= {}
|
1777
|
+
end
|
1778
|
+
|
1779
|
+
# @return [Hash{ ??? => Puppet::Provider}] Returns a hash of WHAT EXACTLY for this type.
|
1780
|
+
# @see provider_hash_by_type method to get the same for some other type
|
1781
|
+
def self.provider_hash
|
1782
|
+
Puppet::Type.provider_hash_by_type(self.name)
|
1783
|
+
end
|
1784
|
+
|
1785
|
+
# Returns the provider having the given name.
|
1786
|
+
# This will load a provider if it is not already loaded. The returned provider is the first found provider
|
1787
|
+
# having the given name, where "first found" semantics is defined by the {providerloader} in use.
|
1788
|
+
#
|
1789
|
+
# @param name [String] the name of the provider to get
|
1790
|
+
# @return [Puppet::Provider, nil] the found provider, or nil if no provider of the given name was found
|
1791
|
+
#
|
1792
|
+
def self.provider(name)
|
1793
|
+
name = name.intern
|
1794
|
+
|
1795
|
+
# If we don't have it yet, try loading it.
|
1796
|
+
@providerloader.load(name) unless provider_hash.has_key?(name)
|
1797
|
+
provider_hash[name]
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
# Returns a list of loaded providers by name.
|
1801
|
+
# This method will not load/search for available providers.
|
1802
|
+
# @return [Array<String>] list of loaded provider names
|
1803
|
+
#
|
1804
|
+
def self.providers
|
1805
|
+
provider_hash.keys
|
1806
|
+
end
|
1807
|
+
|
1808
|
+
# Returns true if the given name is a reference to a provider and if this is a suitable provider for
|
1809
|
+
# this type.
|
1810
|
+
# @todo How does the provider know if it is suitable for the type? Is it just suitable for the platform/
|
1811
|
+
# environment where this method is executing?
|
1812
|
+
# @param name [String] the name of the provider for which validity is checked
|
1813
|
+
# @return [Boolean] true if the given name references a provider that is suitable
|
1814
|
+
#
|
1815
|
+
def self.validprovider?(name)
|
1816
|
+
name = name.intern
|
1817
|
+
|
1818
|
+
(provider_hash.has_key?(name) && provider_hash[name].suitable?)
|
1819
|
+
end
|
1820
|
+
|
1821
|
+
# Creates a new provider of a type.
|
1822
|
+
# This method must be called directly on the type that it's implementing.
|
1823
|
+
# @todo Fix Confusing Explanations!
|
1824
|
+
# Is this a new provider of a Type (metatype), or a provider of an instance of Type (a resource), or
|
1825
|
+
# a Provider (the implementation of a Type's behavior). CONFUSED. It calls magically named methods like
|
1826
|
+
# "providify" ...
|
1827
|
+
# @param name [String, Symbol] the name of the WHAT? provider? type?
|
1828
|
+
# @param options [Hash{Symbol => Object}] a hash of options, used by this method, and passed on to {#genclass}, (see
|
1829
|
+
# it for additional options to pass).
|
1830
|
+
# @option options [Puppet::Provider] :parent the parent provider (what is this?)
|
1831
|
+
# @option options [Puppet::Type] :resource_type the resource type, defaults to this type if unspecified
|
1832
|
+
# @return [Puppet::Provider] a provider ???
|
1833
|
+
# @raise [Puppet::DevError] when the parent provider could not be found.
|
1834
|
+
#
|
1835
|
+
def self.provide(name, options = {}, &block)
|
1836
|
+
name = name.intern
|
1837
|
+
|
1838
|
+
if unprovide(name)
|
1839
|
+
Puppet.debug "Reloading #{name} #{self.name} provider"
|
1840
|
+
end
|
1841
|
+
|
1842
|
+
parent = if pname = options[:parent]
|
1843
|
+
options.delete(:parent)
|
1844
|
+
if pname.is_a? Class
|
1845
|
+
pname
|
1846
|
+
else
|
1847
|
+
if provider = self.provider(pname)
|
1848
|
+
provider
|
1849
|
+
else
|
1850
|
+
raise Puppet::DevError,
|
1851
|
+
"Could not find parent provider #{pname} of #{name}"
|
1852
|
+
end
|
1853
|
+
end
|
1854
|
+
else
|
1855
|
+
Puppet::Provider
|
1856
|
+
end
|
1857
|
+
|
1858
|
+
options[:resource_type] ||= self
|
1859
|
+
|
1860
|
+
self.providify
|
1861
|
+
|
1862
|
+
provider = genclass(
|
1863
|
+
name,
|
1864
|
+
:parent => parent,
|
1865
|
+
:hash => provider_hash,
|
1866
|
+
:prefix => "Provider",
|
1867
|
+
:block => block,
|
1868
|
+
:include => feature_module,
|
1869
|
+
:extend => feature_module,
|
1870
|
+
:attributes => options
|
1871
|
+
)
|
1872
|
+
|
1873
|
+
provider
|
1874
|
+
end
|
1875
|
+
|
1876
|
+
# Ensures there is a `:provider` parameter defined.
|
1877
|
+
# Should only be called if there are providers.
|
1878
|
+
# @return [void]
|
1879
|
+
def self.providify
|
1880
|
+
return if @paramhash.has_key? :provider
|
1881
|
+
|
1882
|
+
param = newparam(:provider) do
|
1883
|
+
# We're using a hacky way to get the name of our type, since there doesn't
|
1884
|
+
# seem to be a correct way to introspect this at the time this code is run.
|
1885
|
+
# We expect that the class in which this code is executed will be something
|
1886
|
+
# like Puppet::Type::Ssh_authorized_key::ParameterProvider.
|
1887
|
+
desc <<-EOT
|
1888
|
+
The specific backend to use for this `#{self.to_s.split('::')[2].downcase}`
|
1889
|
+
resource. You will seldom need to specify this --- Puppet will usually
|
1890
|
+
discover the appropriate provider for your platform.
|
1891
|
+
EOT
|
1892
|
+
|
1893
|
+
# This is so we can refer back to the type to get a list of
|
1894
|
+
# providers for documentation.
|
1895
|
+
class << self
|
1896
|
+
# The reference to a parent type for the parameter `:provider` used to get a list of
|
1897
|
+
# providers for documentation purposes.
|
1898
|
+
#
|
1899
|
+
attr_accessor :parenttype
|
1900
|
+
end
|
1901
|
+
|
1902
|
+
# Provides the ability to add documentation to a provider.
|
1903
|
+
#
|
1904
|
+
def self.doc
|
1905
|
+
# Since we're mixing @doc with text from other sources, we must normalize
|
1906
|
+
# its indentation with scrub. But we don't need to manually scrub the
|
1907
|
+
# provider's doc string, since markdown_definitionlist sanitizes its inputs.
|
1908
|
+
scrub(@doc) + "Available providers are:\n\n" + parenttype.providers.sort { |a,b|
|
1909
|
+
a.to_s <=> b.to_s
|
1910
|
+
}.collect { |i|
|
1911
|
+
markdown_definitionlist( i, scrub(parenttype().provider(i).doc) )
|
1912
|
+
}.join
|
1913
|
+
end
|
1914
|
+
|
1915
|
+
# For each resource, the provider param defaults to
|
1916
|
+
# the type's default provider
|
1917
|
+
defaultto {
|
1918
|
+
prov = @resource.class.defaultprovider
|
1919
|
+
prov.name if prov
|
1920
|
+
}
|
1921
|
+
|
1922
|
+
validate do |provider_class|
|
1923
|
+
provider_class = provider_class[0] if provider_class.is_a? Array
|
1924
|
+
provider_class = provider_class.class.name if provider_class.is_a?(Puppet::Provider)
|
1925
|
+
|
1926
|
+
unless @resource.class.provider(provider_class)
|
1927
|
+
raise ArgumentError, "Invalid #{@resource.class.name} provider '#{provider_class}'"
|
1928
|
+
end
|
1929
|
+
end
|
1930
|
+
|
1931
|
+
munge do |provider|
|
1932
|
+
provider = provider[0] if provider.is_a? Array
|
1933
|
+
provider = provider.intern if provider.is_a? String
|
1934
|
+
@resource.provider = provider
|
1935
|
+
|
1936
|
+
if provider.is_a?(Puppet::Provider)
|
1937
|
+
provider.class.name
|
1938
|
+
else
|
1939
|
+
provider
|
1940
|
+
end
|
1941
|
+
end
|
1942
|
+
end
|
1943
|
+
param.parenttype = self
|
1944
|
+
end
|
1945
|
+
|
1946
|
+
# @todo this needs a better explanation
|
1947
|
+
# Removes the implementation class of a given provider.
|
1948
|
+
# @return [Object] returns what {Puppet::Util::ClassGen#rmclass} returns
|
1949
|
+
def self.unprovide(name)
|
1950
|
+
if @defaultprovider and @defaultprovider.name == name
|
1951
|
+
@defaultprovider = nil
|
1952
|
+
end
|
1953
|
+
|
1954
|
+
rmclass(name, :hash => provider_hash, :prefix => "Provider")
|
1955
|
+
end
|
1956
|
+
|
1957
|
+
# Returns a list of suitable providers for the given type.
|
1958
|
+
# A call to this method will load all providers if not already loaded and ask each if it is
|
1959
|
+
# suitable - those that are are included in the result.
|
1960
|
+
# @note This method also does some special processing which rejects a provider named `:fake` (for testing purposes).
|
1961
|
+
# @return [Array<Puppet::Provider>] Returns an array of all suitable providers.
|
1962
|
+
#
|
1963
|
+
def self.suitableprovider
|
1964
|
+
providerloader.loadall if provider_hash.empty?
|
1965
|
+
provider_hash.find_all { |name, provider|
|
1966
|
+
provider.suitable?
|
1967
|
+
}.collect { |name, provider|
|
1968
|
+
provider
|
1969
|
+
}.reject { |p| p.name == :fake } # For testing
|
1970
|
+
end
|
1971
|
+
|
1972
|
+
# @return [Boolean] Returns true if this is something else than a `:provider`, or if it
|
1973
|
+
# is a provider and it is suitable, or if there is a default provider. Otherwise, false is returned.
|
1974
|
+
#
|
1975
|
+
def suitable?
|
1976
|
+
# If we don't use providers, then we consider it suitable.
|
1977
|
+
return true unless self.class.paramclass(:provider)
|
1978
|
+
|
1979
|
+
# We have a provider and it is suitable.
|
1980
|
+
return true if provider && provider.class.suitable?
|
1981
|
+
|
1982
|
+
# We're using the default provider and there is one.
|
1983
|
+
if !provider and self.class.defaultprovider
|
1984
|
+
self.provider = self.class.defaultprovider.name
|
1985
|
+
return true
|
1986
|
+
end
|
1987
|
+
|
1988
|
+
# We specified an unsuitable provider, or there isn't any suitable
|
1989
|
+
# provider.
|
1990
|
+
false
|
1991
|
+
end
|
1992
|
+
|
1993
|
+
# Sets the provider to the given provider/name.
|
1994
|
+
# @overload provider=(name)
|
1995
|
+
# Sets the provider to the result of resolving the name to an instance of Provider.
|
1996
|
+
# @param name [String] the name of the provider
|
1997
|
+
# @overload provider=(provider)
|
1998
|
+
# Sets the provider to the given instances of Provider.
|
1999
|
+
# @param provider [Puppet::Provider] the provider to set
|
2000
|
+
# @return [Puppet::Provider] the provider set
|
2001
|
+
# @raise [ArgumentError] if the provider could not be found/resolved.
|
2002
|
+
#
|
2003
|
+
def provider=(name)
|
2004
|
+
if name.is_a?(Puppet::Provider)
|
2005
|
+
@provider = name
|
2006
|
+
@provider.resource = self
|
2007
|
+
elsif klass = self.class.provider(name)
|
2008
|
+
@provider = klass.new(self)
|
2009
|
+
else
|
2010
|
+
raise ArgumentError, "Could not find #{name} provider of #{self.class.name}"
|
2011
|
+
end
|
2012
|
+
end
|
2013
|
+
|
2014
|
+
###############################
|
2015
|
+
# All of the relationship code.
|
2016
|
+
|
2017
|
+
# Adds a block producing a single name (or list of names) of the given
|
2018
|
+
# resource type name to autorelate.
|
2019
|
+
#
|
2020
|
+
# The four relationship types require, before, notify, and subscribe are all
|
2021
|
+
# supported.
|
2022
|
+
#
|
2023
|
+
# Be *careful* with notify and subscribe as they may have unintended
|
2024
|
+
# consequences.
|
2025
|
+
#
|
2026
|
+
# Resources in the catalog that have the named type and a title that is
|
2027
|
+
# included in the result will be linked to the calling resource as a
|
2028
|
+
# requirement.
|
2029
|
+
#
|
2030
|
+
# @example Autorequire the files File['foo', 'bar']
|
2031
|
+
# autorequire( 'file', {|| ['foo', 'bar'] })
|
2032
|
+
#
|
2033
|
+
# @example Autobefore the files File['foo', 'bar']
|
2034
|
+
# autobefore( 'file', {|| ['foo', 'bar'] })
|
2035
|
+
#
|
2036
|
+
# @example Autosubscribe the files File['foo', 'bar']
|
2037
|
+
# autosubscribe( 'file', {|| ['foo', 'bar'] })
|
2038
|
+
#
|
2039
|
+
# @example Autonotify the files File['foo', 'bar']
|
2040
|
+
# autonotify( 'file', {|| ['foo', 'bar'] })
|
2041
|
+
#
|
2042
|
+
# @param name [String] the name of a type of which one or several resources should be autorelated e.g. "file"
|
2043
|
+
# @yield [ ] a block returning list of names of given type to auto require
|
2044
|
+
# @yieldreturn [String, Array<String>] one or several resource names for the named type
|
2045
|
+
# @return [void]
|
2046
|
+
# @dsl type
|
2047
|
+
# @api public
|
2048
|
+
#
|
2049
|
+
def self.autorequire(name, &block)
|
2050
|
+
@autorequires ||= {}
|
2051
|
+
@autorequires[name] = block
|
2052
|
+
end
|
2053
|
+
|
2054
|
+
def self.autobefore(name, &block)
|
2055
|
+
@autobefores ||= {}
|
2056
|
+
@autobefores[name] = block
|
2057
|
+
end
|
2058
|
+
|
2059
|
+
def self.autosubscribe(name, &block)
|
2060
|
+
@autosubscribes ||= {}
|
2061
|
+
@autosubscribes[name] = block
|
2062
|
+
end
|
2063
|
+
|
2064
|
+
def self.autonotify(name, &block)
|
2065
|
+
@autonotifies ||= {}
|
2066
|
+
@autonotifies[name] = block
|
2067
|
+
end
|
2068
|
+
|
2069
|
+
# Provides iteration over added auto-requirements (see {autorequire}).
|
2070
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2071
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autorequire}).
|
2072
|
+
# @yieldreturn [void]
|
2073
|
+
# @return [void]
|
2074
|
+
def self.eachautorequire
|
2075
|
+
@autorequires ||= {}
|
2076
|
+
@autorequires.each { |type, block|
|
2077
|
+
yield(type, block)
|
2078
|
+
}
|
2079
|
+
end
|
2080
|
+
|
2081
|
+
# Provides iteration over added auto-requirements (see {autobefore}).
|
2082
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2083
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autobefore}).
|
2084
|
+
# @yieldreturn [void]
|
2085
|
+
# @return [void]
|
2086
|
+
def self.eachautobefore
|
2087
|
+
@autobefores ||= {}
|
2088
|
+
@autobefores.each { |type,block|
|
2089
|
+
yield(type, block)
|
2090
|
+
}
|
2091
|
+
end
|
2092
|
+
|
2093
|
+
# Provides iteration over added auto-requirements (see {autosubscribe}).
|
2094
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2095
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autosubscribe}).
|
2096
|
+
# @yieldreturn [void]
|
2097
|
+
# @return [void]
|
2098
|
+
def self.eachautosubscribe
|
2099
|
+
@autosubscribes ||= {}
|
2100
|
+
@autosubscribes.each { |type,block|
|
2101
|
+
yield(type, block)
|
2102
|
+
}
|
2103
|
+
end
|
2104
|
+
|
2105
|
+
# Provides iteration over added auto-requirements (see {autonotify}).
|
2106
|
+
# @yieldparam type [String] the name of the type to autorequire an instance of
|
2107
|
+
# @yieldparam block [Proc] a block producing one or several dependencies to auto require (see {autonotify}).
|
2108
|
+
# @yieldreturn [void]
|
2109
|
+
# @return [void]
|
2110
|
+
def self.eachautonotify
|
2111
|
+
@autonotifies ||= {}
|
2112
|
+
@autonotifies.each { |type,block|
|
2113
|
+
yield(type, block)
|
2114
|
+
}
|
2115
|
+
end
|
2116
|
+
|
2117
|
+
# Adds dependencies to the catalog from added autorelations.
|
2118
|
+
# See {autorequire} for how to add an auto-requirement.
|
2119
|
+
# @todo needs details - see the param rel_catalog, and type of this param
|
2120
|
+
# @param rel_catalog [Puppet::Resource::Catalog, nil] the catalog to
|
2121
|
+
# add dependencies to. Defaults to the current catalog (set when the
|
2122
|
+
# type instance was added to a catalog)
|
2123
|
+
# @raise [Puppet::DevError] if there is no catalog
|
2124
|
+
#
|
2125
|
+
def autorelation(rel_type, rel_catalog = nil)
|
2126
|
+
rel_catalog ||= catalog
|
2127
|
+
raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
|
2128
|
+
|
2129
|
+
reqs = []
|
2130
|
+
|
2131
|
+
auto_rel = "eachauto#{rel_type}".to_sym
|
2132
|
+
|
2133
|
+
self.class.send(auto_rel) { |type, block|
|
2134
|
+
# Ignore any types we can't find, although that would be a bit odd.
|
2135
|
+
next unless Puppet::Type.type(type)
|
2136
|
+
|
2137
|
+
# Retrieve the list of names from the block.
|
2138
|
+
next unless list = self.instance_eval(&block)
|
2139
|
+
list = [list] unless list.is_a?(Array)
|
2140
|
+
|
2141
|
+
# Collect the current prereqs
|
2142
|
+
list.each { |dep|
|
2143
|
+
next if dep.nil?
|
2144
|
+
|
2145
|
+
# Support them passing objects directly, to save some effort.
|
2146
|
+
unless dep.is_a?(Puppet::Type)
|
2147
|
+
# Skip autorelation that we aren't managing
|
2148
|
+
unless dep = rel_catalog.resource(type, dep)
|
2149
|
+
next
|
2150
|
+
end
|
2151
|
+
end
|
2152
|
+
|
2153
|
+
if [:require, :subscribe].include?(rel_type)
|
2154
|
+
reqs << Puppet::Relationship.new(dep, self)
|
2155
|
+
else
|
2156
|
+
reqs << Puppet::Relationship.new(self, dep)
|
2157
|
+
end
|
2158
|
+
}
|
2159
|
+
}
|
2160
|
+
|
2161
|
+
reqs
|
2162
|
+
end
|
2163
|
+
|
2164
|
+
def autorequire(rel_catalog = nil)
|
2165
|
+
autorelation(:require, rel_catalog)
|
2166
|
+
end
|
2167
|
+
|
2168
|
+
def autobefore(rel_catalog = nil)
|
2169
|
+
autorelation(:before, rel_catalog)
|
2170
|
+
end
|
2171
|
+
|
2172
|
+
def autosubscribe(rel_catalog = nil)
|
2173
|
+
autorelation(:subscribe, rel_catalog)
|
2174
|
+
end
|
2175
|
+
|
2176
|
+
def autonotify(rel_catalog = nil)
|
2177
|
+
autorelation(:notify, rel_catalog)
|
2178
|
+
end
|
2179
|
+
|
2180
|
+
# Builds the dependencies associated with this resource.
|
2181
|
+
#
|
2182
|
+
# @return [Array<Puppet::Relationship>] list of relationships to other resources
|
2183
|
+
def builddepends
|
2184
|
+
# Handle the requires
|
2185
|
+
self.class.relationship_params.collect do |klass|
|
2186
|
+
if param = @parameters[klass.name]
|
2187
|
+
param.to_edges
|
2188
|
+
end
|
2189
|
+
end.flatten.reject { |r| r.nil? }
|
2190
|
+
end
|
2191
|
+
|
2192
|
+
# Sets the initial list of tags to associate to this resource.
|
2193
|
+
#
|
2194
|
+
# @return [void] ???
|
2195
|
+
def tags=(list)
|
2196
|
+
tag(self.class.name)
|
2197
|
+
tag(*list)
|
2198
|
+
end
|
2199
|
+
|
2200
|
+
# @comment - these two comments were floating around here, and turned up as documentation
|
2201
|
+
# for the attribute "title", much to my surprise and amusement. Clearly these comments
|
2202
|
+
# are orphaned ... I think they can just be removed as what they say should be covered
|
2203
|
+
# by the now added yardoc. <irony>(Yo! to quote some of the other actual awesome specific comments applicable
|
2204
|
+
# to objects called from elsewhere, or not. ;-)</irony>
|
2205
|
+
#
|
2206
|
+
# @comment Types (which map to resources in the languages) are entirely composed of
|
2207
|
+
# attribute value pairs. Generally, Puppet calls any of these things an
|
2208
|
+
# 'attribute', but these attributes always take one of three specific
|
2209
|
+
# forms: parameters, metaparams, or properties.
|
2210
|
+
|
2211
|
+
# @comment In naming methods, I have tried to consistently name the method so
|
2212
|
+
# that it is clear whether it operates on all attributes (thus has 'attr' in
|
2213
|
+
# the method name, or whether it operates on a specific type of attributes.
|
2214
|
+
|
2215
|
+
# The title attribute of WHAT ???
|
2216
|
+
# @todo Figure out what this is the title attribute of (it appears on line 1926 currently).
|
2217
|
+
# @return [String] the title
|
2218
|
+
attr_writer :title
|
2219
|
+
|
2220
|
+
# The noop attribute of WHAT ??? does WHAT???
|
2221
|
+
# @todo Figure out what this is the noop attribute of (it appears on line 1931 currently).
|
2222
|
+
# @return [???] the noop WHAT ??? (mode? if so of what, or noop for an instance of the type, or for all
|
2223
|
+
# instances of a type, or for what???
|
2224
|
+
#
|
2225
|
+
attr_writer :noop
|
2226
|
+
|
2227
|
+
include Enumerable
|
2228
|
+
|
2229
|
+
# class methods dealing with Type management
|
2230
|
+
|
2231
|
+
public
|
2232
|
+
|
2233
|
+
# The Type class attribute accessors
|
2234
|
+
class << self
|
2235
|
+
# @return [String] the name of the resource type; e.g., "File"
|
2236
|
+
#
|
2237
|
+
attr_reader :name
|
2238
|
+
|
2239
|
+
# @return [Boolean] true if the type should send itself a refresh event on change.
|
2240
|
+
#
|
2241
|
+
attr_accessor :self_refresh
|
2242
|
+
include Enumerable, Puppet::Util::ClassGen
|
2243
|
+
include Puppet::MetaType::Manager
|
2244
|
+
|
2245
|
+
include Puppet::Util
|
2246
|
+
include Puppet::Util::Logging
|
2247
|
+
end
|
2248
|
+
|
2249
|
+
# Initializes all of the variables that must be initialized for each subclass.
|
2250
|
+
# @todo Does the explanation make sense?
|
2251
|
+
# @return [void]
|
2252
|
+
def self.initvars
|
2253
|
+
# all of the instances of this class
|
2254
|
+
@objects = Hash.new
|
2255
|
+
@aliases = Hash.new
|
2256
|
+
|
2257
|
+
@defaults = {}
|
2258
|
+
|
2259
|
+
@parameters ||= []
|
2260
|
+
|
2261
|
+
@validproperties = {}
|
2262
|
+
@properties = []
|
2263
|
+
@parameters = []
|
2264
|
+
@paramhash = {}
|
2265
|
+
|
2266
|
+
@paramdoc = Hash.new { |hash,key|
|
2267
|
+
key = key.intern if key.is_a?(String)
|
2268
|
+
if hash.include?(key)
|
2269
|
+
hash[key]
|
2270
|
+
else
|
2271
|
+
"Param Documentation for #{key} not found"
|
2272
|
+
end
|
2273
|
+
}
|
2274
|
+
|
2275
|
+
@doc ||= ""
|
2276
|
+
|
2277
|
+
end
|
2278
|
+
|
2279
|
+
# Returns the name of this type (if specified) or the parent type #to_s.
|
2280
|
+
# The returned name is on the form "Puppet::Type::<name>", where the first letter of name is
|
2281
|
+
# capitalized.
|
2282
|
+
# @return [String] the fully qualified name Puppet::Type::<name> where the first letter of name is capitalized
|
2283
|
+
#
|
2284
|
+
def self.to_s
|
2285
|
+
if defined?(@name)
|
2286
|
+
"Puppet::Type::#{@name.to_s.capitalize}"
|
2287
|
+
else
|
2288
|
+
super
|
2289
|
+
end
|
2290
|
+
end
|
2291
|
+
|
2292
|
+
# Creates a `validate` method that is used to validate a resource before it is operated on.
|
2293
|
+
# The validation should raise exceptions if the validation finds errors. (It is not recommended to
|
2294
|
+
# issue warnings as this typically just ends up in a logfile - you should fail if a validation fails).
|
2295
|
+
# The easiest way to raise an appropriate exception is to call the method {Puppet::Util::Errors.fail} with
|
2296
|
+
# the message as an argument.
|
2297
|
+
#
|
2298
|
+
# @yield [ ] a required block called with self set to the instance of a Type class representing a resource.
|
2299
|
+
# @return [void]
|
2300
|
+
# @dsl type
|
2301
|
+
# @api public
|
2302
|
+
#
|
2303
|
+
def self.validate(&block)
|
2304
|
+
define_method(:validate, &block)
|
2305
|
+
end
|
2306
|
+
|
2307
|
+
# @return [String] The file from which this type originates from
|
2308
|
+
attr_accessor :file
|
2309
|
+
|
2310
|
+
# @return [Integer] The line in {#file} from which this type originates from
|
2311
|
+
attr_accessor :line
|
2312
|
+
|
2313
|
+
# @todo what does this mean "this resource" (sounds like this if for an instance of the type, not the meta Type),
|
2314
|
+
# but not sure if this is about the catalog where the meta Type is included)
|
2315
|
+
# @return [??? TODO] The catalog that this resource is stored in.
|
2316
|
+
attr_accessor :catalog
|
2317
|
+
|
2318
|
+
# @return [Boolean] Flag indicating if this type is exported
|
2319
|
+
attr_accessor :exported
|
2320
|
+
|
2321
|
+
# @return [Boolean] Flag indicating if the type is virtual (it should not be).
|
2322
|
+
attr_accessor :virtual
|
2323
|
+
|
2324
|
+
# Creates a log entry with the given message at the log level specified by the parameter `loglevel`
|
2325
|
+
# @return [void]
|
2326
|
+
#
|
2327
|
+
def log(msg)
|
2328
|
+
|
2329
|
+
Puppet::Util::Log.create(
|
2330
|
+
|
2331
|
+
:level => @parameters[:loglevel].value,
|
2332
|
+
:message => msg,
|
2333
|
+
|
2334
|
+
:source => self
|
2335
|
+
)
|
2336
|
+
end
|
2337
|
+
|
2338
|
+
|
2339
|
+
# instance methods related to instance intrinsics
|
2340
|
+
# e.g., initialize and name
|
2341
|
+
|
2342
|
+
public
|
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
|
+
@tags = resource.tags
|
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
|
+
elsif self.class.attrclass(name)
|
2440
|
+
warning("Unable to mark '#{name}' as sensitive: the property itself was not assigned a value.")
|
2441
|
+
else
|
2442
|
+
err("Unable to mark '#{name}' as sensitive: the property itself is not defined on #{type}.")
|
2443
|
+
end
|
2444
|
+
end
|
2445
|
+
end
|
2446
|
+
|
2447
|
+
private
|
2448
|
+
|
2449
|
+
# Sets the name of the resource from a hash containing a mapping of `name_var` to value.
|
2450
|
+
# Sets the value of the property/parameter appointed by the `name_var` (if it is defined). The value set is
|
2451
|
+
# given by the corresponding entry in the given hash - e.g. if name_var appoints the name `:path` the value
|
2452
|
+
# of `:path` is set to the value at the key `:path` in the given hash. As a side effect this key/value is then
|
2453
|
+
# removed from the given hash.
|
2454
|
+
#
|
2455
|
+
# @note This method mutates the given hash by removing the entry with a key equal to the value
|
2456
|
+
# returned from name_var!
|
2457
|
+
# @param hash [Hash] a hash of what
|
2458
|
+
# @return [void]
|
2459
|
+
def set_name(hash)
|
2460
|
+
self[name_var] = hash.delete(name_var) if name_var
|
2461
|
+
end
|
2462
|
+
|
2463
|
+
# Sets parameters from the given hash.
|
2464
|
+
# Values are set in _attribute order_ i.e. higher priority attributes before others, otherwise in
|
2465
|
+
# the order they were specified (as opposed to just setting them in the order they happen to appear in
|
2466
|
+
# when iterating over the given hash).
|
2467
|
+
#
|
2468
|
+
# Attributes that are not included in the given hash are set to their default value.
|
2469
|
+
#
|
2470
|
+
# @todo Is this description accurate? Is "ensure" an example of such a higher priority attribute?
|
2471
|
+
# @return [void]
|
2472
|
+
# @raise [Puppet::DevError] when impossible to set the value due to some problem
|
2473
|
+
# @raise [ArgumentError, TypeError, Puppet::Error] when faulty arguments have been passed
|
2474
|
+
#
|
2475
|
+
def set_parameters(hash)
|
2476
|
+
# Use the order provided by allattrs, but add in any
|
2477
|
+
# extra attributes from the resource so we get failures
|
2478
|
+
# on invalid attributes.
|
2479
|
+
no_values = []
|
2480
|
+
(self.class.allattrs + hash.keys).uniq.each do |attr|
|
2481
|
+
begin
|
2482
|
+
# Set any defaults immediately. This is mostly done so
|
2483
|
+
# that the default provider is available for any other
|
2484
|
+
# property validation.
|
2485
|
+
if hash.has_key?(attr)
|
2486
|
+
self[attr] = hash[attr]
|
2487
|
+
else
|
2488
|
+
no_values << attr
|
2489
|
+
end
|
2490
|
+
rescue ArgumentError, Puppet::Error, TypeError
|
2491
|
+
raise
|
2492
|
+
rescue => detail
|
2493
|
+
error = Puppet::DevError.new( "Could not set #{attr} on #{self.class.name}: #{detail}")
|
2494
|
+
error.set_backtrace(detail.backtrace)
|
2495
|
+
raise error
|
2496
|
+
end
|
2497
|
+
end
|
2498
|
+
no_values.each do |attr|
|
2499
|
+
set_default(attr)
|
2500
|
+
end
|
2501
|
+
end
|
2502
|
+
|
2503
|
+
public
|
2504
|
+
|
2505
|
+
# Finishes any outstanding processing.
|
2506
|
+
# This method should be called as a final step in setup,
|
2507
|
+
# to allow the parameters that have associated auto-require needs to be processed.
|
2508
|
+
#
|
2509
|
+
# @todo what is the expected sequence here - who is responsible for calling this? When?
|
2510
|
+
# Is the returned type correct?
|
2511
|
+
# @return [Array<Puppet::Parameter>] the validated list/set of attributes
|
2512
|
+
#
|
2513
|
+
def finish
|
2514
|
+
# Call post_compile hook on every parameter that implements it. This includes all subclasses
|
2515
|
+
# of parameter including, but not limited to, regular parameters, metaparameters, relationship
|
2516
|
+
# parameters, and properties.
|
2517
|
+
eachparameter do |parameter|
|
2518
|
+
parameter.post_compile if parameter.respond_to? :post_compile
|
2519
|
+
end
|
2520
|
+
|
2521
|
+
# Make sure all of our relationships are valid. Again, must be done
|
2522
|
+
# when the entire catalog is instantiated.
|
2523
|
+
self.class.relationship_params.collect do |klass|
|
2524
|
+
if param = @parameters[klass.name]
|
2525
|
+
param.validate_relationship
|
2526
|
+
end
|
2527
|
+
end.flatten.reject { |r| r.nil? }
|
2528
|
+
end
|
2529
|
+
|
2530
|
+
# @comment For now, leave the 'name' method functioning like it used to. Once 'title'
|
2531
|
+
# works everywhere, I'll switch it.
|
2532
|
+
# Returns the resource's name
|
2533
|
+
# @todo There is a comment in source that this is not quite the same as ':title' and that a switch should
|
2534
|
+
# be made...
|
2535
|
+
# @return [String] the name of a resource
|
2536
|
+
def name
|
2537
|
+
self[:name]
|
2538
|
+
end
|
2539
|
+
|
2540
|
+
# Returns the parent of this in the catalog. In case of an erroneous catalog
|
2541
|
+
# where multiple parents have been produced, the first found (non
|
2542
|
+
# deterministic) parent is returned.
|
2543
|
+
# @return [Puppet::Type, nil] the
|
2544
|
+
# containing resource or nil if there is no catalog or no containing
|
2545
|
+
# resource.
|
2546
|
+
def parent
|
2547
|
+
return nil unless catalog
|
2548
|
+
|
2549
|
+
@parent ||=
|
2550
|
+
if parents = catalog.adjacent(self, :direction => :in)
|
2551
|
+
parents.shift
|
2552
|
+
else
|
2553
|
+
nil
|
2554
|
+
end
|
2555
|
+
end
|
2556
|
+
|
2557
|
+
# Returns a reference to this as a string in "Type[name]" format.
|
2558
|
+
# @return [String] a reference to this object on the form 'Type[name]'
|
2559
|
+
#
|
2560
|
+
def ref
|
2561
|
+
# memoizing this is worthwhile ~ 3 percent of calls are the "first time
|
2562
|
+
# around" in an average run of Puppet. --daniel 2012-07-17
|
2563
|
+
@ref ||= "#{self.class.name.to_s.capitalize}[#{self.title}]"
|
2564
|
+
end
|
2565
|
+
|
2566
|
+
# (see self_refresh)
|
2567
|
+
# @todo check that meaningful yardoc is produced - this method delegates to "self.class.self_refresh"
|
2568
|
+
# @return [Boolean] - ??? returns true when ... what?
|
2569
|
+
#
|
2570
|
+
def self_refresh?
|
2571
|
+
self.class.self_refresh
|
2572
|
+
end
|
2573
|
+
|
2574
|
+
# Marks the object as "being purged".
|
2575
|
+
# This method is used by transactions to forbid deletion when there are dependencies.
|
2576
|
+
# @todo what does this mean; "mark that we are purging" (purging what from where). How to use/when?
|
2577
|
+
# Is this internal API in transactions?
|
2578
|
+
# @see purging?
|
2579
|
+
def purging
|
2580
|
+
@purging = true
|
2581
|
+
end
|
2582
|
+
|
2583
|
+
# Returns whether this resource is being purged or not.
|
2584
|
+
# This method is used by transactions to forbid deletion when there are dependencies.
|
2585
|
+
# @return [Boolean] the current "purging" state
|
2586
|
+
#
|
2587
|
+
def purging?
|
2588
|
+
if defined?(@purging)
|
2589
|
+
@purging
|
2590
|
+
else
|
2591
|
+
false
|
2592
|
+
end
|
2593
|
+
end
|
2594
|
+
|
2595
|
+
# Returns the title of this object, or its name if title was not explicitly set.
|
2596
|
+
# If the title is not already set, it will be computed by looking up the {#name_var} and using
|
2597
|
+
# that value as the title.
|
2598
|
+
# @todo it is somewhat confusing that if the name_var is a valid parameter, it is assumed to
|
2599
|
+
# be the name_var called :name, but if it is a property, it uses the name_var.
|
2600
|
+
# It is further confusing as Type in some respects supports multiple namevars.
|
2601
|
+
#
|
2602
|
+
# @return [String] Returns the title of this object, or its name if title was not explicitly set.
|
2603
|
+
# @raise [??? devfail] if title is not set, and name_var can not be found.
|
2604
|
+
def title
|
2605
|
+
unless @title
|
2606
|
+
if self.class.validparameter?(name_var)
|
2607
|
+
@title = self[:name]
|
2608
|
+
elsif self.class.validproperty?(name_var)
|
2609
|
+
@title = self.should(name_var)
|
2610
|
+
else
|
2611
|
+
self.devfail "Could not find namevar #{name_var} for #{self.class.name}"
|
2612
|
+
end
|
2613
|
+
end
|
2614
|
+
|
2615
|
+
@title
|
2616
|
+
end
|
2617
|
+
|
2618
|
+
# Produces a reference to this in reference format.
|
2619
|
+
# @see #ref
|
2620
|
+
#
|
2621
|
+
def to_s
|
2622
|
+
self.ref
|
2623
|
+
end
|
2624
|
+
|
2625
|
+
# Convert this resource type instance to a Puppet::Resource.
|
2626
|
+
# @return [Puppet::Resource] Returns a serializable representation of this resource
|
2627
|
+
#
|
2628
|
+
def to_resource
|
2629
|
+
resource = self.retrieve_resource
|
2630
|
+
resource.tag(*self.tags)
|
2631
|
+
|
2632
|
+
@parameters.each do |name, param|
|
2633
|
+
# Avoid adding each instance name twice
|
2634
|
+
next if param.class.isnamevar? and param.value == self.title
|
2635
|
+
|
2636
|
+
# We've already got property values
|
2637
|
+
next if param.is_a?(Puppet::Property)
|
2638
|
+
resource[name] = param.value
|
2639
|
+
end
|
2640
|
+
|
2641
|
+
resource
|
2642
|
+
end
|
2643
|
+
|
2644
|
+
# @return [Boolean] Returns whether the resource is virtual or not
|
2645
|
+
def virtual?; !!@virtual; end
|
2646
|
+
# @return [Boolean] Returns whether the resource is exported or not
|
2647
|
+
def exported?; !!@exported; end
|
2648
|
+
|
2649
|
+
# @return [Boolean] Returns whether the resource is applicable to `:device`
|
2650
|
+
# Returns true if a resource of this type can be evaluated on a 'network device' kind
|
2651
|
+
# of hosts.
|
2652
|
+
# @api private
|
2653
|
+
def appliable_to_device?
|
2654
|
+
self.class.can_apply_to(:device)
|
2655
|
+
end
|
2656
|
+
|
2657
|
+
# @return [Boolean] Returns whether the resource is applicable to `:host`
|
2658
|
+
# Returns true if a resource of this type can be evaluated on a regular generalized computer (ie not an appliance like a network device)
|
2659
|
+
# @api private
|
2660
|
+
def appliable_to_host?
|
2661
|
+
self.class.can_apply_to(:host)
|
2662
|
+
end
|
2663
|
+
end
|
2664
|
+
end
|