vagrant-clone 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.idea/.rakeTasks +7 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/runConfigurations/clone.xml +21 -0
- data/.idea/runConfigurations/libvirt.xml +21 -0
- data/.idea/vagrant-clone.iml +114 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/workspace.xml +948 -0
- data/Gemfile +9 -3
- data/Gemfile.lock +123 -37
- data/Rakefile +2 -1
- data/Vagrantfile +9 -0
- data/cookbooks/apt/CHANGELOG.md +321 -0
- data/cookbooks/apt/CONTRIBUTING.md +2 -0
- data/cookbooks/apt/MAINTAINERS.md +15 -0
- data/cookbooks/apt/README.md +250 -0
- data/cookbooks/apt/attributes/default.rb +57 -0
- data/cookbooks/apt/files/15update-stamp +1 -0
- data/cookbooks/apt/files/apt-proxy-v2.conf +50 -0
- data/cookbooks/apt/libraries/helpers.rb +49 -0
- data/cookbooks/apt/libraries/matchers.rb +16 -0
- data/cookbooks/apt/metadata.json +1 -0
- data/cookbooks/apt/recipes/cacher-client.rb +52 -0
- data/cookbooks/apt/recipes/cacher-ng.rb +39 -0
- data/cookbooks/apt/recipes/default.rb +93 -0
- data/cookbooks/apt/recipes/unattended-upgrades.rb +47 -0
- data/cookbooks/apt/resources/preference.rb +90 -0
- data/cookbooks/apt/templates/01proxy.erb +11 -0
- data/cookbooks/apt/templates/10dpkg-options.erb +8 -0
- data/cookbooks/apt/templates/10recommends.erb +3 -0
- data/cookbooks/apt/templates/20auto-upgrades.erb +5 -0
- data/cookbooks/apt/templates/50unattended-upgrades.erb +75 -0
- data/cookbooks/apt/templates/acng.conf.erb +275 -0
- data/cookbooks/apt/templates/unattended-upgrades.seed.erb +1 -0
- data/cookbooks/build-essential/.foodcritic +1 -0
- data/cookbooks/build-essential/CHANGELOG.md +257 -0
- data/cookbooks/build-essential/CONTRIBUTING.md +2 -0
- data/cookbooks/build-essential/MAINTAINERS.md +15 -0
- data/cookbooks/build-essential/README.md +134 -0
- data/cookbooks/build-essential/attributes/default.rb +21 -0
- data/cookbooks/build-essential/libraries/matchers.rb +9 -0
- data/cookbooks/build-essential/metadata.json +1 -0
- data/cookbooks/build-essential/recipes/_windows.rb +53 -0
- data/cookbooks/build-essential/recipes/default.rb +24 -0
- data/cookbooks/build-essential/resources/build_essential.rb +106 -0
- data/cookbooks/build-essential/resources/xcode_command_line_tools.rb +61 -0
- data/cookbooks/compat_resource/CHANGELOG.md +53 -0
- data/cookbooks/compat_resource/CONTRIBUTING.md +2 -0
- data/cookbooks/compat_resource/MAINTAINERS.md +16 -0
- data/cookbooks/compat_resource/README.md +60 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/constants.rb +47 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb +40 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb +73 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +315 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb +292 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb +37 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb +70 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb +98 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb +74 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +510 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/powershell_out.rb +117 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb +328 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb +713 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_repository.rb +269 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_update.rb +105 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/noop.rb +56 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/support/yum_repo.erb +132 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/systemd_unit.rb +253 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/yum_repository.rb +136 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb +164 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb +114 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_repository.rb +65 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_update.rb +52 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/systemd_unit.rb +81 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/yum_repository.rb +97 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource.rb +214 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +174 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef.rb +29 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/mixin/properties.rb +8 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/exceptions.rb +10 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/log.rb +30 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/mixin/params_validate.rb +17 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/node.rb +9 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb +15 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/provider.rb +65 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe.rb +118 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe_hook.rb +20 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb +60 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource.rb +156 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb +167 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_list.rb +49 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_set.rb +49 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection.rb +103 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/run_context.rb +691 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb +153 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef.rb +33 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches.rb +41 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/property.rb +6 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/recipe.rb +8 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/resource/lwrp_base.rb +44 -0
- data/cookbooks/compat_resource/files/lib/chef_compat/resource.rb +56 -0
- data/cookbooks/compat_resource/files/lib/chef_upstream_version.rb +3 -0
- data/cookbooks/compat_resource/files/lib/compat_resource.rb +35 -0
- data/cookbooks/compat_resource/libraries/autoload.rb +31 -0
- data/cookbooks/compat_resource/metadata.json +1 -0
- data/cookbooks/inifile_chef_gem/CHANGELOG.md +11 -0
- data/cookbooks/inifile_chef_gem/README.md +46 -0
- data/cookbooks/inifile_chef_gem/metadata.json +51 -0
- data/cookbooks/inifile_chef_gem/metadata.rb +11 -0
- data/cookbooks/inifile_chef_gem/resources/default.rb +28 -0
- data/cookbooks/mariadb/CHANGELOG.md +332 -0
- data/cookbooks/mariadb/README.md +225 -0
- data/cookbooks/mariadb/attributes/default.rb +199 -0
- data/cookbooks/mariadb/libraries/mariadb_conn_helper.rb +53 -0
- data/cookbooks/mariadb/libraries/mariadb_helper.rb +216 -0
- data/cookbooks/mariadb/libraries/matchers.rb +21 -0
- data/cookbooks/mariadb/metadata.json +1 -0
- data/cookbooks/mariadb/providers/configuration.rb +39 -0
- data/cookbooks/mariadb/recipes/_audit_plugin.rb +63 -0
- data/cookbooks/mariadb/recipes/_debian_galera.rb +62 -0
- data/cookbooks/mariadb/recipes/_debian_server.rb +78 -0
- data/cookbooks/mariadb/recipes/_mariadb_repository.rb +29 -0
- data/cookbooks/mariadb/recipes/_redhat_client.rb +27 -0
- data/cookbooks/mariadb/recipes/_redhat_galera.rb +55 -0
- data/cookbooks/mariadb/recipes/_redhat_server.rb +58 -0
- data/cookbooks/mariadb/recipes/client.rb +47 -0
- data/cookbooks/mariadb/recipes/config.rb +115 -0
- data/cookbooks/mariadb/recipes/default.rb +46 -0
- data/cookbooks/mariadb/recipes/devel.rb +41 -0
- data/cookbooks/mariadb/recipes/galera.rb +324 -0
- data/cookbooks/mariadb/recipes/plugins.rb +3 -0
- data/cookbooks/mariadb/recipes/repository.rb +45 -0
- data/cookbooks/mariadb/recipes/server.rb +157 -0
- data/cookbooks/mariadb/resources/configuration.rb +13 -0
- data/cookbooks/mariadb/resources/mysql2_gem.rb +25 -0
- data/cookbooks/mariadb/resources/replication.rb +192 -0
- data/cookbooks/mariadb/templates/default/conf.d.generic.erb +19 -0
- data/cookbooks/mariadb/templates/default/debian.cnf.erb +12 -0
- data/cookbooks/mariadb/templates/default/mariadb-server.seed.erb +13 -0
- data/cookbooks/mariadb/templates/default/mariadb_grants.erb +42 -0
- data/cookbooks/mariadb/templates/default/my.cnf.erb +210 -0
- data/cookbooks/mariadb/templates/default/root.cnf.erb +5 -0
- data/cookbooks/mingw/.foodcritic +1 -0
- data/cookbooks/mingw/CHANGELOG.md +50 -0
- data/cookbooks/mingw/CONTRIBUTING.md +2 -0
- data/cookbooks/mingw/MAINTAINERS.md +14 -0
- data/cookbooks/mingw/README.md +133 -0
- data/cookbooks/mingw/files/default/bash.bat +17 -0
- data/cookbooks/mingw/files/default/custom-upgrade.sh +23 -0
- data/cookbooks/mingw/files/default/custom_prefix.sh +13 -0
- data/cookbooks/mingw/files/default/pthread.h +719 -0
- data/cookbooks/mingw/files/default/time.h +297 -0
- data/cookbooks/mingw/libraries/_helper.rb +38 -0
- data/cookbooks/mingw/metadata.json +1 -0
- data/cookbooks/mingw/recipes/default.rb +19 -0
- data/cookbooks/mingw/resources/get.rb +56 -0
- data/cookbooks/mingw/resources/msys2_package.rb +139 -0
- data/cookbooks/mingw/resources/tdm_gcc.rb +114 -0
- data/cookbooks/ohai/.foodcritic +2 -0
- data/cookbooks/ohai/CHANGELOG.md +166 -0
- data/cookbooks/ohai/CONTRIBUTING.md +2 -0
- data/cookbooks/ohai/MAINTAINERS.md +15 -0
- data/cookbooks/ohai/README.md +134 -0
- data/cookbooks/ohai/libraries/matchers.rb +41 -0
- data/cookbooks/ohai/metadata.json +1 -0
- data/cookbooks/ohai/recipes/default.rb +20 -0
- data/cookbooks/ohai/resources/hint.rb +55 -0
- data/cookbooks/ohai/resources/plugin.rb +117 -0
- data/cookbooks/selinux_policy/.gitignore +51 -0
- data/cookbooks/selinux_policy/.kitchen.yml +25 -0
- data/cookbooks/selinux_policy/.rubocop.yml +2 -0
- data/cookbooks/selinux_policy/.travis.yml +26 -0
- data/cookbooks/selinux_policy/Berksfile +8 -0
- data/cookbooks/selinux_policy/CHANGELOG.md +155 -0
- data/cookbooks/selinux_policy/LICENSE +13 -0
- data/cookbooks/selinux_policy/README.md +217 -0
- data/cookbooks/selinux_policy/Rakefile +68 -0
- data/cookbooks/selinux_policy/TESTING.md +2 -0
- data/cookbooks/selinux_policy/Thorfile +12 -0
- data/cookbooks/selinux_policy/attributes/default.rb +5 -0
- data/cookbooks/selinux_policy/chefignore +102 -0
- data/cookbooks/selinux_policy/libraries/helper-disabled.rb +29 -0
- data/cookbooks/selinux_policy/libraries/matchers.rb +57 -0
- data/cookbooks/selinux_policy/metadata.json +58 -0
- data/cookbooks/selinux_policy/metadata.rb +20 -0
- data/cookbooks/selinux_policy/providers/boolean.rb +28 -0
- data/cookbooks/selinux_policy/providers/fcontext.rb +78 -0
- data/cookbooks/selinux_policy/providers/module.rb +81 -0
- data/cookbooks/selinux_policy/providers/permissive.rb +26 -0
- data/cookbooks/selinux_policy/providers/port.rb +58 -0
- data/cookbooks/selinux_policy/recipes/default.rb +9 -0
- data/cookbooks/selinux_policy/recipes/install.rb +32 -0
- data/cookbooks/selinux_policy/resources/boolean.rb +8 -0
- data/cookbooks/selinux_policy/resources/fcontext.rb +8 -0
- data/cookbooks/selinux_policy/resources/module.rb +21 -0
- data/cookbooks/selinux_policy/resources/permissive.rb +6 -0
- data/cookbooks/selinux_policy/resources/port.rb +9 -0
- data/cookbooks/seven_zip/CHANGELOG.md +30 -0
- data/cookbooks/seven_zip/README.md +108 -0
- data/cookbooks/seven_zip/attributes/default.rb +31 -0
- data/cookbooks/seven_zip/libraries/matchers.rb +33 -0
- data/cookbooks/seven_zip/metadata.json +1 -0
- data/cookbooks/seven_zip/providers/archive.rb +68 -0
- data/cookbooks/seven_zip/recipes/default.rb +41 -0
- data/cookbooks/seven_zip/resources/archive.rb +29 -0
- data/cookbooks/windows/.foodcritic +2 -0
- data/cookbooks/windows/CHANGELOG.md +528 -0
- data/cookbooks/windows/CONTRIBUTING.md +2 -0
- data/cookbooks/windows/MAINTAINERS.md +21 -0
- data/cookbooks/windows/README.md +803 -0
- data/cookbooks/windows/attributes/default.rb +21 -0
- data/cookbooks/windows/files/dism_features.rb +45 -0
- data/cookbooks/windows/libraries/matchers.rb +586 -0
- data/cookbooks/windows/libraries/powershell_helper.rb +53 -0
- data/cookbooks/windows/libraries/registry_helper.rb +356 -0
- data/cookbooks/windows/libraries/version.rb +207 -0
- data/cookbooks/windows/libraries/version_helper.rb +79 -0
- data/cookbooks/windows/libraries/windows_helper.rb +174 -0
- data/cookbooks/windows/libraries/windows_privileged.rb +103 -0
- data/cookbooks/windows/libraries/wmi_helper.rb +32 -0
- data/cookbooks/windows/metadata.json +1 -0
- data/cookbooks/windows/recipes/default.rb +21 -0
- data/cookbooks/windows/resources/auto_run.rb +46 -0
- data/cookbooks/windows/resources/certificate.rb +166 -0
- data/cookbooks/windows/resources/certificate_binding.rb +128 -0
- data/cookbooks/windows/resources/feature.rb +82 -0
- data/cookbooks/windows/resources/feature_dism.rb +108 -0
- data/cookbooks/windows/resources/feature_powershell.rb +70 -0
- data/cookbooks/windows/resources/feature_servermanagercmd.rb +76 -0
- data/cookbooks/windows/resources/font.rb +80 -0
- data/cookbooks/windows/resources/http_acl.rb +110 -0
- data/cookbooks/windows/resources/pagefile.rb +152 -0
- data/cookbooks/windows/resources/path.rb +54 -0
- data/cookbooks/windows/resources/printer.rb +103 -0
- data/cookbooks/windows/resources/printer_port.rb +101 -0
- data/cookbooks/windows/resources/share.rb +291 -0
- data/cookbooks/windows/resources/shortcut.rb +53 -0
- data/cookbooks/windows/resources/task.rb +384 -0
- data/cookbooks/windows/resources/zipfile.rb +125 -0
- data/cookbooks/yum/.foodcritic +1 -0
- data/cookbooks/yum/CHANGELOG.md +351 -0
- data/cookbooks/yum/CONTRIBUTING.md +2 -0
- data/cookbooks/yum/MAINTAINERS.md +16 -0
- data/cookbooks/yum/README.md +125 -0
- data/cookbooks/yum/attributes/main.rb +103 -0
- data/cookbooks/yum/libraries/matchers.rb +9 -0
- data/cookbooks/yum/metadata.json +1 -0
- data/cookbooks/yum/recipes/default.rb +26 -0
- data/cookbooks/yum/recipes/dnf_yum_compat.rb +29 -0
- data/cookbooks/yum/resources/globalconfig.rb +119 -0
- data/cookbooks/yum/templates/.DS_Store +0 -0
- data/cookbooks/yum/templates/main.erb +276 -0
- data/cookbooks/yum-epel/CHANGELOG.md +138 -0
- data/cookbooks/yum-epel/CONTRIBUTING.md +2 -0
- data/cookbooks/yum-epel/MAINTAINERS.md +19 -0
- data/cookbooks/yum-epel/README.md +172 -0
- data/cookbooks/yum-epel/attributes/default.rb +8 -0
- data/cookbooks/yum-epel/attributes/epel-debuginfo.rb +15 -0
- data/cookbooks/yum-epel/attributes/epel-source.rb +15 -0
- data/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb +15 -0
- data/cookbooks/yum-epel/attributes/epel-testing-source.rb +15 -0
- data/cookbooks/yum-epel/attributes/epel-testing.rb +15 -0
- data/cookbooks/yum-epel/attributes/epel.rb +21 -0
- data/cookbooks/yum-epel/metadata.json +1 -0
- data/cookbooks/yum-epel/recipes/default.rb +27 -0
- data/cookbooks/yum-scl/.kitchen.dokken.yml +24 -0
- data/cookbooks/yum-scl/.kitchen.yml +24 -0
- data/cookbooks/yum-scl/.rubocop.yml +6 -0
- data/cookbooks/yum-scl/.travis.yml +28 -0
- data/cookbooks/yum-scl/Berksfile +3 -0
- data/cookbooks/yum-scl/Berksfile.lock +25 -0
- data/cookbooks/yum-scl/CHANGELOG.md +11 -0
- data/cookbooks/yum-scl/Gemfile +46 -0
- data/cookbooks/yum-scl/README.md +76 -0
- data/cookbooks/yum-scl/attributes/centos.rb +83 -0
- data/cookbooks/yum-scl/attributes/default.rb +15 -0
- data/cookbooks/yum-scl/attributes/scientific.rb +1 -0
- data/cookbooks/yum-scl/files/default/RPM-GPG-KEY-CentOS-SIG-SCLo +20 -0
- data/cookbooks/yum-scl/libraries/yum_scl_helper.rb +33 -0
- data/cookbooks/yum-scl/metadata.json +42 -0
- data/cookbooks/yum-scl/metadata.rb +12 -0
- data/cookbooks/yum-scl/recipes/chef_install.rb +52 -0
- data/cookbooks/yum-scl/recipes/default.rb +17 -0
- data/cookbooks/yum-scl/recipes/native_install.rb +35 -0
- data/lib/vagrant-clone/command/clone.rb +66 -61
- data/lib/vagrant-clone/errors.rb +61 -0
- data/lib/vagrant-clone/util/clone_manager_base.rb +69 -0
- data/lib/vagrant-clone/util/clone_managers/docker.rb +31 -0
- data/lib/vagrant-clone/util/clone_managers/libvirt.rb +254 -0
- data/lib/vagrant-clone/util/vagrantfile_managers/docker.rb +154 -0
- data/lib/vagrant-clone/util/vagrantfile_managers/libvirt.rb +159 -0
- data/lib/vagrant-clone/version.rb +2 -2
- data/lib/vagrant-clone.rb +6 -6
- data/libvirt.txt +7 -0
- data/performance_testing.rb +165 -0
- data/results.txt +45 -0
- data/scripts/create_box.sh +134 -0
- data/test.rb +92 -0
- data/tools/create_box.sh +130 -0
- data/vagrant-clone.gemspec +7 -7
- metadata +296 -5
- data/lib/vagrant-clone/command/errors.rb +0 -16
- data/lib/vagrant-clone/command/provider/docker.rb +0 -13
- data/lib/vagrant-clone/utils/vagrantfile_manager.rb +0 -47
data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb
ADDED
@@ -0,0 +1,328 @@
|
|
1
|
+
#
|
2
|
+
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
|
3
|
+
#
|
4
|
+
# THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!!
|
5
|
+
#
|
6
|
+
# NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
|
7
|
+
#
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'chef/mixin/properties'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
require 'chef_compat/copied_from_chef'
|
14
|
+
class Chef
|
15
|
+
module ::ChefCompat
|
16
|
+
module CopiedFromChef
|
17
|
+
require "chef_compat/copied_from_chef/chef/delayed_evaluator"
|
18
|
+
require "chef_compat/copied_from_chef/chef/mixin/params_validate"
|
19
|
+
require "chef_compat/copied_from_chef/chef/property"
|
20
|
+
|
21
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
22
|
+
module Mixin
|
23
|
+
CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin)
|
24
|
+
module Properties
|
25
|
+
CopiedFromChef.extend_chef_module(::Chef::Mixin::Properties, self) if defined?(::Chef::Mixin::Properties)
|
26
|
+
module ClassMethods
|
27
|
+
CopiedFromChef.extend_chef_module(::Chef::Mixin::Properties::ClassMethods, self) if defined?(::Chef::Mixin::Properties::ClassMethods)
|
28
|
+
#
|
29
|
+
# The list of properties defined on this resource.
|
30
|
+
#
|
31
|
+
# Everything defined with `property` is in this list.
|
32
|
+
#
|
33
|
+
# @param include_superclass [Boolean] `true` to include properties defined
|
34
|
+
# on superclasses; `false` or `nil` to return the list of properties
|
35
|
+
# directly on this class.
|
36
|
+
#
|
37
|
+
# @return [Hash<Symbol,Property>] The list of property names and types.
|
38
|
+
#
|
39
|
+
def properties(include_superclass = true)
|
40
|
+
if include_superclass
|
41
|
+
result = {}
|
42
|
+
ancestors.reverse_each { |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) }
|
43
|
+
result
|
44
|
+
else
|
45
|
+
@properties ||= {}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Create a property on this resource class.
|
51
|
+
#
|
52
|
+
# If a superclass has this property, or if this property has already been
|
53
|
+
# defined by this resource, this will *override* the previous value.
|
54
|
+
#
|
55
|
+
# @param name [Symbol] The name of the property.
|
56
|
+
# @param type [Object,Array<Object>] The type(s) of this property.
|
57
|
+
# If present, this is prepended to the `is` validation option.
|
58
|
+
# @param options [Hash<Symbol,Object>] Validation options.
|
59
|
+
# @option options [Object,Array] :is An object, or list of
|
60
|
+
# objects, that must match the value using Ruby's `===` operator
|
61
|
+
# (`options[:is].any? { |v| v === value }`).
|
62
|
+
# @option options [Object,Array] :equal_to An object, or list
|
63
|
+
# of objects, that must be equal to the value using Ruby's `==`
|
64
|
+
# operator (`options[:is].any? { |v| v == value }`)
|
65
|
+
# @option options [Regexp,Array<Regexp>] :regex An object, or
|
66
|
+
# list of objects, that must match the value with `regex.match(value)`.
|
67
|
+
# @option options [Class,Array<Class>] :kind_of A class, or
|
68
|
+
# list of classes, that the value must be an instance of.
|
69
|
+
# @option options [Hash<String,Proc>] :callbacks A hash of
|
70
|
+
# messages -> procs, all of which match the value. The proc must
|
71
|
+
# return a truthy or falsey value (true means it matches).
|
72
|
+
# @option options [Symbol,Array<Symbol>] :respond_to A method
|
73
|
+
# name, or list of method names, the value must respond to.
|
74
|
+
# @option options [Symbol,Array<Symbol>] :cannot_be A property,
|
75
|
+
# or a list of properties, that the value cannot have (such as `:nil` or
|
76
|
+
# `:empty`). The method with a questionmark at the end is called on the
|
77
|
+
# value (e.g. `value.empty?`). If the value does not have this method,
|
78
|
+
# it is considered valid (i.e. if you don't respond to `empty?` we
|
79
|
+
# assume you are not empty).
|
80
|
+
# @option options [Proc] :coerce A proc which will be called to
|
81
|
+
# transform the user input to canonical form. The value is passed in,
|
82
|
+
# and the transformed value returned as output. Lazy values will *not*
|
83
|
+
# be passed to this method until after they are evaluated. Called in the
|
84
|
+
# context of the resource (meaning you can access other properties).
|
85
|
+
# @option options [Boolean] :required `true` if this property
|
86
|
+
# must be present; `false` otherwise. This is checked after the resource
|
87
|
+
# is fully initialized.
|
88
|
+
# @option options [Boolean] :name_property `true` if this
|
89
|
+
# property defaults to the same value as `name`. Equivalent to
|
90
|
+
# `default: lazy { name }`, except that #property_is_set? will
|
91
|
+
# return `true` if the property is set *or* if `name` is set.
|
92
|
+
# @option options [Boolean] :name_attribute Same as `name_property`.
|
93
|
+
# @option options [Object] :default The value this property
|
94
|
+
# will return if the user does not set one. If this is `lazy`, it will
|
95
|
+
# be run in the context of the instance (and able to access other
|
96
|
+
# properties).
|
97
|
+
# @option options [Boolean] :desired_state `true` if this property is
|
98
|
+
# part of desired state. Defaults to `true`.
|
99
|
+
# @option options [Boolean] :identity `true` if this property
|
100
|
+
# is part of object identity. Defaults to `false`.
|
101
|
+
# @option options [Boolean] :sensitive `true` if this property could
|
102
|
+
# contain sensitive information and whose value should be redacted
|
103
|
+
# in any resource reporting / auditing output. Defaults to `false`.
|
104
|
+
#
|
105
|
+
# @example Bare property
|
106
|
+
# property :x
|
107
|
+
#
|
108
|
+
# @example With just a type
|
109
|
+
# property :x, String
|
110
|
+
#
|
111
|
+
# @example With just options
|
112
|
+
# property :x, default: 'hi'
|
113
|
+
#
|
114
|
+
# @example With type and options
|
115
|
+
# property :x, String, default: 'hi'
|
116
|
+
#
|
117
|
+
def property(name, type = NOT_PASSED, **options)
|
118
|
+
name = name.to_sym
|
119
|
+
|
120
|
+
options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo }
|
121
|
+
|
122
|
+
options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name)
|
123
|
+
options[:name] = name
|
124
|
+
options[:declared_in] = self
|
125
|
+
|
126
|
+
if type == NOT_PASSED
|
127
|
+
# If a type is not passed, the property derives from the
|
128
|
+
# superclass property (if any)
|
129
|
+
if properties.has_key?(name)
|
130
|
+
property = properties[name].derive(**options)
|
131
|
+
else
|
132
|
+
property = property_type(**options)
|
133
|
+
end
|
134
|
+
|
135
|
+
# If a Property is specified, derive a new one from that.
|
136
|
+
elsif type.is_a?(Property) || (type.is_a?(Class) && type <= Property)
|
137
|
+
property = type.derive(**options)
|
138
|
+
|
139
|
+
# If a primitive type was passed, combine it with "is"
|
140
|
+
else
|
141
|
+
if options[:is]
|
142
|
+
options[:is] = ([ type ] + [ options[:is] ]).flatten(1)
|
143
|
+
else
|
144
|
+
options[:is] = type
|
145
|
+
end
|
146
|
+
property = property_type(**options)
|
147
|
+
end
|
148
|
+
|
149
|
+
local_properties = properties(false)
|
150
|
+
local_properties[name] = property
|
151
|
+
|
152
|
+
property.emit_dsl
|
153
|
+
end
|
154
|
+
|
155
|
+
#
|
156
|
+
# Create a reusable property type that can be used in multiple properties
|
157
|
+
# in different resources.
|
158
|
+
#
|
159
|
+
# @param options [Hash<Symbol,Object>] Validation options. see #property for
|
160
|
+
# the list of options.
|
161
|
+
#
|
162
|
+
# @example
|
163
|
+
# property_type(default: 'hi')
|
164
|
+
#
|
165
|
+
def property_type(**options)
|
166
|
+
Property.derive(**options)
|
167
|
+
end
|
168
|
+
|
169
|
+
#
|
170
|
+
# Create a lazy value for assignment to a default value.
|
171
|
+
#
|
172
|
+
# @param block The block to run when the value is retrieved.
|
173
|
+
#
|
174
|
+
# @return [Chef::DelayedEvaluator] The lazy value
|
175
|
+
#
|
176
|
+
def lazy(&block)
|
177
|
+
DelayedEvaluator.new(&block)
|
178
|
+
end
|
179
|
+
|
180
|
+
#
|
181
|
+
# Get or set the list of desired state properties for this resource.
|
182
|
+
#
|
183
|
+
# State properties are properties that describe the desired state
|
184
|
+
# of the system, such as file permissions or ownership.
|
185
|
+
# In general, state properties are properties that could be populated by
|
186
|
+
# examining the state of the system (e.g., File.stat can tell you the
|
187
|
+
# permissions on an existing file). Contrarily, properties that are not
|
188
|
+
# "state properties" usually modify the way Chef itself behaves, for example
|
189
|
+
# by providing additional options for a package manager to use when
|
190
|
+
# installing a package.
|
191
|
+
#
|
192
|
+
# This list is used by the Chef client auditing system to extract
|
193
|
+
# information from resources to describe changes made to the system.
|
194
|
+
#
|
195
|
+
# This method is unnecessary when declaring properties with `property`;
|
196
|
+
# properties are added to state_properties by default, and can be turned off
|
197
|
+
# with `desired_state: false`.
|
198
|
+
#
|
199
|
+
# ```ruby
|
200
|
+
# property :x # part of desired state
|
201
|
+
# property :y, desired_state: false # not part of desired state
|
202
|
+
# ```
|
203
|
+
#
|
204
|
+
# @param names [Array<Symbol>] A list of property names to set as desired
|
205
|
+
# state.
|
206
|
+
#
|
207
|
+
# @return [Array<Property>] All properties in desired state.
|
208
|
+
#
|
209
|
+
def state_properties(*names)
|
210
|
+
if !names.empty?
|
211
|
+
names = names.map { |name| name.to_sym }.uniq
|
212
|
+
|
213
|
+
local_properties = properties(false)
|
214
|
+
# Add new properties to the list.
|
215
|
+
names.each do |name|
|
216
|
+
property = properties[name]
|
217
|
+
if !property
|
218
|
+
self.property name, instance_variable_name: false, desired_state: true
|
219
|
+
elsif !property.desired_state?
|
220
|
+
self.property name, desired_state: true
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# If state_attrs *excludes* something which is currently desired state,
|
225
|
+
# mark it as desired_state: false.
|
226
|
+
local_properties.each do |name, property|
|
227
|
+
if property.desired_state? && !names.include?(name)
|
228
|
+
self.property name, desired_state: false
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
properties.values.select { |property| property.desired_state? }
|
234
|
+
end
|
235
|
+
|
236
|
+
#
|
237
|
+
# Set the identity of this resource to a particular set of properties.
|
238
|
+
#
|
239
|
+
# This drives #identity, which returns data that uniquely refers to a given
|
240
|
+
# resource on the given node (in such a way that it can be correlated
|
241
|
+
# across Chef runs).
|
242
|
+
#
|
243
|
+
# This method is unnecessary when declaring properties with `property`;
|
244
|
+
# properties can be added to identity during declaration with
|
245
|
+
# `identity: true`.
|
246
|
+
#
|
247
|
+
# ```ruby
|
248
|
+
# property :x, identity: true # part of identity
|
249
|
+
# property :y # not part of identity
|
250
|
+
# ```
|
251
|
+
#
|
252
|
+
# If no properties are marked as identity, "name" is considered the identity.
|
253
|
+
#
|
254
|
+
# @param names [Array<Symbol>] A list of property names to set as the identity.
|
255
|
+
#
|
256
|
+
# @return [Array<Property>] All identity properties.
|
257
|
+
#
|
258
|
+
def identity_properties(*names)
|
259
|
+
if !names.empty?
|
260
|
+
names = names.map { |name| name.to_sym }
|
261
|
+
|
262
|
+
# Add or change properties that are not part of the identity.
|
263
|
+
names.each do |name|
|
264
|
+
property = properties[name]
|
265
|
+
if !property
|
266
|
+
self.property name, instance_variable_name: false, identity: true
|
267
|
+
elsif !property.identity?
|
268
|
+
self.property name, identity: true
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# If identity_properties *excludes* something which is currently part of
|
273
|
+
# the identity, mark it as identity: false.
|
274
|
+
properties.each do |name, property|
|
275
|
+
if property.identity? && !names.include?(name)
|
276
|
+
|
277
|
+
self.property name, identity: false
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
result = properties.values.select { |property| property.identity? }
|
283
|
+
result = [ properties[:name] ] if result.empty?
|
284
|
+
result
|
285
|
+
end
|
286
|
+
|
287
|
+
def included(other)
|
288
|
+
other.extend ClassMethods
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def self.included(other)
|
293
|
+
other.extend ClassMethods
|
294
|
+
end
|
295
|
+
|
296
|
+
include Chef::Mixin::ParamsValidate
|
297
|
+
|
298
|
+
#
|
299
|
+
# Whether this property has been set (or whether it has a default that has
|
300
|
+
# been retrieved).
|
301
|
+
#
|
302
|
+
# @param name [Symbol] The name of the property.
|
303
|
+
# @return [Boolean] `true` if the property has been set.
|
304
|
+
#
|
305
|
+
def property_is_set?(name)
|
306
|
+
property = self.class.properties[name.to_sym]
|
307
|
+
raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property
|
308
|
+
property.is_set?(self)
|
309
|
+
end
|
310
|
+
|
311
|
+
#
|
312
|
+
# Clear this property as if it had never been set. It will thereafter return
|
313
|
+
# the default.
|
314
|
+
# been retrieved).
|
315
|
+
#
|
316
|
+
# @param name [Symbol] The name of the property.
|
317
|
+
#
|
318
|
+
def reset_property(name)
|
319
|
+
property = self.class.properties[name.to_sym]
|
320
|
+
raise ArgumentError, "Property #{name} is not defined in class #{self}" if !property
|
321
|
+
property.reset(self)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|