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/provider/systemd_unit.rb
ADDED
@@ -0,0 +1,253 @@
|
|
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/provider/systemd_unit'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
require 'chef_compat/copied_from_chef'
|
14
|
+
class Chef
|
15
|
+
module ::ChefCompat
|
16
|
+
module CopiedFromChef
|
17
|
+
#
|
18
|
+
# Author:: Nathan Williams (<nath.e.will@gmail.com>)
|
19
|
+
# Copyright:: Copyright 2016, Nathan Williams
|
20
|
+
# License:: Apache License, Version 2.0
|
21
|
+
#
|
22
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
23
|
+
# you may not use this file except in compliance with the License.
|
24
|
+
# You may obtain a copy of the License at
|
25
|
+
#
|
26
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
27
|
+
#
|
28
|
+
# Unless required by applicable law or agreed to in writing, software
|
29
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
30
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
31
|
+
# See the License for the specific language governing permissions and
|
32
|
+
# limitations under the License.
|
33
|
+
#
|
34
|
+
|
35
|
+
require "chef_compat/copied_from_chef/chef/provider"
|
36
|
+
|
37
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
38
|
+
class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object)
|
39
|
+
class SystemdUnit < (defined?(::Chef::Provider::SystemdUnit) ? ::Chef::Provider::SystemdUnit : Chef::Provider)
|
40
|
+
include Chef::Mixin::Which
|
41
|
+
include Chef::Mixin::ShellOut
|
42
|
+
|
43
|
+
provides :systemd_unit, os: "linux"
|
44
|
+
|
45
|
+
def load_current_resource
|
46
|
+
@current_resource = Chef::Resource::SystemdUnit.new(new_resource.name)
|
47
|
+
|
48
|
+
current_resource.content(::File.read(unit_path)) if ::File.exist?(unit_path)
|
49
|
+
current_resource.user(new_resource.user)
|
50
|
+
current_resource.enabled(enabled?)
|
51
|
+
current_resource.active(active?)
|
52
|
+
current_resource.masked(masked?)
|
53
|
+
current_resource.static(static?)
|
54
|
+
current_resource.triggers_reload(new_resource.triggers_reload)
|
55
|
+
|
56
|
+
current_resource
|
57
|
+
end
|
58
|
+
|
59
|
+
def define_resource_requirements
|
60
|
+
super
|
61
|
+
|
62
|
+
requirements.assert(:create) do |a|
|
63
|
+
a.assertion { IniParse.parse(new_resource.to_ini) }
|
64
|
+
a.failure_message "Unit content is not valid INI text"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def action_create
|
69
|
+
if current_resource.content != new_resource.to_ini
|
70
|
+
converge_by("creating unit: #{new_resource.name}") do
|
71
|
+
manage_unit_file(:create)
|
72
|
+
daemon_reload if new_resource.triggers_reload
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def action_delete
|
78
|
+
if ::File.exist?(unit_path)
|
79
|
+
converge_by("deleting unit: #{new_resource.name}") do
|
80
|
+
manage_unit_file(:delete)
|
81
|
+
daemon_reload if new_resource.triggers_reload
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def action_enable
|
87
|
+
if current_resource.static
|
88
|
+
Chef::Log.debug("#{new_resource.name} is a static unit, enabling is a NOP.")
|
89
|
+
end
|
90
|
+
|
91
|
+
unless current_resource.enabled || current_resource.static
|
92
|
+
converge_by("enabling unit: #{new_resource.name}") do
|
93
|
+
systemctl_execute!(:enable, new_resource.name)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def action_disable
|
99
|
+
if current_resource.static
|
100
|
+
Chef::Log.debug("#{new_resource.name} is a static unit, disabling is a NOP.")
|
101
|
+
end
|
102
|
+
|
103
|
+
if current_resource.enabled && !current_resource.static
|
104
|
+
converge_by("disabling unit: #{new_resource.name}") do
|
105
|
+
systemctl_execute!(:disable, new_resource.name)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def action_mask
|
111
|
+
unless current_resource.masked
|
112
|
+
converge_by("masking unit: #{new_resource.name}") do
|
113
|
+
systemctl_execute!(:mask, new_resource.name)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def action_unmask
|
119
|
+
if current_resource.masked
|
120
|
+
converge_by("unmasking unit: #{new_resource.name}") do
|
121
|
+
systemctl_execute!(:unmask, new_resource.name)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def action_start
|
127
|
+
unless current_resource.active
|
128
|
+
converge_by("starting unit: #{new_resource.name}") do
|
129
|
+
systemctl_execute!(:start, new_resource.name)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def action_stop
|
135
|
+
if current_resource.active
|
136
|
+
converge_by("stopping unit: #{new_resource.name}") do
|
137
|
+
systemctl_execute!(:stop, new_resource.name)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def action_restart
|
143
|
+
converge_by("restarting unit: #{new_resource.name}") do
|
144
|
+
systemctl_execute!(:restart, new_resource.name)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def action_reload
|
149
|
+
if current_resource.active
|
150
|
+
converge_by("reloading unit: #{new_resource.name}") do
|
151
|
+
systemctl_execute!(:reload, new_resource.name)
|
152
|
+
end
|
153
|
+
else
|
154
|
+
Chef::Log.debug("#{new_resource.name} is not active, skipping reload.")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def action_try_restart
|
159
|
+
converge_by("try-restarting unit: #{new_resource.name}") do
|
160
|
+
systemctl_execute!("try-restart", new_resource.name)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def action_reload_or_restart
|
165
|
+
converge_by("reload-or-restarting unit: #{new_resource.name}") do
|
166
|
+
systemctl_execute!("reload-or-restart", new_resource.name)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def action_reload_or_try_restart
|
171
|
+
converge_by("reload-or-try-restarting unit: #{new_resource.name}") do
|
172
|
+
systemctl_execute!("reload-or-try-restart", new_resource.name)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def active?
|
177
|
+
systemctl_execute("is-active", new_resource.name).exitstatus == 0
|
178
|
+
end
|
179
|
+
|
180
|
+
def enabled?
|
181
|
+
systemctl_execute("is-enabled", new_resource.name).exitstatus == 0
|
182
|
+
end
|
183
|
+
|
184
|
+
def masked?
|
185
|
+
systemctl_execute(:status, new_resource.name).stdout.include?("masked")
|
186
|
+
end
|
187
|
+
|
188
|
+
def static?
|
189
|
+
systemctl_execute("is-enabled", new_resource.name).stdout.include?("static")
|
190
|
+
end
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
def unit_path
|
195
|
+
if new_resource.user
|
196
|
+
"/etc/systemd/user/#{new_resource.name}"
|
197
|
+
else
|
198
|
+
"/etc/systemd/system/#{new_resource.name}"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def manage_unit_file(action = :nothing)
|
203
|
+
Chef::Resource::File.new(unit_path, run_context).tap do |f|
|
204
|
+
f.owner "root"
|
205
|
+
f.group "root"
|
206
|
+
f.mode "0644"
|
207
|
+
f.content new_resource.to_ini
|
208
|
+
end.run_action(action)
|
209
|
+
end
|
210
|
+
|
211
|
+
def daemon_reload
|
212
|
+
shell_out_with_systems_locale!("#{systemctl_path} daemon-reload")
|
213
|
+
end
|
214
|
+
|
215
|
+
def systemctl_execute!(action, unit)
|
216
|
+
shell_out_with_systems_locale!("#{systemctl_cmd} #{action} #{unit}", systemctl_opts)
|
217
|
+
end
|
218
|
+
|
219
|
+
def systemctl_execute(action, unit)
|
220
|
+
shell_out("#{systemctl_cmd} #{action} #{unit}", systemctl_opts)
|
221
|
+
end
|
222
|
+
|
223
|
+
def systemctl_cmd
|
224
|
+
@systemctl_cmd ||= "#{systemctl_path} #{systemctl_args}"
|
225
|
+
end
|
226
|
+
|
227
|
+
def systemctl_path
|
228
|
+
@systemctl_path ||= which("systemctl")
|
229
|
+
end
|
230
|
+
|
231
|
+
def systemctl_args
|
232
|
+
@systemctl_args ||= new_resource.user ? "--user" : "--system"
|
233
|
+
end
|
234
|
+
|
235
|
+
def systemctl_opts
|
236
|
+
@systemctl_opts ||=
|
237
|
+
if new_resource.user
|
238
|
+
{
|
239
|
+
:user => new_resource.user,
|
240
|
+
:environment => {
|
241
|
+
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{node['etc']['passwd'][new_resource.user]['uid']}/bus",
|
242
|
+
},
|
243
|
+
}
|
244
|
+
else
|
245
|
+
{}
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
@@ -0,0 +1,136 @@
|
|
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/provider/yum_repository'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
require 'chef_compat/copied_from_chef'
|
14
|
+
class Chef
|
15
|
+
module ::ChefCompat
|
16
|
+
module CopiedFromChef
|
17
|
+
#
|
18
|
+
# Author:: Thom May (<thom@chef.io>)
|
19
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
20
|
+
# License:: Apache License, Version 2.0
|
21
|
+
#
|
22
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
23
|
+
# you may not use this file except in compliance with the License.
|
24
|
+
# You may obtain a copy of the License at
|
25
|
+
#
|
26
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
27
|
+
#
|
28
|
+
# Unless required by applicable law or agreed to in writing, software
|
29
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
30
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
31
|
+
# See the License for the specific language governing permissions and
|
32
|
+
# limitations under the License.
|
33
|
+
#
|
34
|
+
|
35
|
+
require "chef_compat/copied_from_chef/chef/resource"
|
36
|
+
require "chef_compat/copied_from_chef/chef/dsl/declare_resource"
|
37
|
+
require "chef_compat/copied_from_chef/chef/provider/noop"
|
38
|
+
|
39
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
40
|
+
class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object)
|
41
|
+
class YumRepository < (defined?(::Chef::Provider::YumRepository) ? ::Chef::Provider::YumRepository : Chef::Provider)
|
42
|
+
use_inline_resources
|
43
|
+
|
44
|
+
extend Chef::Mixin::Which
|
45
|
+
|
46
|
+
provides :yum_repository do
|
47
|
+
which "yum"
|
48
|
+
end
|
49
|
+
|
50
|
+
def whyrun_supported?; true; end
|
51
|
+
|
52
|
+
def load_current_resource; end
|
53
|
+
|
54
|
+
action :create do
|
55
|
+
declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
|
56
|
+
if template_available?(new_resource.source)
|
57
|
+
source new_resource.source
|
58
|
+
else
|
59
|
+
source ::File.expand_path("../support/yum_repo.erb", __FILE__)
|
60
|
+
local true
|
61
|
+
end
|
62
|
+
sensitive new_resource.sensitive
|
63
|
+
variables(config: new_resource)
|
64
|
+
mode new_resource.mode
|
65
|
+
if new_resource.make_cache
|
66
|
+
notifies :run, "execute[yum clean metadata #{new_resource.repositoryid}]", :immediately if new_resource.clean_metadata || new_resource.clean_headers
|
67
|
+
notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
|
68
|
+
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
declare_resource(:execute, "yum clean metadata #{new_resource.repositoryid}") do
|
73
|
+
command "yum clean metadata --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
74
|
+
action :nothing
|
75
|
+
end
|
76
|
+
|
77
|
+
# get the metadata for this repo only
|
78
|
+
declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do
|
79
|
+
command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
80
|
+
action :nothing
|
81
|
+
only_if { new_resource.enabled }
|
82
|
+
end
|
83
|
+
|
84
|
+
# reload internal Chef yum cache
|
85
|
+
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
|
86
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
87
|
+
action :nothing
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
action :delete do
|
92
|
+
# clean the repo cache first
|
93
|
+
declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do
|
94
|
+
command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
95
|
+
only_if "yum repolist all | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
|
96
|
+
end
|
97
|
+
|
98
|
+
declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
|
99
|
+
action :delete
|
100
|
+
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
|
101
|
+
end
|
102
|
+
|
103
|
+
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
|
104
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
105
|
+
action :nothing
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
action :makecache do
|
110
|
+
declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do
|
111
|
+
command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
112
|
+
action :run
|
113
|
+
only_if { new_resource.enabled }
|
114
|
+
end
|
115
|
+
|
116
|
+
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
|
117
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
118
|
+
action :run
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
alias_method :action_add, :action_create
|
123
|
+
alias_method :action_remove, :action_delete
|
124
|
+
|
125
|
+
def template_available?(path)
|
126
|
+
!path.nil? && run_context.has_template_in_cookbook?(new_resource.cookbook_name, path)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
Chef::Provider::Noop.provides :yum_repository
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,164 @@
|
|
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/provider'
|
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/dsl/core"
|
18
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
19
|
+
class Provider < (defined?(::Chef::Provider) ? ::Chef::Provider : Object)
|
20
|
+
include Chef::DSL::Core
|
21
|
+
attr_accessor :action
|
22
|
+
def initialize(new_resource, run_context)
|
23
|
+
super if defined?(::Chef::Provider)
|
24
|
+
@new_resource = new_resource
|
25
|
+
@action = action
|
26
|
+
@current_resource = nil
|
27
|
+
@run_context = run_context
|
28
|
+
@converge_actions = nil
|
29
|
+
|
30
|
+
@recipe_name = nil
|
31
|
+
@cookbook_name = nil
|
32
|
+
self.class.include_resource_dsl_module(new_resource)
|
33
|
+
end
|
34
|
+
def converge_if_changed(*properties, &converge_block)
|
35
|
+
if !converge_block
|
36
|
+
raise ArgumentError, "converge_if_changed must be passed a block!"
|
37
|
+
end
|
38
|
+
|
39
|
+
properties = new_resource.class.state_properties.map { |p| p.name } if properties.empty?
|
40
|
+
properties = properties.map { |p| p.to_sym }
|
41
|
+
if current_resource
|
42
|
+
# Collect the list of modified properties
|
43
|
+
specified_properties = properties.select { |property| new_resource.property_is_set?(property) }
|
44
|
+
modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) }
|
45
|
+
if modified.empty?
|
46
|
+
properties_str = if sensitive
|
47
|
+
specified_properties.join(", ")
|
48
|
+
else
|
49
|
+
specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ")
|
50
|
+
end
|
51
|
+
Chef::Log.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.")
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
|
55
|
+
# Print the pretty green text and run the block
|
56
|
+
property_size = modified.map { |p| p.size }.max
|
57
|
+
modified.map! do |p|
|
58
|
+
properties_str = if sensitive
|
59
|
+
"(suppressed sensitive property)"
|
60
|
+
else
|
61
|
+
"#{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})"
|
62
|
+
end
|
63
|
+
" set #{p.to_s.ljust(property_size)} to #{properties_str}"
|
64
|
+
end
|
65
|
+
converge_by([ "update #{current_resource.identity}" ] + modified, &converge_block)
|
66
|
+
|
67
|
+
else
|
68
|
+
# The resource doesn't exist. Mark that we are *creating* this, and
|
69
|
+
# write down any properties we are setting.
|
70
|
+
property_size = properties.map { |p| p.size }.max
|
71
|
+
created = properties.map do |property|
|
72
|
+
default = " (default value)" unless new_resource.property_is_set?(property)
|
73
|
+
properties_str = if sensitive
|
74
|
+
"(suppressed sensitive property)"
|
75
|
+
else
|
76
|
+
new_resource.send(property).inspect
|
77
|
+
end
|
78
|
+
" set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}"
|
79
|
+
end
|
80
|
+
|
81
|
+
converge_by([ "create #{new_resource.identity}" ] + created, &converge_block)
|
82
|
+
end
|
83
|
+
true
|
84
|
+
end
|
85
|
+
def self.include_resource_dsl(include_resource_dsl)
|
86
|
+
@include_resource_dsl = include_resource_dsl
|
87
|
+
end
|
88
|
+
def self.include_resource_dsl_module(resource)
|
89
|
+
if @include_resource_dsl && !defined?(@included_resource_dsl_module)
|
90
|
+
provider_class = self
|
91
|
+
@included_resource_dsl_module = Module.new do
|
92
|
+
extend Forwardable
|
93
|
+
define_singleton_method(:to_s) { "forwarder module for #{provider_class}" }
|
94
|
+
define_singleton_method(:inspect) { to_s }
|
95
|
+
# Add a delegator for each explicit property that will get the *current* value
|
96
|
+
# of the property by default instead of the *actual* value.
|
97
|
+
resource.class.properties.each do |name, property|
|
98
|
+
class_eval(<<-EOM, __FILE__, __LINE__)
|
99
|
+
def #{name}(*args, &block)
|
100
|
+
# If no arguments were passed, we process "get" by defaulting
|
101
|
+
# the value to current_resource, not new_resource. This helps
|
102
|
+
# avoid issues where resources accidentally overwrite perfectly
|
103
|
+
# valid stuff with default values.
|
104
|
+
if args.empty? && !block
|
105
|
+
if !new_resource.property_is_set?(__method__) && current_resource
|
106
|
+
return current_resource.public_send(__method__)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
new_resource.public_send(__method__, *args, &block)
|
110
|
+
end
|
111
|
+
EOM
|
112
|
+
end
|
113
|
+
dsl_methods =
|
114
|
+
resource.class.public_instance_methods +
|
115
|
+
resource.class.protected_instance_methods -
|
116
|
+
provider_class.instance_methods -
|
117
|
+
resource.class.properties.keys
|
118
|
+
def_delegators(:new_resource, *dsl_methods)
|
119
|
+
end
|
120
|
+
include @included_resource_dsl_module
|
121
|
+
end
|
122
|
+
end
|
123
|
+
def self.use_inline_resources
|
124
|
+
extend InlineResources::ClassMethods
|
125
|
+
include InlineResources
|
126
|
+
end
|
127
|
+
module InlineResources
|
128
|
+
CopiedFromChef.extend_chef_module(::Chef::Provider::InlineResources, self) if defined?(::Chef::Provider::InlineResources)
|
129
|
+
def compile_and_converge_action(&block)
|
130
|
+
old_run_context = run_context
|
131
|
+
@run_context = run_context.create_child
|
132
|
+
return_value = instance_eval(&block)
|
133
|
+
Chef::Runner.new(run_context).converge
|
134
|
+
return_value
|
135
|
+
ensure
|
136
|
+
if run_context.resource_collection.any? { |r| r.updated? }
|
137
|
+
new_resource.updated_by_last_action(true)
|
138
|
+
end
|
139
|
+
@run_context = old_run_context
|
140
|
+
end
|
141
|
+
module ClassMethods
|
142
|
+
CopiedFromChef.extend_chef_module(::Chef::Provider::InlineResources::ClassMethods, self) if defined?(::Chef::Provider::InlineResources::ClassMethods)
|
143
|
+
def action(name, &block)
|
144
|
+
# We need the block directly in a method so that `super` works
|
145
|
+
define_method("compile_action_#{name}", &block)
|
146
|
+
# We try hard to use `def` because define_method doesn't show the method name in the stack.
|
147
|
+
begin
|
148
|
+
class_eval <<-EOM
|
149
|
+
def action_#{name}
|
150
|
+
compile_and_converge_action { compile_action_#{name} }
|
151
|
+
end
|
152
|
+
EOM
|
153
|
+
rescue SyntaxError
|
154
|
+
define_method("action_#{name}") { send("compile_action_#{name}") }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
protected
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb
ADDED
@@ -0,0 +1,114 @@
|
|
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/resource/action_class'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
require 'chef_compat/copied_from_chef'
|
14
|
+
class Chef
|
15
|
+
module ::ChefCompat
|
16
|
+
module CopiedFromChef
|
17
|
+
#
|
18
|
+
# Author:: John Keiser (<jkeiser@chef.io)
|
19
|
+
# Copyright:: Copyright 2015-2016, Chef Software Inc.
|
20
|
+
# License:: Apache License, Version 2.0
|
21
|
+
#
|
22
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
23
|
+
# you may not use this file except in compliance with the License.
|
24
|
+
# You may obtain a copy of the License at
|
25
|
+
#
|
26
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
27
|
+
#
|
28
|
+
# Unless required by applicable law or agreed to in writing, software
|
29
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
30
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
31
|
+
# See the License for the specific language governing permissions and
|
32
|
+
# limitations under the License.
|
33
|
+
#
|
34
|
+
|
35
|
+
require "chef_compat/copied_from_chef/chef/dsl/recipe"
|
36
|
+
|
37
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
38
|
+
class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object)
|
39
|
+
module ActionClass
|
40
|
+
CopiedFromChef.extend_chef_module(::Chef::Resource::ActionClass, self) if defined?(::Chef::Resource::ActionClass)
|
41
|
+
include Chef::DSL::Recipe
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
"#{new_resource || "<no resource>"} action #{action ? action.inspect : "<no action>"}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def whyrun_supported?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# If load_current_value! is defined on the resource, use that.
|
53
|
+
#
|
54
|
+
def load_current_resource
|
55
|
+
if new_resource.respond_to?(:load_current_value!)
|
56
|
+
# dup the resource and then reset desired-state properties.
|
57
|
+
current_resource = new_resource.dup
|
58
|
+
|
59
|
+
# We clear desired state in the copy, because it is supposed to be actual state.
|
60
|
+
# We keep identity properties and non-desired-state, which are assumed to be
|
61
|
+
# "control" values like `recurse: true`
|
62
|
+
current_resource.class.properties.each do |name, property|
|
63
|
+
if property.desired_state? && !property.identity? && !property.name_property?
|
64
|
+
property.reset(current_resource)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Call the actual load_current_value! method. If it raises
|
69
|
+
# CurrentValueDoesNotExist, set current_resource to `nil`.
|
70
|
+
begin
|
71
|
+
# If the user specifies load_current_value do |desired_resource|, we
|
72
|
+
# pass in the desired resource as well as the current one.
|
73
|
+
if current_resource.method(:load_current_value!).arity > 0
|
74
|
+
current_resource.load_current_value!(new_resource)
|
75
|
+
else
|
76
|
+
current_resource.load_current_value!
|
77
|
+
end
|
78
|
+
rescue Chef::Exceptions::CurrentValueDoesNotExist
|
79
|
+
current_resource = nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
@current_resource = current_resource
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.included(other)
|
87
|
+
other.extend(ClassMethods)
|
88
|
+
other.use_inline_resources
|
89
|
+
other.include_resource_dsl true
|
90
|
+
end
|
91
|
+
|
92
|
+
module ClassMethods
|
93
|
+
CopiedFromChef.extend_chef_module(::Chef::Resource::ActionClass::ClassMethods, self) if defined?(::Chef::Resource::ActionClass::ClassMethods)
|
94
|
+
#
|
95
|
+
# The Chef::Resource class this ActionClass was declared against.
|
96
|
+
#
|
97
|
+
# @return [Class] The Chef::Resource class this ActionClass was declared against.
|
98
|
+
#
|
99
|
+
attr_accessor :resource_class
|
100
|
+
|
101
|
+
def to_s
|
102
|
+
"#{resource_class} action provider"
|
103
|
+
end
|
104
|
+
|
105
|
+
def inspect
|
106
|
+
to_s
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|