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
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook:: build-essential
|
3
|
+
# Resource:: xcode_command_line_tools
|
4
|
+
#
|
5
|
+
# Copyright:: 2014-2017, Chef Software, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
resource_name :xcode_command_line_tools
|
21
|
+
|
22
|
+
action :install do
|
23
|
+
if installed?
|
24
|
+
Chef::Log.debug("#{new_resource} already installed - skipping")
|
25
|
+
else
|
26
|
+
converge_by("Install #{new_resource}") do
|
27
|
+
# This script was graciously borrowed and modified from Tim Sutton's
|
28
|
+
# osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh
|
29
|
+
execute 'install XCode Command Line tools' do
|
30
|
+
command <<-EOH.gsub(/^ {14}/, '')
|
31
|
+
# create the placeholder file that's checked by CLI updates' .dist code
|
32
|
+
# in Apple's SUS catalog
|
33
|
+
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
|
34
|
+
# find the CLI Tools update
|
35
|
+
PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
|
36
|
+
# install it
|
37
|
+
softwareupdate -i "$PROD" --verbose
|
38
|
+
# Remove the placeholder to prevent perpetual appearance in the update utility
|
39
|
+
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
|
40
|
+
EOH
|
41
|
+
# rubocop:enable Metrics/LineLength
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
action_class do
|
48
|
+
#
|
49
|
+
# Determine if the XCode Command Line Tools are installed
|
50
|
+
#
|
51
|
+
# @return [true, false]
|
52
|
+
#
|
53
|
+
def installed?
|
54
|
+
cmd = Mixlib::ShellOut.new('pkgutil --pkgs=com.apple.pkg.CLTools_Executables')
|
55
|
+
cmd.run_command
|
56
|
+
cmd.error!
|
57
|
+
true
|
58
|
+
rescue Mixlib::ShellOut::ShellCommandFailed
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# compat_resource Cookbook CHANGELOG
|
2
|
+
|
3
|
+
This file is used to list changes made in each version of the compat_resource cookbook.
|
4
|
+
|
5
|
+
## 12.19.0 (2017-04-17)
|
6
|
+
|
7
|
+
- Suppress warning already initialized constant
|
8
|
+
- Backport yum/apt changes from 12.19
|
9
|
+
|
10
|
+
## 12.16.2 (2016-11-09)
|
11
|
+
|
12
|
+
- Sync chef-client changes from Chef 12.16.42
|
13
|
+
|
14
|
+
## 12.16.1 (2016-10-20)
|
15
|
+
|
16
|
+
- add delayed_action helper
|
17
|
+
|
18
|
+
## 12.16.0 (2016-10-19)
|
19
|
+
|
20
|
+
- Sync chef-client changes from Chef 12.16.14
|
21
|
+
|
22
|
+
## 12.14.7 (2016-09-26)
|
23
|
+
|
24
|
+
- Update to 12.14.89 Chef
|
25
|
+
- Fix autoload by applying fix from #106
|
26
|
+
|
27
|
+
## 12.14.6 (2016-09-20)
|
28
|
+
|
29
|
+
- Update backported codebase to Chef 12.14.77 which brings in yum_repository updates and why-run enabled by default in custom resources
|
30
|
+
|
31
|
+
## 12.14.5 (2016-09-19)
|
32
|
+
|
33
|
+
- Prevent spamming messages in Chefspec runs for cookbooks that depend on compat_resource
|
34
|
+
|
35
|
+
## 12.14.4 (2016-09-19)
|
36
|
+
|
37
|
+
- Fix delayed notifications cloning
|
38
|
+
|
39
|
+
## 12.14.3 (2016-09-12)
|
40
|
+
|
41
|
+
- Fix subscribes notifications
|
42
|
+
|
43
|
+
## 12.14.2 (2016-09-09)
|
44
|
+
|
45
|
+
- Improve documentation
|
46
|
+
- keep ChefCompat::Resource defined even if we don't load
|
47
|
+
|
48
|
+
## 12.14.1 (2016-09-07)
|
49
|
+
|
50
|
+
- add yum_repository resource from Chef 12.14
|
51
|
+
- Update the minimum chef version in the metadata to 12.1
|
52
|
+
- Added maintainers files
|
53
|
+
- suppress constant redef warnings when running chefspec
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!-- This is a generated file. Please do not edit directly -->
|
2
|
+
|
3
|
+
# Maintainers
|
4
|
+
|
5
|
+
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
|
6
|
+
|
7
|
+
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
|
8
|
+
|
9
|
+
# Project Maintainer
|
10
|
+
* [Lamont Granquist](https://github.com/lamont-granquist)
|
11
|
+
|
12
|
+
# Maintainers
|
13
|
+
* [Jennifer Davis](https://github.com/sigje)
|
14
|
+
* [Tim Smith](https://github.com/tas50)
|
15
|
+
* [Thom May](https://github.com/thommay)
|
16
|
+
* [Lamont Granquist](https://github.com/lamont-granquist)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# compat_resource cookbook
|
2
|
+
|
3
|
+
[](https://travis-ci.org/chef-cookbooks/compat_resource) [](https://supermarket.chef.io/cookbooks/compat_resource)
|
4
|
+
|
5
|
+
This cookbook backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards. This includes [Custom Resource](https://docs.chef.io/custom_resources.html) functionality, notification improvements, as well as new resources added to core chef. It allows for the usage of these new resources in cookbooks without requiring the very latest Chef client release.
|
6
|
+
|
7
|
+
## Backported functionality
|
8
|
+
|
9
|
+
- [Custom Resources](https://docs.chef.io/custom_resources.html)
|
10
|
+
- [apt_repository](https://docs.chef.io/resource_apt_repository.html)
|
11
|
+
- [apt_update](https://docs.chef.io/resource_apt_update.html)
|
12
|
+
- [systemd_unit](https://docs.chef.io/resource_systemd_unit.html)
|
13
|
+
- [yum_repository](https://docs.chef.io/resource_yum_repository.html)
|
14
|
+
- [:before notifications](https://docs.chef.io/resources.html#timers)
|
15
|
+
|
16
|
+
## Requirements
|
17
|
+
|
18
|
+
### Platforms
|
19
|
+
|
20
|
+
- All platforms supported by Chef
|
21
|
+
|
22
|
+
### Chef
|
23
|
+
|
24
|
+
- Chef 12.1+
|
25
|
+
|
26
|
+
### Cookbooks
|
27
|
+
|
28
|
+
- none
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
To use this cookbook, put `depends 'compat_resource'` in the metadata.rb of your cookbook. Once this is done, you can use all the new custom resource features to define resources. It Just Works.
|
33
|
+
|
34
|
+
## Custom Resources?
|
35
|
+
|
36
|
+
Curious about how to use custom resources?
|
37
|
+
|
38
|
+
- Docs: <https://docs.chef.io/custom_resources.html>
|
39
|
+
- Slides: <https://docs.chef.io/decks/custom_resources.html>
|
40
|
+
|
41
|
+
## License & Authors
|
42
|
+
|
43
|
+
- Author:: Lamont Granquist ([lamont@chef.io](mailto:lamont@chef.io))
|
44
|
+
- Author:: John Keiser ([jkeiser@chef.io](mailto:jkeiser@chef.io))
|
45
|
+
|
46
|
+
```text
|
47
|
+
Copyright:: 2015-2016 Chef Software, Inc.
|
48
|
+
|
49
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
50
|
+
you may not use this file except in compliance with the License.
|
51
|
+
You may obtain a copy of the License at
|
52
|
+
|
53
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
54
|
+
|
55
|
+
Unless required by applicable law or agreed to in writing, software
|
56
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
57
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
58
|
+
See the License for the specific language governing permissions and
|
59
|
+
limitations under the License.
|
60
|
+
```
|
@@ -0,0 +1,47 @@
|
|
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/constants'
|
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
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
35
|
+
NOT_PASSED = Object.new
|
36
|
+
def NOT_PASSED.to_s
|
37
|
+
"NOT_PASSED"
|
38
|
+
end
|
39
|
+
|
40
|
+
def NOT_PASSED.inspect
|
41
|
+
to_s
|
42
|
+
end
|
43
|
+
NOT_PASSED.freeze
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb
ADDED
@@ -0,0 +1,40 @@
|
|
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/delayed_evaluator'
|
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
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
35
|
+
class DelayedEvaluator < (defined?(::Chef::DelayedEvaluator) ? ::Chef::DelayedEvaluator : Proc)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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/dsl/core'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
require 'chef_compat/copied_from_chef'
|
14
|
+
class Chef
|
15
|
+
module ::ChefCompat
|
16
|
+
module CopiedFromChef
|
17
|
+
#--
|
18
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
19
|
+
# Author:: Christopher Walters (<cw@chef.io>)
|
20
|
+
# Copyright:: Copyright 2008-2016 Chef Software, Inc.
|
21
|
+
# License:: Apache License, Version 2.0
|
22
|
+
#
|
23
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
24
|
+
# you may not use this file except in compliance with the License.
|
25
|
+
# You may obtain a copy of the License at
|
26
|
+
#
|
27
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
28
|
+
#
|
29
|
+
# Unless required by applicable law or agreed to in writing, software
|
30
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
31
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
32
|
+
# See the License for the specific language governing permissions and
|
33
|
+
# limitations under the License.
|
34
|
+
#
|
35
|
+
|
36
|
+
require "chef_compat/copied_from_chef/chef/dsl/declare_resource"
|
37
|
+
require "chef_compat/copied_from_chef/chef/dsl/universal"
|
38
|
+
require "chef_compat/copied_from_chef/chef/mixin/notifying_block"
|
39
|
+
require "chef_compat/copied_from_chef/chef/mixin/lazy_module_include"
|
40
|
+
|
41
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
42
|
+
module DSL
|
43
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
|
44
|
+
# Part of a family of DSL mixins.
|
45
|
+
#
|
46
|
+
# Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
|
47
|
+
# - this does not target core chef resources and providers.
|
48
|
+
# - this is restricted to recipe/resource/provider context where a resource collection exists.
|
49
|
+
# - cookbook authors should typically include modules into here.
|
50
|
+
#
|
51
|
+
# Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
|
52
|
+
# - this adds cores providers on top of the Recipe DSL.
|
53
|
+
# - this is restricted to recipe/resource/provider context where a resource collection exists.
|
54
|
+
# - core chef authors should typically include modules into here.
|
55
|
+
#
|
56
|
+
# Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
|
57
|
+
# - this adds resources and attributes files.
|
58
|
+
# - do not add helpers which manipulate the resource collection.
|
59
|
+
# - this is for general-purpose stuff that is useful nearly everywhere.
|
60
|
+
# - it also pollutes the namespace of nearly every context, watch out.
|
61
|
+
#
|
62
|
+
module Core
|
63
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL::Core, self) if defined?(::Chef::DSL::Core)
|
64
|
+
include Chef::DSL::Universal
|
65
|
+
include Chef::DSL::DeclareResource
|
66
|
+
include Chef::Mixin::NotifyingBlock
|
67
|
+
extend Chef::Mixin::LazyModuleInclude
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb
ADDED
@@ -0,0 +1,315 @@
|
|
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/dsl/declare_resource'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
require 'chef_compat/copied_from_chef'
|
14
|
+
class Chef
|
15
|
+
module ::ChefCompat
|
16
|
+
module CopiedFromChef
|
17
|
+
#--
|
18
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
19
|
+
# Author:: Christopher Walters
|
20
|
+
# Copyright:: Copyright 2008-2016 Chef Software, Inc.
|
21
|
+
# License:: Apache License, Version 2.0
|
22
|
+
#
|
23
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
24
|
+
# you may not use this file except in compliance with the License.
|
25
|
+
# You may obtain a copy of the License at
|
26
|
+
#
|
27
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
28
|
+
#
|
29
|
+
# Unless required by applicable law or agreed to in writing, software
|
30
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
31
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
32
|
+
# See the License for the specific language governing permissions and
|
33
|
+
# limitations under the License.
|
34
|
+
#
|
35
|
+
|
36
|
+
|
37
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
38
|
+
module DSL
|
39
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
|
40
|
+
module DeclareResource
|
41
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL::DeclareResource, self) if defined?(::Chef::DSL::DeclareResource)
|
42
|
+
|
43
|
+
# Helper for switching run_contexts. Allows for using :parent or :root in place of
|
44
|
+
# passing the run_context. Executes the block in the run_context. Returns the return
|
45
|
+
# value of the passed block.
|
46
|
+
#
|
47
|
+
# @param rc [Chef::RunContext,Symbol] Either :root, :parent or a Chef::RunContext
|
48
|
+
#
|
49
|
+
# @return return value of the block
|
50
|
+
#
|
51
|
+
# @example
|
52
|
+
# # creates/returns a 'service[foo]' resource in the root run_context
|
53
|
+
# resource = with_run_context(:root)
|
54
|
+
# edit_resource(:service, "foo") do
|
55
|
+
# action :nothing
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
def with_run_context(rc)
|
60
|
+
raise ArgumentError, "with_run_context is useless without a block" unless block_given?
|
61
|
+
old_run_context = @run_context
|
62
|
+
@run_context =
|
63
|
+
case rc
|
64
|
+
when Chef::RunContext
|
65
|
+
rc
|
66
|
+
when :root
|
67
|
+
run_context.root_run_context
|
68
|
+
when :parent
|
69
|
+
run_context.parent_run_context
|
70
|
+
else
|
71
|
+
raise ArgumentError, "bad argument to run_context helper, must be :root, :parent, or a Chef::RunContext"
|
72
|
+
end
|
73
|
+
yield
|
74
|
+
ensure
|
75
|
+
@run_context = old_run_context
|
76
|
+
end
|
77
|
+
|
78
|
+
# Lookup a resource in the resource collection by name and delete it. This
|
79
|
+
# will raise Chef::Exceptions::ResourceNotFound if the resource is not found.
|
80
|
+
#
|
81
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
82
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
83
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
84
|
+
#
|
85
|
+
# @return [Chef::Resource] The resource
|
86
|
+
#
|
87
|
+
# @example
|
88
|
+
# delete_resource!(:template, '/x/y.txy')
|
89
|
+
#
|
90
|
+
def delete_resource!(type, name, run_context: self.run_context)
|
91
|
+
run_context.resource_collection.delete("#{type}[#{name}]").tap do |resource|
|
92
|
+
# Purge any pending notifications too. This will not raise an exception
|
93
|
+
# if there are no notifications.
|
94
|
+
if resource
|
95
|
+
run_context.before_notification_collection.delete(resource.declared_key)
|
96
|
+
run_context.immediate_notification_collection.delete(resource.declared_key)
|
97
|
+
run_context.delayed_notification_collection.delete(resource.declared_key)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Lookup a resource in the resource collection by name and delete it. Returns
|
103
|
+
# nil if the resource is not found and should not fail.
|
104
|
+
#
|
105
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
106
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
107
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
108
|
+
#
|
109
|
+
# @return [Chef::Resource] The resource
|
110
|
+
#
|
111
|
+
# @example
|
112
|
+
# delete_resource(:template, '/x/y.txy')
|
113
|
+
#
|
114
|
+
def delete_resource(type, name, run_context: self.run_context)
|
115
|
+
delete_resource!(type, name, run_context: run_context)
|
116
|
+
rescue Chef::Exceptions::ResourceNotFound
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
|
120
|
+
# Lookup a resource in the resource collection by name and edit the resource. If the resource is not
|
121
|
+
# found this will raise Chef::Exceptions::ResourceNotFound. This is the correct API to use for
|
122
|
+
# "chef_rewind" functionality.
|
123
|
+
#
|
124
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
125
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
126
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
127
|
+
# @param resource_attrs_block A block that lets you set attributes of the
|
128
|
+
# resource (it is instance_eval'd on the resource instance).
|
129
|
+
#
|
130
|
+
# @return [Chef::Resource] The updated resource
|
131
|
+
#
|
132
|
+
# @example
|
133
|
+
# edit_resource!(:template, '/x/y.txy') do
|
134
|
+
# cookbook_name: cookbook_name
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
def edit_resource!(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
|
138
|
+
resource = find_resource!(type, name, run_context: run_context)
|
139
|
+
if resource_attrs_block
|
140
|
+
if defined?(new_resource)
|
141
|
+
resource.instance_exec(new_resource, &resource_attrs_block)
|
142
|
+
else
|
143
|
+
resource.instance_exec(&resource_attrs_block)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
resource
|
147
|
+
end
|
148
|
+
|
149
|
+
# Lookup a resource in the resource collection by name. If it exists,
|
150
|
+
# return it. If it does not exist, create it. This is a useful function
|
151
|
+
# for accumulator patterns. In CRUD terminology this is an "upsert" operation and is
|
152
|
+
# used to assert that the resource must exist with the specified properties.
|
153
|
+
#
|
154
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
155
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
156
|
+
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
157
|
+
# to get the caller of your function. Defaults to the caller of this
|
158
|
+
# function.
|
159
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
160
|
+
# @param resource_attrs_block A block that lets you set attributes of the
|
161
|
+
# resource (it is instance_eval'd on the resource instance).
|
162
|
+
#
|
163
|
+
# @return [Chef::Resource] The updated or created resource
|
164
|
+
#
|
165
|
+
# @example
|
166
|
+
# resource = edit_resource(:template, '/x/y.txy') do
|
167
|
+
# source "y.txy.erb"
|
168
|
+
# variables {}
|
169
|
+
# end
|
170
|
+
# resource.variables.merge!({ home: "/home/klowns" })
|
171
|
+
#
|
172
|
+
def edit_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
|
173
|
+
edit_resource!(type, name, created_at, run_context: run_context, &resource_attrs_block)
|
174
|
+
rescue Chef::Exceptions::ResourceNotFound
|
175
|
+
declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Lookup a resource in the resource collection by name. If the resource is not
|
179
|
+
# found this will raise Chef::Exceptions::ResourceNotFound. This API is identical to the
|
180
|
+
# resources() call and while it is a synonym it is not intended to deprecate that call.
|
181
|
+
#
|
182
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
183
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
184
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
185
|
+
#
|
186
|
+
# @return [Chef::Resource] The updated resource
|
187
|
+
#
|
188
|
+
# @example
|
189
|
+
# resource = find_resource!(:template, '/x/y.txy')
|
190
|
+
#
|
191
|
+
def find_resource!(type, name, run_context: self.run_context)
|
192
|
+
raise ArgumentError, "find_resource! does not take a block" if block_given?
|
193
|
+
run_context.resource_collection.find(type => name)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Lookup a resource in the resource collection by name. If the resource is not found
|
197
|
+
# the will be no exception raised and the call will return nil. If a block is given and
|
198
|
+
# no resource is found it will create the resource using the block, if the resource is
|
199
|
+
# found then the block will not be applied. The block version is similar to create_if_missing
|
200
|
+
#
|
201
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
202
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
203
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
204
|
+
#
|
205
|
+
# @return [Chef::Resource] The updated resource
|
206
|
+
#
|
207
|
+
# @example
|
208
|
+
# if ( find_resource(:template, '/x/y.txy') )
|
209
|
+
# # do something
|
210
|
+
# else
|
211
|
+
# # don't worry about the error
|
212
|
+
# end
|
213
|
+
#
|
214
|
+
# @example
|
215
|
+
# # this API can be used to return a resource from an outer run context, and will only create
|
216
|
+
# # an action :nothing service if one does not already exist.
|
217
|
+
# resource = with_run_context(:root) do
|
218
|
+
# find_resource(:service, 'whatever') do
|
219
|
+
# action :nothing
|
220
|
+
# end
|
221
|
+
# end
|
222
|
+
#
|
223
|
+
def find_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block)
|
224
|
+
find_resource!(type, name, run_context: run_context)
|
225
|
+
rescue Chef::Exceptions::ResourceNotFound
|
226
|
+
if resource_attrs_block
|
227
|
+
declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
|
228
|
+
end # returns nil otherwise
|
229
|
+
end
|
230
|
+
|
231
|
+
# Instantiates a resource (via #build_resource), then adds it to the
|
232
|
+
# resource collection. Note that resource classes are looked up directly,
|
233
|
+
# so this will create the resource you intended even if the method name
|
234
|
+
# corresponding to that resource has been overridden.
|
235
|
+
#
|
236
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
237
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
238
|
+
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
239
|
+
# to get the caller of your function. Defaults to the caller of this
|
240
|
+
# function.
|
241
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
242
|
+
# @param resource_attrs_block A block that lets you set attributes of the
|
243
|
+
# resource (it is instance_eval'd on the resource instance).
|
244
|
+
#
|
245
|
+
# @return [Chef::Resource] The new resource.
|
246
|
+
#
|
247
|
+
# @example
|
248
|
+
# declare_resource(:file, '/x/y.txy', caller[0]) do
|
249
|
+
# action :delete
|
250
|
+
# end
|
251
|
+
# # Equivalent to
|
252
|
+
# file '/x/y.txt' do
|
253
|
+
# action :delete
|
254
|
+
# end
|
255
|
+
#
|
256
|
+
def declare_resource(type, name, created_at = nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
|
257
|
+
created_at ||= caller[0]
|
258
|
+
|
259
|
+
if create_if_missing
|
260
|
+
Chef::Log.deprecation "build_resource with a create_if_missing flag is deprecated, use edit_resource instead"
|
261
|
+
# midly goofy since we call edit_resource only to re-call ourselves, but that's why its deprecated...
|
262
|
+
return edit_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
|
263
|
+
end
|
264
|
+
|
265
|
+
resource = build_resource(type, name, created_at, &resource_attrs_block)
|
266
|
+
|
267
|
+
run_context.resource_collection.insert(resource, resource_type: type, instance_name: name)
|
268
|
+
resource
|
269
|
+
end
|
270
|
+
|
271
|
+
# Instantiate a resource of the given +type+ with the given +name+ and
|
272
|
+
# attributes as given in the +resource_attrs_block+.
|
273
|
+
#
|
274
|
+
# The resource is NOT added to the resource collection.
|
275
|
+
#
|
276
|
+
# @param type [Symbol] The type of resource (e.g. `:file` or `:package`)
|
277
|
+
# @param name [String] The name of the resource (e.g. '/x/y.txt' or 'apache2')
|
278
|
+
# @param created_at [String] The caller of the resource. Use `caller[0]`
|
279
|
+
# to get the caller of your function. Defaults to the caller of this
|
280
|
+
# function.
|
281
|
+
# @param run_context [Chef::RunContext] the run_context of the resource collection to operate on
|
282
|
+
# @param resource_attrs_block A block that lets you set attributes of the
|
283
|
+
# resource (it is instance_eval'd on the resource instance).
|
284
|
+
#
|
285
|
+
# @return [Chef::Resource] The new resource.
|
286
|
+
#
|
287
|
+
# @example
|
288
|
+
# build_resource(:file, '/x/y.txy', caller[0]) do
|
289
|
+
# action :delete
|
290
|
+
# end
|
291
|
+
#
|
292
|
+
def build_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
|
293
|
+
created_at ||= caller[0]
|
294
|
+
|
295
|
+
# this needs to be lazy in order to avoid circular dependencies since ResourceBuilder
|
296
|
+
# will requires the entire provider+resolver universe
|
297
|
+
require "chef_compat/copied_from_chef/chef/resource_builder" unless defined?(Chef::ResourceBuilder)
|
298
|
+
|
299
|
+
Chef::ResourceBuilder.new(
|
300
|
+
type: type,
|
301
|
+
name: name,
|
302
|
+
created_at: created_at,
|
303
|
+
params: @params,
|
304
|
+
run_context: run_context,
|
305
|
+
cookbook_name: cookbook_name,
|
306
|
+
recipe_name: recipe_name,
|
307
|
+
enclosing_provider: self.is_a?(Chef::Provider) ? self : nil
|
308
|
+
).build(&resource_attrs_block)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|