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,128 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Richard Lavey (richard.lavey@calastone.com)
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Resource:: certificate_binding
|
5
|
+
#
|
6
|
+
# Copyright:: 2015-2017, Calastone Ltd.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
include Chef::Mixin::ShellOut
|
22
|
+
include Chef::Mixin::PowershellOut
|
23
|
+
include Windows::Helper
|
24
|
+
|
25
|
+
property :cert_name, String, name_property: true, required: true
|
26
|
+
property :name_kind, Symbol, equal_to: [:hash, :subject], default: :subject
|
27
|
+
property :address, String, default: '0.0.0.0'
|
28
|
+
property :port, Integer, default: 443
|
29
|
+
property :app_id, String, default: '{4dc3e181-e14b-4a21-b022-59fc669b0914}'
|
30
|
+
property :store_name, String, default: 'MY', regex: /^(?:MY|CA|ROOT)$/
|
31
|
+
property :exists, [true, false], desired_state: true
|
32
|
+
|
33
|
+
load_current_value do |desired|
|
34
|
+
cmd = shell_out("#{locate_sysnative_cmd('netsh.exe')} http show sslcert ipport=#{desired.address}:#{desired.port}")
|
35
|
+
Chef::Log.debug "netsh reports: #{cmd.stdout}"
|
36
|
+
|
37
|
+
address desired.address
|
38
|
+
port desired.port
|
39
|
+
store_name desired.store_name
|
40
|
+
app_id desired.app_id
|
41
|
+
|
42
|
+
if cmd.exitstatus == 0
|
43
|
+
m = cmd.stdout.scan(/Certificate Hash\s+:\s?([A-Fa-f0-9]{40})/)
|
44
|
+
raise "Failed to extract hash from command output #{cmd.stdout}" if m.empty?
|
45
|
+
cert_name m[0][0]
|
46
|
+
name_kind :hash
|
47
|
+
exists true
|
48
|
+
else
|
49
|
+
exists false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
action :create do
|
54
|
+
hash = new_resource.name_kind == :subject ? hash_from_subject : new_resource.cert_name
|
55
|
+
|
56
|
+
if current_resource.exists
|
57
|
+
needs_change = (hash.casecmp(current_resource.cert_name) != 0)
|
58
|
+
|
59
|
+
if needs_change
|
60
|
+
converge_by("Changing #{current_resource.address}:#{current_resource.port}") do
|
61
|
+
delete_binding
|
62
|
+
add_binding hash
|
63
|
+
end
|
64
|
+
else
|
65
|
+
Chef::Log.debug("#{new_resource.address}:#{new_resource.port} already bound to #{hash} - nothing to do")
|
66
|
+
end
|
67
|
+
else
|
68
|
+
converge_by("Binding #{new_resource.address}:#{new_resource.port}") do
|
69
|
+
add_binding hash
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
action :delete do
|
75
|
+
if current_resource.exists
|
76
|
+
converge_by("Deleting #{current_resource.address}:#{current_resource.port}") do
|
77
|
+
delete_binding
|
78
|
+
end
|
79
|
+
else
|
80
|
+
Chef::Log.debug("#{current_resource.address}:#{current_resource.port} not bound - nothing to do")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
action_class do
|
85
|
+
def netsh_command
|
86
|
+
locate_sysnative_cmd('netsh.exe')
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_binding(hash)
|
90
|
+
cmd = "#{netsh_command} http add sslcert"
|
91
|
+
cmd << " ipport=#{current_resource.address}:#{current_resource.port}"
|
92
|
+
cmd << " certhash=#{hash}"
|
93
|
+
cmd << " appid=#{current_resource.app_id}"
|
94
|
+
cmd << " certstorename=#{current_resource.store_name}"
|
95
|
+
check_hash hash
|
96
|
+
|
97
|
+
shell_out!(cmd)
|
98
|
+
end
|
99
|
+
|
100
|
+
def delete_binding
|
101
|
+
shell_out!("#{netsh_command} http delete sslcert ipport=#{current_resource.address}:#{current_resource.port}")
|
102
|
+
end
|
103
|
+
|
104
|
+
def check_hash(hash)
|
105
|
+
p = powershell_out!("Test-Path \"cert:\\LocalMachine\\#{current_resource.store_name}\\#{hash}\"")
|
106
|
+
|
107
|
+
unless p.stderr.empty? && p.stdout =~ /True/i
|
108
|
+
raise "A Cert with hash of #{hash} doesn't exist in keystore LocalMachine\\#{current_resource.store_name}"
|
109
|
+
end
|
110
|
+
nil
|
111
|
+
end
|
112
|
+
|
113
|
+
def hash_from_subject
|
114
|
+
# escape wildcard subject name (*.acme.com)
|
115
|
+
subject = new_resource.cert_name.sub(/\*/, '`*')
|
116
|
+
ps_script = "& { gci cert:\\localmachine\\#{new_resource.store_name} | where { $_.subject -like '*#{subject}*' } | select -first 1 -expandproperty Thumbprint }"
|
117
|
+
|
118
|
+
Chef::Log.debug "Running PS script #{ps_script}"
|
119
|
+
p = powershell_out!(ps_script)
|
120
|
+
|
121
|
+
raise "#{ps_script} failed with #{p.stderr}" if !p.stderr.nil? && !p.stderr.empty?
|
122
|
+
raise "Couldn't find thumbprint for subject #{new_resource.cert_name}" if p.stdout.nil? || p.stdout.empty?
|
123
|
+
|
124
|
+
# seem to get a UTF-8 string with BOM returned sometimes! Strip any such BOM
|
125
|
+
hash = p.stdout.strip
|
126
|
+
hash[0].ord == 239 ? hash.force_encoding('UTF-8').delete!("\xEF\xBB\xBF".force_encoding('UTF-8')) : hash
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Resource:: feature
|
5
|
+
#
|
6
|
+
# Copyright:: 2011-2017, Chef Software, Inc.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
property :feature_name, [Array, String], name_property: true
|
22
|
+
property :source, String
|
23
|
+
property :all, [true, false], default: false
|
24
|
+
property :install_method, Symbol, equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd]
|
25
|
+
|
26
|
+
include Windows::Helper
|
27
|
+
|
28
|
+
def whyrun_supported?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
action :install do
|
33
|
+
run_default_provider :install
|
34
|
+
end
|
35
|
+
|
36
|
+
action :remove do
|
37
|
+
run_default_provider :remove
|
38
|
+
end
|
39
|
+
|
40
|
+
action :delete do
|
41
|
+
run_default_provider :delete
|
42
|
+
end
|
43
|
+
|
44
|
+
action_class do
|
45
|
+
def locate_default_provider
|
46
|
+
if new_resource.install_method
|
47
|
+
new_resource.install_method
|
48
|
+
elsif ::File.exist?(locate_sysnative_cmd('dism.exe'))
|
49
|
+
:windows_feature_dism
|
50
|
+
elsif ::File.exist?(locate_sysnative_cmd('servermanagercmd.exe'))
|
51
|
+
:windows_feature_servermanagercmd
|
52
|
+
else
|
53
|
+
:windows_feature_powershell
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_default_provider(desired_action)
|
58
|
+
case locate_default_provider
|
59
|
+
when :windows_feature_dism
|
60
|
+
windows_feature_dism new_resource.name do
|
61
|
+
action desired_action
|
62
|
+
feature_name new_resource.feature_name
|
63
|
+
source new_resource.source if new_resource.source
|
64
|
+
all new_resource.all
|
65
|
+
end
|
66
|
+
when :windows_feature_servermanagercmd
|
67
|
+
windows_feature_servermanagercmd new_resource.name do
|
68
|
+
action desired_action
|
69
|
+
feature_name new_resource.feature_name
|
70
|
+
source new_resource.source if new_resource.source
|
71
|
+
all new_resource.all
|
72
|
+
end
|
73
|
+
when :windows_feature_powershell
|
74
|
+
windows_feature_powershell new_resource.name do
|
75
|
+
action desired_action
|
76
|
+
feature_name new_resource.feature_name
|
77
|
+
source new_resource.source if new_resource.source
|
78
|
+
all new_resource.all
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Provider:: feature_dism
|
5
|
+
#
|
6
|
+
# Copyright:: 2011-2017, Chef Software, Inc.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
property :feature_name, [Array, String], name_property: true
|
22
|
+
property :source, String
|
23
|
+
property :all, [true, false], default: false
|
24
|
+
|
25
|
+
include Chef::Mixin::ShellOut
|
26
|
+
include Windows::Helper
|
27
|
+
|
28
|
+
action :install do
|
29
|
+
Chef::Log.warn("Requested feature #{new_resource.feature_name} is not available on this system.") unless available?
|
30
|
+
unless !available? || installed?
|
31
|
+
converge_by("install Windows feature #{new_resource.feature_name}") do
|
32
|
+
addsource = new_resource.source ? "/LimitAccess /Source:\"#{new_resource.source}\"" : ''
|
33
|
+
addall = new_resource.all ? '/All' : ''
|
34
|
+
shell_out!("#{dism} /online /enable-feature #{to_array(new_resource.feature_name).map { |feature| "/featurename:#{feature}" }.join(' ')} /norestart #{addsource} #{addall}", returns: [0, 42, 127, 3010])
|
35
|
+
# Reload ohai data
|
36
|
+
reload_ohai_features_plugin(new_resource.action, new_resource.feature_name)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
action :remove do
|
42
|
+
if installed?
|
43
|
+
converge_by("removing Windows feature #{new_resource.feature_name}") do
|
44
|
+
shell_out!("#{dism} /online /disable-feature #{to_array(new_resource.feature_name).map { |feature| "/featurename:#{feature}" }.join(' ')} /norestart", returns: [0, 42, 127, 3010])
|
45
|
+
# Reload ohai data
|
46
|
+
reload_ohai_features_plugin(new_resource.action, new_resource.feature_name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
action :delete do
|
52
|
+
raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not support on #{win_version.sku}" unless supports_feature_delete?
|
53
|
+
if available?
|
54
|
+
converge_by("deleting Windows feature #{new_resource.feature_name} from the image") do
|
55
|
+
shell_out!("#{dism} /online /disable-feature #{to_array(new_resource.feature_name).map { |feature| "/featurename:#{feature}" }.join(' ')} /Remove /norestart", returns: [0, 42, 127, 3010])
|
56
|
+
# Reload ohai data
|
57
|
+
reload_ohai_features_plugin(new_resource.action, new_resource.feature_name)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
action_class do
|
63
|
+
def installed?
|
64
|
+
@installed ||= begin
|
65
|
+
install_ohai_plugin unless node['dism_features']
|
66
|
+
|
67
|
+
# Compare against ohai plugin instead of costly dism run
|
68
|
+
node['dism_features'].key?(new_resource.feature_name) && node['dism_features'][new_resource.feature_name] =~ /Enable/
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def available?
|
73
|
+
@available ||= begin
|
74
|
+
install_ohai_plugin unless node['dism_features']
|
75
|
+
|
76
|
+
# Compare against ohai plugin instead of costly dism run
|
77
|
+
node['dism_features'].key?(new_resource.feature_name) && node['dism_features'][new_resource.feature_name] !~ /with payload removed/
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def reload_ohai_features_plugin(take_action, feature_name)
|
82
|
+
ohai "Reloading Dism_Features Plugin - Action #{take_action} of feature #{feature_name}" do
|
83
|
+
action :reload
|
84
|
+
plugin 'dism_features'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def install_ohai_plugin
|
89
|
+
Chef::Log.info("node['dism_features'] data missing. Installing the dism_features Ohai plugin")
|
90
|
+
|
91
|
+
ohai_plugin 'dism_features' do
|
92
|
+
compile_time true
|
93
|
+
cookbook 'windows'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def supports_feature_delete?
|
98
|
+
win_version.major_version >= 6 && win_version.minor_version >= 2
|
99
|
+
end
|
100
|
+
|
101
|
+
# account for File System Redirector
|
102
|
+
# http://msdn.microsoft.com/en-us/library/aa384187(v=vs.85).aspx
|
103
|
+
def dism
|
104
|
+
@dism ||= begin
|
105
|
+
locate_sysnative_cmd('dism.exe')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Greg Zapp (<greg.zapp@gmail.com>)
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Provider:: feature_powershell
|
5
|
+
#
|
6
|
+
|
7
|
+
property :feature_name, [Array, String], name_attribute: true
|
8
|
+
property :source, String
|
9
|
+
property :all, [true, false], default: false
|
10
|
+
|
11
|
+
include Chef::Mixin::PowershellOut
|
12
|
+
include Windows::Helper
|
13
|
+
|
14
|
+
action :remove do
|
15
|
+
if installed?
|
16
|
+
converge_by("remove Windows feature #{new_resource.feature_name}") do
|
17
|
+
cmd = powershell_out!("#{remove_feature_cmdlet} #{to_array(new_resource.feature_name).join(',')}")
|
18
|
+
Chef::Log.info(cmd.stdout)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
action :delete do
|
24
|
+
if available?
|
25
|
+
converge_by("delete Windows feature #{new_resource.feature_name} from the image") do
|
26
|
+
cmd = powershell_out!("Uninstall-WindowsFeature #{to_array(new_resource.feature_name).join(',')} -Remove")
|
27
|
+
Chef::Log.info(cmd.stdout)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
action_class do
|
33
|
+
def install_feature_cmdlet
|
34
|
+
node['os_version'].to_f < 6.2 ? 'Import-Module ServerManager; Add-WindowsFeature' : 'Install-WindowsFeature'
|
35
|
+
end
|
36
|
+
|
37
|
+
def remove_feature_cmdlet
|
38
|
+
node['os_version'].to_f < 6.2 ? 'Import-Module ServerManager; Remove-WindowsFeature' : 'Uninstall-WindowsFeature'
|
39
|
+
end
|
40
|
+
|
41
|
+
def installed?
|
42
|
+
@installed ||= begin
|
43
|
+
cmd = powershell_out("(Get-WindowsFeature #{to_array(new_resource.feature_name).join(',')} | ?{$_.InstallState -ne \'Installed\'}).count")
|
44
|
+
cmd.stderr.empty? && cmd.stdout.chomp.to_i == 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def available?
|
49
|
+
@available ||= begin
|
50
|
+
cmd = powershell_out("(Get-WindowsFeature #{to_array(new_resource.feature_name).join(',')} | ?{$_.InstallState -ne \'Removed\'}).count")
|
51
|
+
cmd.stderr.empty? && cmd.stdout.chomp.to_i > 0
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
action :install do
|
57
|
+
Chef::Log.warn("Requested feature #{new_resource.feature_name} is not available on this system.") unless available?
|
58
|
+
unless !available? || installed?
|
59
|
+
converge_by("install Windows feature #{new_resource.feature_name}") do
|
60
|
+
addsource = new_resource.source ? "-Source \"#{new_resource.source}\"" : ''
|
61
|
+
addall = new_resource.all ? '-IncludeAllSubFeature' : ''
|
62
|
+
cmd = if node['os_version'].to_f < 6.2
|
63
|
+
powershell_out!("#{install_feature_cmdlet} #{to_array(new_resource.feature_name).join(',')} #{addall}")
|
64
|
+
else
|
65
|
+
powershell_out!("#{install_feature_cmdlet} #{to_array(new_resource.feature_name).join(',')} #{addsource} #{addall}")
|
66
|
+
end
|
67
|
+
Chef::Log.info(cmd.stdout)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Provider:: feature_servermanagercmd
|
5
|
+
#
|
6
|
+
# Copyright:: 2011-2017, Chef Software, Inc.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
property :feature_name, [Array, String], name_attribute: true
|
22
|
+
property :source, String
|
23
|
+
property :all, [true, false], default: false
|
24
|
+
|
25
|
+
include Chef::Mixin::ShellOut
|
26
|
+
include Windows::Helper
|
27
|
+
|
28
|
+
action :install do
|
29
|
+
unless installed?
|
30
|
+
converge_by("install Windows feature #{new_resource.feature_name}") do
|
31
|
+
check_reboot(shell_out("#{servermanagercmd} -install #{to_array(new_resource.feature_name).join(' ')}", returns: [0, 42, 127, 1003, 3010]), new_resource.feature_name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
action :remove do
|
37
|
+
if installed?
|
38
|
+
converge_by("removing Windows feature #{new_resource.feature_name}") do
|
39
|
+
check_reboot(shell_out("#{servermanagercmd} -remove #{to_array(new_resource.feature_name).join(' ')}", returns: [0, 42, 127, 1003, 3010]), new_resource.feature_name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
action :delete do
|
45
|
+
Chef::Log.warn('servermanagercmd does not support removing a feature from the image.')
|
46
|
+
end
|
47
|
+
|
48
|
+
# Exit codes are listed at http://technet.microsoft.com/en-us/library/cc749128(v=ws.10).aspx
|
49
|
+
|
50
|
+
action_class do
|
51
|
+
def check_reboot(result, feature)
|
52
|
+
if result.exitstatus == 3010 # successful, but needs reboot
|
53
|
+
node.run_state['reboot_requested'] = true
|
54
|
+
Chef::Log.warn("Require reboot to install #{feature}")
|
55
|
+
elsif result.exitstatus == 1001 # failure, but needs reboot before we can do anything else
|
56
|
+
node.run_state['reboot_requested'] = true
|
57
|
+
Chef::Log.warn("Failed installing #{feature} and need to reboot")
|
58
|
+
end
|
59
|
+
result.error! # throw for any other bad results. The above results will also get raised, and should cause a reboot via the handler.
|
60
|
+
end
|
61
|
+
|
62
|
+
def installed?
|
63
|
+
@installed ||= begin
|
64
|
+
cmd = shell_out("#{servermanagercmd} -query", returns: [0, 42, 127, 1003])
|
65
|
+
cmd.stderr.empty? && (cmd.stdout =~ /^\s*?\[X\]\s.+?\s\[#{new_resource.feature_name}\]\s*$/i)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# account for File System Redirector
|
70
|
+
# http://msdn.microsoft.com/en-us/library/aa384187(v=vs.85).aspx
|
71
|
+
def servermanagercmd
|
72
|
+
@servermanagercmd ||= begin
|
73
|
+
locate_sysnative_cmd('servermanagercmd.exe')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman <sbotman@schubergphilis.com>
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Resource:: font
|
5
|
+
#
|
6
|
+
# Copyright:: 2014-2017, Schuberg Philis BV.
|
7
|
+
# Copyright:: 2017, Chef Software, Inc.
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
property :name, String, name_property: true
|
23
|
+
property :source, String, required: false
|
24
|
+
|
25
|
+
include Windows::Helper
|
26
|
+
|
27
|
+
action :install do
|
28
|
+
if font_exists?
|
29
|
+
Chef::Log.debug("Not installing font: #{new_resource.name}, font already installed.")
|
30
|
+
else
|
31
|
+
retrieve_cookbook_font
|
32
|
+
install_font
|
33
|
+
del_cookbook_font
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
action_class do
|
38
|
+
def retrieve_cookbook_font
|
39
|
+
font_file = new_resource.name
|
40
|
+
if new_resource.source
|
41
|
+
remote_file font_file do
|
42
|
+
action :nothing
|
43
|
+
source "file://#{new_resource.source}"
|
44
|
+
path win_friendly_path(::File.join(ENV['TEMP'], font_file))
|
45
|
+
end.run_action(:create)
|
46
|
+
else
|
47
|
+
cookbook_file font_file do
|
48
|
+
action :nothing
|
49
|
+
cookbook cookbook_name.to_s unless cookbook_name.nil?
|
50
|
+
path win_friendly_path(::File.join(ENV['TEMP'], font_file))
|
51
|
+
end.run_action(:create)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def del_cookbook_font
|
56
|
+
file ::File.join(ENV['TEMP'], new_resource.name) do
|
57
|
+
action :delete
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def install_font
|
62
|
+
require 'win32ole' if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
63
|
+
fonts_dir = WIN32OLE.new('WScript.Shell').SpecialFolders('Fonts')
|
64
|
+
folder = WIN32OLE.new('Shell.Application').Namespace(fonts_dir)
|
65
|
+
converge_by("install font #{new_resource.name}") do
|
66
|
+
folder.CopyHere(win_friendly_path(::File.join(ENV['TEMP'], new_resource.name)))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Check to see if the font is installed
|
71
|
+
#
|
72
|
+
# === Returns
|
73
|
+
# <true>:: If the font is installed
|
74
|
+
# <false>:: If the font is not instaled
|
75
|
+
def font_exists?
|
76
|
+
require 'win32ole' if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
77
|
+
fonts_dir = WIN32OLE.new('WScript.Shell').SpecialFolders('Fonts')
|
78
|
+
::File.exist?(win_friendly_path(::File.join(fonts_dir, new_resource.name)))
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Richard Lavey (richard.lavey@calastone.com)
|
3
|
+
# Cookbook:: windows
|
4
|
+
# Resource:: http_acl
|
5
|
+
#
|
6
|
+
# Copyright:: 2015-2017, Calastone Ltd.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
include Chef::Mixin::ShellOut
|
22
|
+
include Windows::Helper
|
23
|
+
|
24
|
+
property :url, String, name_property: true, required: true
|
25
|
+
property :user, String
|
26
|
+
property :sddl, String
|
27
|
+
property :exists, [true, false], desired_state: true
|
28
|
+
|
29
|
+
# See https://msdn.microsoft.com/en-us/library/windows/desktop/cc307236%28v=vs.85%29.aspx for netsh info
|
30
|
+
|
31
|
+
load_current_value do |desired|
|
32
|
+
cmd_out = shell_out!("#{locate_sysnative_cmd('netsh.exe')} http show urlacl url=#{desired.url}").stdout
|
33
|
+
Chef::Log.debug "netsh reports: #{cmd_out}"
|
34
|
+
|
35
|
+
if cmd_out.include? desired.url
|
36
|
+
exists true
|
37
|
+
url desired.url
|
38
|
+
# Checks first for sddl, because it generates user(s)
|
39
|
+
sddl_match = cmd_out.match(/SDDL:\s*(?<sddl>.+)/)
|
40
|
+
if sddl_match
|
41
|
+
sddl sddl_match['sddl']
|
42
|
+
else
|
43
|
+
# if no sddl, tries to find a single user
|
44
|
+
user_match = cmd_out.match(/User:\s*(?<user>.+)/)
|
45
|
+
user user_match['user']
|
46
|
+
end
|
47
|
+
else
|
48
|
+
exists false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
action :create do
|
53
|
+
raise '`user` xor `sddl` can\'t be used together' if new_resource.user && new_resource.sddl
|
54
|
+
raise 'When provided user property can\'t be empty' if new_resource.user && new_resource.user.empty?
|
55
|
+
raise 'When provided sddl property can\'t be empty' if new_resource.sddl && new_resource.sddl.empty?
|
56
|
+
|
57
|
+
if current_resource.exists
|
58
|
+
sddl_changed = (
|
59
|
+
new_resource.sddl &&
|
60
|
+
current_resource.sddl &&
|
61
|
+
current_resource.sddl.casecmp(new_resource.sddl) != 0
|
62
|
+
)
|
63
|
+
user_changed = (
|
64
|
+
new_resource.user &&
|
65
|
+
current_resource.user &&
|
66
|
+
current_resource.user.casecmp(new_resource.user) != 0
|
67
|
+
)
|
68
|
+
|
69
|
+
if sddl_changed || user_changed
|
70
|
+
converge_by("Changing #{new_resource.url}") do
|
71
|
+
delete_acl
|
72
|
+
apply_acl
|
73
|
+
end
|
74
|
+
else
|
75
|
+
Chef::Log.debug("#{new_resource.url} already set - nothing to do")
|
76
|
+
end
|
77
|
+
else
|
78
|
+
converge_by("Setting #{new_resource.url}") do
|
79
|
+
apply_acl
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
action :delete do
|
85
|
+
if current_resource.exists
|
86
|
+
converge_by("Deleting #{new_resource.url}") do
|
87
|
+
delete_acl
|
88
|
+
end
|
89
|
+
else
|
90
|
+
Chef::Log.debug("#{new_resource.url} does not exist - nothing to do")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
action_class do
|
95
|
+
def netsh_command
|
96
|
+
locate_sysnative_cmd('netsh.exe')
|
97
|
+
end
|
98
|
+
|
99
|
+
def apply_acl
|
100
|
+
if current_resource.sddl
|
101
|
+
shell_out!("#{netsh_command} http add urlacl url=#{new_resource.url} sddl=\"#{new_resource.sddl}\"")
|
102
|
+
else
|
103
|
+
shell_out!("#{netsh_command} http add urlacl url=#{new_resource.url} user=\"#{new_resource.user}\"")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def delete_acl
|
108
|
+
shell_out!("#{netsh_command} http delete urlacl url=#{new_resource.url}")
|
109
|
+
end
|
110
|
+
end
|