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.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/.rakeTasks +7 -0
  3. data/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. data/.idea/misc.xml +4 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/runConfigurations/clone.xml +21 -0
  7. data/.idea/runConfigurations/libvirt.xml +21 -0
  8. data/.idea/vagrant-clone.iml +114 -0
  9. data/.idea/vcs.xml +6 -0
  10. data/.idea/workspace.xml +948 -0
  11. data/Gemfile +9 -3
  12. data/Gemfile.lock +123 -37
  13. data/Rakefile +2 -1
  14. data/Vagrantfile +9 -0
  15. data/cookbooks/apt/CHANGELOG.md +321 -0
  16. data/cookbooks/apt/CONTRIBUTING.md +2 -0
  17. data/cookbooks/apt/MAINTAINERS.md +15 -0
  18. data/cookbooks/apt/README.md +250 -0
  19. data/cookbooks/apt/attributes/default.rb +57 -0
  20. data/cookbooks/apt/files/15update-stamp +1 -0
  21. data/cookbooks/apt/files/apt-proxy-v2.conf +50 -0
  22. data/cookbooks/apt/libraries/helpers.rb +49 -0
  23. data/cookbooks/apt/libraries/matchers.rb +16 -0
  24. data/cookbooks/apt/metadata.json +1 -0
  25. data/cookbooks/apt/recipes/cacher-client.rb +52 -0
  26. data/cookbooks/apt/recipes/cacher-ng.rb +39 -0
  27. data/cookbooks/apt/recipes/default.rb +93 -0
  28. data/cookbooks/apt/recipes/unattended-upgrades.rb +47 -0
  29. data/cookbooks/apt/resources/preference.rb +90 -0
  30. data/cookbooks/apt/templates/01proxy.erb +11 -0
  31. data/cookbooks/apt/templates/10dpkg-options.erb +8 -0
  32. data/cookbooks/apt/templates/10recommends.erb +3 -0
  33. data/cookbooks/apt/templates/20auto-upgrades.erb +5 -0
  34. data/cookbooks/apt/templates/50unattended-upgrades.erb +75 -0
  35. data/cookbooks/apt/templates/acng.conf.erb +275 -0
  36. data/cookbooks/apt/templates/unattended-upgrades.seed.erb +1 -0
  37. data/cookbooks/build-essential/.foodcritic +1 -0
  38. data/cookbooks/build-essential/CHANGELOG.md +257 -0
  39. data/cookbooks/build-essential/CONTRIBUTING.md +2 -0
  40. data/cookbooks/build-essential/MAINTAINERS.md +15 -0
  41. data/cookbooks/build-essential/README.md +134 -0
  42. data/cookbooks/build-essential/attributes/default.rb +21 -0
  43. data/cookbooks/build-essential/libraries/matchers.rb +9 -0
  44. data/cookbooks/build-essential/metadata.json +1 -0
  45. data/cookbooks/build-essential/recipes/_windows.rb +53 -0
  46. data/cookbooks/build-essential/recipes/default.rb +24 -0
  47. data/cookbooks/build-essential/resources/build_essential.rb +106 -0
  48. data/cookbooks/build-essential/resources/xcode_command_line_tools.rb +61 -0
  49. data/cookbooks/compat_resource/CHANGELOG.md +53 -0
  50. data/cookbooks/compat_resource/CONTRIBUTING.md +2 -0
  51. data/cookbooks/compat_resource/MAINTAINERS.md +16 -0
  52. data/cookbooks/compat_resource/README.md +60 -0
  53. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/constants.rb +47 -0
  54. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb +40 -0
  55. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb +73 -0
  56. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +315 -0
  57. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb +292 -0
  58. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb +37 -0
  59. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb +70 -0
  60. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb +98 -0
  61. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb +74 -0
  62. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +510 -0
  63. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/powershell_out.rb +117 -0
  64. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb +328 -0
  65. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb +713 -0
  66. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_repository.rb +269 -0
  67. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_update.rb +105 -0
  68. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/noop.rb +56 -0
  69. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/support/yum_repo.erb +132 -0
  70. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/systemd_unit.rb +253 -0
  71. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/yum_repository.rb +136 -0
  72. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb +164 -0
  73. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb +114 -0
  74. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_repository.rb +65 -0
  75. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_update.rb +52 -0
  76. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/systemd_unit.rb +81 -0
  77. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/yum_repository.rb +97 -0
  78. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource.rb +214 -0
  79. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +174 -0
  80. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef.rb +29 -0
  81. data/cookbooks/compat_resource/files/lib/chef_compat/mixin/properties.rb +8 -0
  82. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/exceptions.rb +10 -0
  83. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/log.rb +30 -0
  84. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/mixin/params_validate.rb +17 -0
  85. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/node.rb +9 -0
  86. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb +15 -0
  87. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/provider.rb +65 -0
  88. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe.rb +118 -0
  89. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe_hook.rb +20 -0
  90. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb +60 -0
  91. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource.rb +156 -0
  92. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb +167 -0
  93. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_list.rb +49 -0
  94. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_set.rb +49 -0
  95. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection.rb +103 -0
  96. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/run_context.rb +691 -0
  97. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb +153 -0
  98. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef.rb +33 -0
  99. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches.rb +41 -0
  100. data/cookbooks/compat_resource/files/lib/chef_compat/property.rb +6 -0
  101. data/cookbooks/compat_resource/files/lib/chef_compat/recipe.rb +8 -0
  102. data/cookbooks/compat_resource/files/lib/chef_compat/resource/lwrp_base.rb +44 -0
  103. data/cookbooks/compat_resource/files/lib/chef_compat/resource.rb +56 -0
  104. data/cookbooks/compat_resource/files/lib/chef_upstream_version.rb +3 -0
  105. data/cookbooks/compat_resource/files/lib/compat_resource.rb +35 -0
  106. data/cookbooks/compat_resource/libraries/autoload.rb +31 -0
  107. data/cookbooks/compat_resource/metadata.json +1 -0
  108. data/cookbooks/inifile_chef_gem/CHANGELOG.md +11 -0
  109. data/cookbooks/inifile_chef_gem/README.md +46 -0
  110. data/cookbooks/inifile_chef_gem/metadata.json +51 -0
  111. data/cookbooks/inifile_chef_gem/metadata.rb +11 -0
  112. data/cookbooks/inifile_chef_gem/resources/default.rb +28 -0
  113. data/cookbooks/mariadb/CHANGELOG.md +332 -0
  114. data/cookbooks/mariadb/README.md +225 -0
  115. data/cookbooks/mariadb/attributes/default.rb +199 -0
  116. data/cookbooks/mariadb/libraries/mariadb_conn_helper.rb +53 -0
  117. data/cookbooks/mariadb/libraries/mariadb_helper.rb +216 -0
  118. data/cookbooks/mariadb/libraries/matchers.rb +21 -0
  119. data/cookbooks/mariadb/metadata.json +1 -0
  120. data/cookbooks/mariadb/providers/configuration.rb +39 -0
  121. data/cookbooks/mariadb/recipes/_audit_plugin.rb +63 -0
  122. data/cookbooks/mariadb/recipes/_debian_galera.rb +62 -0
  123. data/cookbooks/mariadb/recipes/_debian_server.rb +78 -0
  124. data/cookbooks/mariadb/recipes/_mariadb_repository.rb +29 -0
  125. data/cookbooks/mariadb/recipes/_redhat_client.rb +27 -0
  126. data/cookbooks/mariadb/recipes/_redhat_galera.rb +55 -0
  127. data/cookbooks/mariadb/recipes/_redhat_server.rb +58 -0
  128. data/cookbooks/mariadb/recipes/client.rb +47 -0
  129. data/cookbooks/mariadb/recipes/config.rb +115 -0
  130. data/cookbooks/mariadb/recipes/default.rb +46 -0
  131. data/cookbooks/mariadb/recipes/devel.rb +41 -0
  132. data/cookbooks/mariadb/recipes/galera.rb +324 -0
  133. data/cookbooks/mariadb/recipes/plugins.rb +3 -0
  134. data/cookbooks/mariadb/recipes/repository.rb +45 -0
  135. data/cookbooks/mariadb/recipes/server.rb +157 -0
  136. data/cookbooks/mariadb/resources/configuration.rb +13 -0
  137. data/cookbooks/mariadb/resources/mysql2_gem.rb +25 -0
  138. data/cookbooks/mariadb/resources/replication.rb +192 -0
  139. data/cookbooks/mariadb/templates/default/conf.d.generic.erb +19 -0
  140. data/cookbooks/mariadb/templates/default/debian.cnf.erb +12 -0
  141. data/cookbooks/mariadb/templates/default/mariadb-server.seed.erb +13 -0
  142. data/cookbooks/mariadb/templates/default/mariadb_grants.erb +42 -0
  143. data/cookbooks/mariadb/templates/default/my.cnf.erb +210 -0
  144. data/cookbooks/mariadb/templates/default/root.cnf.erb +5 -0
  145. data/cookbooks/mingw/.foodcritic +1 -0
  146. data/cookbooks/mingw/CHANGELOG.md +50 -0
  147. data/cookbooks/mingw/CONTRIBUTING.md +2 -0
  148. data/cookbooks/mingw/MAINTAINERS.md +14 -0
  149. data/cookbooks/mingw/README.md +133 -0
  150. data/cookbooks/mingw/files/default/bash.bat +17 -0
  151. data/cookbooks/mingw/files/default/custom-upgrade.sh +23 -0
  152. data/cookbooks/mingw/files/default/custom_prefix.sh +13 -0
  153. data/cookbooks/mingw/files/default/pthread.h +719 -0
  154. data/cookbooks/mingw/files/default/time.h +297 -0
  155. data/cookbooks/mingw/libraries/_helper.rb +38 -0
  156. data/cookbooks/mingw/metadata.json +1 -0
  157. data/cookbooks/mingw/recipes/default.rb +19 -0
  158. data/cookbooks/mingw/resources/get.rb +56 -0
  159. data/cookbooks/mingw/resources/msys2_package.rb +139 -0
  160. data/cookbooks/mingw/resources/tdm_gcc.rb +114 -0
  161. data/cookbooks/ohai/.foodcritic +2 -0
  162. data/cookbooks/ohai/CHANGELOG.md +166 -0
  163. data/cookbooks/ohai/CONTRIBUTING.md +2 -0
  164. data/cookbooks/ohai/MAINTAINERS.md +15 -0
  165. data/cookbooks/ohai/README.md +134 -0
  166. data/cookbooks/ohai/libraries/matchers.rb +41 -0
  167. data/cookbooks/ohai/metadata.json +1 -0
  168. data/cookbooks/ohai/recipes/default.rb +20 -0
  169. data/cookbooks/ohai/resources/hint.rb +55 -0
  170. data/cookbooks/ohai/resources/plugin.rb +117 -0
  171. data/cookbooks/selinux_policy/.gitignore +51 -0
  172. data/cookbooks/selinux_policy/.kitchen.yml +25 -0
  173. data/cookbooks/selinux_policy/.rubocop.yml +2 -0
  174. data/cookbooks/selinux_policy/.travis.yml +26 -0
  175. data/cookbooks/selinux_policy/Berksfile +8 -0
  176. data/cookbooks/selinux_policy/CHANGELOG.md +155 -0
  177. data/cookbooks/selinux_policy/LICENSE +13 -0
  178. data/cookbooks/selinux_policy/README.md +217 -0
  179. data/cookbooks/selinux_policy/Rakefile +68 -0
  180. data/cookbooks/selinux_policy/TESTING.md +2 -0
  181. data/cookbooks/selinux_policy/Thorfile +12 -0
  182. data/cookbooks/selinux_policy/attributes/default.rb +5 -0
  183. data/cookbooks/selinux_policy/chefignore +102 -0
  184. data/cookbooks/selinux_policy/libraries/helper-disabled.rb +29 -0
  185. data/cookbooks/selinux_policy/libraries/matchers.rb +57 -0
  186. data/cookbooks/selinux_policy/metadata.json +58 -0
  187. data/cookbooks/selinux_policy/metadata.rb +20 -0
  188. data/cookbooks/selinux_policy/providers/boolean.rb +28 -0
  189. data/cookbooks/selinux_policy/providers/fcontext.rb +78 -0
  190. data/cookbooks/selinux_policy/providers/module.rb +81 -0
  191. data/cookbooks/selinux_policy/providers/permissive.rb +26 -0
  192. data/cookbooks/selinux_policy/providers/port.rb +58 -0
  193. data/cookbooks/selinux_policy/recipes/default.rb +9 -0
  194. data/cookbooks/selinux_policy/recipes/install.rb +32 -0
  195. data/cookbooks/selinux_policy/resources/boolean.rb +8 -0
  196. data/cookbooks/selinux_policy/resources/fcontext.rb +8 -0
  197. data/cookbooks/selinux_policy/resources/module.rb +21 -0
  198. data/cookbooks/selinux_policy/resources/permissive.rb +6 -0
  199. data/cookbooks/selinux_policy/resources/port.rb +9 -0
  200. data/cookbooks/seven_zip/CHANGELOG.md +30 -0
  201. data/cookbooks/seven_zip/README.md +108 -0
  202. data/cookbooks/seven_zip/attributes/default.rb +31 -0
  203. data/cookbooks/seven_zip/libraries/matchers.rb +33 -0
  204. data/cookbooks/seven_zip/metadata.json +1 -0
  205. data/cookbooks/seven_zip/providers/archive.rb +68 -0
  206. data/cookbooks/seven_zip/recipes/default.rb +41 -0
  207. data/cookbooks/seven_zip/resources/archive.rb +29 -0
  208. data/cookbooks/windows/.foodcritic +2 -0
  209. data/cookbooks/windows/CHANGELOG.md +528 -0
  210. data/cookbooks/windows/CONTRIBUTING.md +2 -0
  211. data/cookbooks/windows/MAINTAINERS.md +21 -0
  212. data/cookbooks/windows/README.md +803 -0
  213. data/cookbooks/windows/attributes/default.rb +21 -0
  214. data/cookbooks/windows/files/dism_features.rb +45 -0
  215. data/cookbooks/windows/libraries/matchers.rb +586 -0
  216. data/cookbooks/windows/libraries/powershell_helper.rb +53 -0
  217. data/cookbooks/windows/libraries/registry_helper.rb +356 -0
  218. data/cookbooks/windows/libraries/version.rb +207 -0
  219. data/cookbooks/windows/libraries/version_helper.rb +79 -0
  220. data/cookbooks/windows/libraries/windows_helper.rb +174 -0
  221. data/cookbooks/windows/libraries/windows_privileged.rb +103 -0
  222. data/cookbooks/windows/libraries/wmi_helper.rb +32 -0
  223. data/cookbooks/windows/metadata.json +1 -0
  224. data/cookbooks/windows/recipes/default.rb +21 -0
  225. data/cookbooks/windows/resources/auto_run.rb +46 -0
  226. data/cookbooks/windows/resources/certificate.rb +166 -0
  227. data/cookbooks/windows/resources/certificate_binding.rb +128 -0
  228. data/cookbooks/windows/resources/feature.rb +82 -0
  229. data/cookbooks/windows/resources/feature_dism.rb +108 -0
  230. data/cookbooks/windows/resources/feature_powershell.rb +70 -0
  231. data/cookbooks/windows/resources/feature_servermanagercmd.rb +76 -0
  232. data/cookbooks/windows/resources/font.rb +80 -0
  233. data/cookbooks/windows/resources/http_acl.rb +110 -0
  234. data/cookbooks/windows/resources/pagefile.rb +152 -0
  235. data/cookbooks/windows/resources/path.rb +54 -0
  236. data/cookbooks/windows/resources/printer.rb +103 -0
  237. data/cookbooks/windows/resources/printer_port.rb +101 -0
  238. data/cookbooks/windows/resources/share.rb +291 -0
  239. data/cookbooks/windows/resources/shortcut.rb +53 -0
  240. data/cookbooks/windows/resources/task.rb +384 -0
  241. data/cookbooks/windows/resources/zipfile.rb +125 -0
  242. data/cookbooks/yum/.foodcritic +1 -0
  243. data/cookbooks/yum/CHANGELOG.md +351 -0
  244. data/cookbooks/yum/CONTRIBUTING.md +2 -0
  245. data/cookbooks/yum/MAINTAINERS.md +16 -0
  246. data/cookbooks/yum/README.md +125 -0
  247. data/cookbooks/yum/attributes/main.rb +103 -0
  248. data/cookbooks/yum/libraries/matchers.rb +9 -0
  249. data/cookbooks/yum/metadata.json +1 -0
  250. data/cookbooks/yum/recipes/default.rb +26 -0
  251. data/cookbooks/yum/recipes/dnf_yum_compat.rb +29 -0
  252. data/cookbooks/yum/resources/globalconfig.rb +119 -0
  253. data/cookbooks/yum/templates/.DS_Store +0 -0
  254. data/cookbooks/yum/templates/main.erb +276 -0
  255. data/cookbooks/yum-epel/CHANGELOG.md +138 -0
  256. data/cookbooks/yum-epel/CONTRIBUTING.md +2 -0
  257. data/cookbooks/yum-epel/MAINTAINERS.md +19 -0
  258. data/cookbooks/yum-epel/README.md +172 -0
  259. data/cookbooks/yum-epel/attributes/default.rb +8 -0
  260. data/cookbooks/yum-epel/attributes/epel-debuginfo.rb +15 -0
  261. data/cookbooks/yum-epel/attributes/epel-source.rb +15 -0
  262. data/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb +15 -0
  263. data/cookbooks/yum-epel/attributes/epel-testing-source.rb +15 -0
  264. data/cookbooks/yum-epel/attributes/epel-testing.rb +15 -0
  265. data/cookbooks/yum-epel/attributes/epel.rb +21 -0
  266. data/cookbooks/yum-epel/metadata.json +1 -0
  267. data/cookbooks/yum-epel/recipes/default.rb +27 -0
  268. data/cookbooks/yum-scl/.kitchen.dokken.yml +24 -0
  269. data/cookbooks/yum-scl/.kitchen.yml +24 -0
  270. data/cookbooks/yum-scl/.rubocop.yml +6 -0
  271. data/cookbooks/yum-scl/.travis.yml +28 -0
  272. data/cookbooks/yum-scl/Berksfile +3 -0
  273. data/cookbooks/yum-scl/Berksfile.lock +25 -0
  274. data/cookbooks/yum-scl/CHANGELOG.md +11 -0
  275. data/cookbooks/yum-scl/Gemfile +46 -0
  276. data/cookbooks/yum-scl/README.md +76 -0
  277. data/cookbooks/yum-scl/attributes/centos.rb +83 -0
  278. data/cookbooks/yum-scl/attributes/default.rb +15 -0
  279. data/cookbooks/yum-scl/attributes/scientific.rb +1 -0
  280. data/cookbooks/yum-scl/files/default/RPM-GPG-KEY-CentOS-SIG-SCLo +20 -0
  281. data/cookbooks/yum-scl/libraries/yum_scl_helper.rb +33 -0
  282. data/cookbooks/yum-scl/metadata.json +42 -0
  283. data/cookbooks/yum-scl/metadata.rb +12 -0
  284. data/cookbooks/yum-scl/recipes/chef_install.rb +52 -0
  285. data/cookbooks/yum-scl/recipes/default.rb +17 -0
  286. data/cookbooks/yum-scl/recipes/native_install.rb +35 -0
  287. data/lib/vagrant-clone/command/clone.rb +66 -61
  288. data/lib/vagrant-clone/errors.rb +61 -0
  289. data/lib/vagrant-clone/util/clone_manager_base.rb +69 -0
  290. data/lib/vagrant-clone/util/clone_managers/docker.rb +31 -0
  291. data/lib/vagrant-clone/util/clone_managers/libvirt.rb +254 -0
  292. data/lib/vagrant-clone/util/vagrantfile_managers/docker.rb +154 -0
  293. data/lib/vagrant-clone/util/vagrantfile_managers/libvirt.rb +159 -0
  294. data/lib/vagrant-clone/version.rb +2 -2
  295. data/lib/vagrant-clone.rb +6 -6
  296. data/libvirt.txt +7 -0
  297. data/performance_testing.rb +165 -0
  298. data/results.txt +45 -0
  299. data/scripts/create_box.sh +134 -0
  300. data/test.rb +92 -0
  301. data/tools/create_box.sh +130 -0
  302. data/vagrant-clone.gemspec +7 -7
  303. metadata +296 -5
  304. data/lib/vagrant-clone/command/errors.rb +0 -16
  305. data/lib/vagrant-clone/command/provider/docker.rb +0 -13
  306. data/lib/vagrant-clone/utils/vagrantfile_manager.rb +0 -47
@@ -0,0 +1,174 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Cookbook:: windows
4
+ # Library:: helper
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
+ require 'uri'
21
+ require 'Win32API' if Chef::Platform.windows?
22
+ require 'chef/exceptions'
23
+
24
+ module Windows
25
+ module Helper
26
+ AUTO_RUN_KEY = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'.freeze unless defined?(AUTO_RUN_KEY)
27
+ ENV_KEY = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'.freeze unless defined?(ENV_KEY)
28
+ ExpandEnvironmentStrings = Win32API.new('kernel32', 'ExpandEnvironmentStrings', %w(P P L), 'L') if Chef::Platform.windows? && !defined?(ExpandEnvironmentStrings)
29
+
30
+ # returns windows friendly version of the provided path,
31
+ # ensures backslashes are used everywhere
32
+ def win_friendly_path(path)
33
+ path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path
34
+ end
35
+
36
+ # account for Window's wacky File System Redirector
37
+ # http://msdn.microsoft.com/en-us/library/aa384187(v=vs.85).aspx
38
+ # especially important for 32-bit processes (like Ruby) on a
39
+ # 64-bit instance of Windows.
40
+ def locate_sysnative_cmd(cmd)
41
+ if ::File.exist?("#{ENV['WINDIR']}\\sysnative\\#{cmd}")
42
+ "#{ENV['WINDIR']}\\sysnative\\#{cmd}"
43
+ elsif ::File.exist?("#{ENV['WINDIR']}\\system32\\#{cmd}")
44
+ "#{ENV['WINDIR']}\\system32\\#{cmd}"
45
+ else
46
+ cmd
47
+ end
48
+ end
49
+
50
+ # Create a feature provider dependent value object.
51
+ # mainly created becasue Windows Feature names are
52
+ # different based on whether dism.exe or servicemanagercmd.exe
53
+ # is used for installation
54
+ def value_for_feature_provider(provider_hash)
55
+ p = Chef::Platform.find_provider_for_node(node, :windows_feature)
56
+ key = p.to_s.downcase.split('::').last
57
+ provider_hash[key] || provider_hash[key.to_sym]
58
+ end
59
+
60
+ # singleton instance of the Windows Version checker
61
+ def win_version
62
+ @win_version ||= Windows::Version.new
63
+ end
64
+
65
+ # Helper function to properly parse a URI
66
+ def as_uri(source)
67
+ URI.parse(source)
68
+ rescue URI::InvalidURIError
69
+ Chef::Log.warn("#{source} was an invalid URI. Trying to escape invalid characters")
70
+ URI.parse(URI.escape(source))
71
+ end
72
+
73
+ # if a file is local it returns a windows friendly path version
74
+ # if a file is remote it caches it locally
75
+ def cached_file(source, checksum = nil, windows_path = true)
76
+ @installer_file_path ||= begin
77
+
78
+ if source =~ %r{^(file|ftp|http|https):\/\/}
79
+ uri = as_uri(source)
80
+ cache_file_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(::URI.unescape(uri.path))}"
81
+ Chef::Log.debug("Caching a copy of file #{source} at #{cache_file_path}")
82
+ remote_file cache_file_path do
83
+ source source
84
+ backup false
85
+ checksum checksum unless checksum.nil?
86
+ end.run_action(:create)
87
+ else
88
+ cache_file_path = source
89
+ end
90
+
91
+ windows_path ? win_friendly_path(cache_file_path) : cache_file_path
92
+ end
93
+ end
94
+
95
+ # Expands the environment variables
96
+ def expand_env_vars(path)
97
+ # We pick 32k because that is the largest it could be:
98
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724265%28v=vs.85%29.aspx
99
+ buf = 0.chr * 32 * 1024 # 32k
100
+ if ExpandEnvironmentStrings.call(path.dup, buf, buf.length) == 0
101
+ raise Chef::Exceptions::Win32APIError, 'Failed calling ExpandEnvironmentStrings (received 0)'
102
+ end
103
+ buf.strip
104
+ end
105
+
106
+ def is_package_installed?(package_name) # rubocop:disable Style/PredicateName
107
+ installed_packages.include?(package_name)
108
+ end
109
+
110
+ def installed_packages
111
+ @installed_packages || begin
112
+ installed_packages = {}
113
+ # Computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
114
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE)) # rescue nil
115
+ # 64-bit registry view
116
+ # Computer\HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall
117
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0100))) # rescue nil
118
+ # 32-bit registry view
119
+ # Computer\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
120
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0200))) # rescue nil
121
+ # Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
122
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_CURRENT_USER)) # rescue nil
123
+ installed_packages
124
+ end
125
+ end
126
+
127
+ # Returns an array
128
+ def to_array(var)
129
+ var = var.is_a?(Array) ? var : [var]
130
+ var.reject(&:nil?)
131
+ end
132
+
133
+ private
134
+
135
+ def extract_installed_packages_from_key(hkey = ::Win32::Registry::HKEY_LOCAL_MACHINE, desired = ::Win32::Registry::Constants::KEY_READ)
136
+ uninstall_subkey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'
137
+ packages = {}
138
+ begin
139
+ ::Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg|
140
+ reg.each_key do |key, _wtime|
141
+ begin
142
+ k = reg.open(key, desired)
143
+ display_name = begin
144
+ k['DisplayName']
145
+ rescue
146
+ nil
147
+ end
148
+ version = begin
149
+ k['DisplayVersion']
150
+ rescue
151
+ 'NO VERSION'
152
+ end
153
+ uninstall_string = begin
154
+ k['UninstallString']
155
+ rescue
156
+ nil
157
+ end
158
+ if display_name
159
+ packages[display_name] = { name: display_name,
160
+ version: version,
161
+ uninstall_string: uninstall_string }
162
+ end
163
+ rescue ::Win32::Registry::Error
164
+ end
165
+ end
166
+ end
167
+ rescue ::Win32::Registry::Error
168
+ end
169
+ packages
170
+ end
171
+ end
172
+ end
173
+
174
+ Chef::Recipe.send(:include, Windows::Helper)
@@ -0,0 +1,103 @@
1
+ #
2
+ # Author:: Doug MacEachern <dougm@vmware.com>
3
+ # Author:: Paul Morton (<pmorton@biaprotect.com>)
4
+ # Cookbook:: windows
5
+ # Library:: windows_privileged
6
+ #
7
+ # Copyright:: 2010-2017, VMware, Inc.
8
+ # Copyright:: 2011-2017, Business Intelligence Associates, Inc
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ #
22
+
23
+ # helpers for Windows API calls that require privilege adjustments
24
+ class Chef
25
+ class WindowsPrivileged
26
+ # File -> Load Hive... in regedit.exe
27
+ def reg_load_key(name, file)
28
+ load_deps
29
+
30
+ run(SE_BACKUP_NAME, SE_RESTORE_NAME) do
31
+ rc = RegLoadKey(HKEY_USERS, name.to_s, file)
32
+ if rc == ERROR_SUCCESS
33
+ return true
34
+ elsif rc == ERROR_SHARING_VIOLATION
35
+ return false
36
+ else
37
+ raise get_last_error(rc)
38
+ end
39
+ end
40
+ end
41
+
42
+ # File -> Unload Hive... in regedit.exe
43
+ def reg_unload_key(name)
44
+ load_deps
45
+
46
+ run(SE_BACKUP_NAME, SE_RESTORE_NAME) do
47
+ rc = RegUnLoadKey(HKEY_USERS, name.to_s)
48
+ raise get_last_error(rc) if rc != ERROR_SUCCESS
49
+ end
50
+ end
51
+
52
+ def run(*privileges)
53
+ load_deps
54
+
55
+ token = [0].pack('L')
56
+
57
+ unless OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, token)
58
+ raise get_last_error
59
+ end
60
+ token = token.unpack('L')[0]
61
+
62
+ privileges.each do |name|
63
+ unless adjust_privilege(token, name, SE_PRIVILEGE_ENABLED)
64
+ raise get_last_error
65
+ end
66
+ end
67
+
68
+ begin
69
+ yield
70
+ ensure # disable privs
71
+ privileges.each do |name|
72
+ adjust_privilege(token, name, 0)
73
+ end
74
+ end
75
+ end
76
+
77
+ def adjust_privilege(token, priv, attr = 0)
78
+ load_deps
79
+
80
+ luid = [0, 0].pack('Ll')
81
+ if LookupPrivilegeValue(nil, priv, luid)
82
+ new_state = [1, luid.unpack('Ll'), attr].flatten.pack('LLlL')
83
+ AdjustTokenPrivileges(token, 0, new_state, new_state.size, 0, 0)
84
+ end
85
+ end
86
+
87
+ private
88
+
89
+ def load_deps
90
+ if RUBY_PLATFORM =~ /mswin|mingw32|windows/
91
+ require 'windows/error'
92
+ require 'windows/registry'
93
+ require 'windows/process'
94
+ require 'windows/security'
95
+
96
+ include Windows::Error
97
+ include Windows::Registry
98
+ include Windows::Process
99
+ include Windows::Security
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Author:: Adam Edwards (<adamed@chef.io>)
3
+ #
4
+ # Copyright:: 2014-2017, Chef Software, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ if RUBY_PLATFORM =~ /mswin|mingw32|windows/
20
+ require 'win32ole'
21
+
22
+ def execute_wmi_query(wmi_query)
23
+ wmi = ::WIN32OLE.connect('winmgmts://')
24
+ result = wmi.ExecQuery(wmi_query)
25
+ return nil unless result.each.count > 0
26
+ result
27
+ end
28
+
29
+ def wmi_object_property(wmi_object, wmi_property)
30
+ wmi_object.send(wmi_property)
31
+ end
32
+ end
@@ -0,0 +1 @@
1
+ {"name":"windows","version":"3.1.0","description":"Provides a set of useful Windows-specific primitives.","long_description":"# Windows Cookbook\n\n[![Build status](https://ci.appveyor.com/api/projects/status/9x4uepmm1g4rktie/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks/windows/branch/master) [![Cookbook Version](https://img.shields.io/cookbook/v/windows.svg)](https://supermarket.chef.io/cookbooks/windows)\n\nProvides a set of Windows-specific resources to aid in the creation of cookbooks/recipes targeting the Windows platform.\n\n## Requirements\n\n### Platforms\n\n- Windows 7\n- Windows Server 2008 R2\n- Windows 8, 8.1\n- Windows Server 2012 (R1, R2)\n\n### Chef\n\n- Chef 12.6+\n\n## Resources\n\n### windows_auto_run\n\n#### Actions\n\n- `:create` - Create an item to be run at login\n- `:remove` - Remove an item that was previously setup to run at login\n\n#### Properties\n\n- `name` - Name attribute. The name of the value to be stored in the registry\n- `program` - The program to be run at login\n- `args` - The arguments for the program\n\n#### Examples\n\nRun BGInfo at login\n\n```ruby\nwindows_auto_run 'BGINFO' do\n program 'C:/Sysinternals/bginfo.exe'\n args '\\'C:/Sysinternals/Config.bgi\\' /NOLICPROMPT /TIMER:0'\n action :create\nend\n```\n\n### windows_certificate\n\nInstalls a certificate into the Windows certificate store from a file, and grants read-only access to the private key for designated accounts. Due to current limitations in WinRM, installing certificated remotely may not work if the operation requires a user profile. Operations on the local machine store should still work.\n\n#### Actions\n\n- `:create` - creates or updates a certificate.\n- `:delete` - deletes a certificate.\n- `:acl_add` - adds read-only entries to a certificate's private key ACL.\n\n#### Properties\n\n- `source` - name attribute. The source file (for create and acl_add), thumbprint (for delete and acl_add) or subject (for delete).\n- `pfx_password` - the password to access the source if it is a pfx file.\n- `private_key_acl` - array of 'domain\\account' entries to be granted read-only access to the certificate's private key. This is not idempotent.\n- `store_name` - the certificate store to manipulate. One of MY (default : personal store), CA (trusted intermediate store) or ROOT (trusted root store).\n- `user_store` - if false (default) then use the local machine store; if true then use the current user's store.\n\n#### Examples\n\n```ruby\n# Add PFX cert to local machine personal store and grant accounts read-only access to private key\nwindows_certificate \"c:/test/mycert.pfx\" do\n pfx_password \"password\"\n private_key_acl [\"acme\\fred\", \"pc\\jane\"]\nend\n```\n\n```ruby\n# Add cert to trusted intermediate store\nwindows_certificate \"c:/test/mycert.cer\" do\n store_name \"CA\"\nend\n```\n\n```ruby\n# Remove all certificates matching the subject\nwindows_certificate \"me.acme.com\" do\n action :delete\nend\n```\n\n### windows_certificate_binding\n\nBinds a certificate to an HTTP port in order to enable TLS communication.\n\n#### Actions\n\n- `:create` - creates or updates a binding.\n- `:delete` - deletes a binding.\n\n#### Properties\n\n- `cert_name` - name attribute. The thumbprint(hash) or subject that identifies the certificate to be bound.\n- `name_kind` - indicates the type of cert_name. One of :subject (default) or :hash.\n- `address` - the address to bind against. Default is 0.0.0.0 (all IP addresses).\n- `port` - the port to bind against. Default is 443.\n- `app_id` - the GUID that defines the application that owns the binding. Default is the values used by IIS.\n- `store_name` - the store to locate the certificate in. One of MY (default : personal store), CA (trusted intermediate store) or ROOT (trusted root store).\n\n#### Examples\n\n```ruby\n# Bind the first certificate matching the subject to the default TLS port\nwindows_certificate_binding \"me.acme.com\" do\nend\n```\n\n```ruby\n# Bind a cert from the CA store with the given hash to port 4334\nwindows_certificate_binding \"me.acme.com\" do\n cert_name \"d234567890a23f567c901e345bc8901d34567890\"\n name_kind :hash\n store_name \"CA\"\n port 4334\nend\n```\n\n### windows_feature\n\n**BREAKING CHANGE - Version 3.0.0**\n\nThis resource has been moved from using LWRPs and multiple providers to using Custom Resources. To maintain functionality, you'll need to change `provider` to `install_method`.\n\nWindows Roles and Features can be thought of as built-in operating system packages that ship with the OS. A server role is a set of software programs that, when they are installed and properly configured, lets a computer perform a specific function for multiple users or other computers within a network. A Role can have multiple Role Services that provide functionality to the Role. Role services are software programs that provide the functionality of a role. Features are software programs that, although they are not directly parts of roles, can support or augment the functionality of one or more roles, or improve the functionality of the server, regardless of which roles are installed. Collectively we refer to all of these attributes as 'features'.\n\nThis resource allows you to manage these 'features' in an unattended, idempotent way.\n\nThere are three methods for the `windows_feature` which map into Microsoft's three major tools for managing roles/features: [Deployment Image Servicing and Management (DISM)](http://msdn.microsoft.com/en-us/library/dd371719%28v=vs.85%29.aspx), [Servermanagercmd](http://technet.microsoft.com/en-us/library/ee344834%28WS.10%29.aspx) (The CLI for Server Manager), and [PowerShell](https://technet.microsoft.com/en-us/library/cc731774(v=ws.11).aspx). As Servermanagercmd is deprecated, Chef will set the default method to `:windows_feature_dism` if `dism.exe` is present on the system being configured. The default method will fall back to `:windows_feature_servermanagercmd`, and then `:windows_feature_powershell`.\n\nFor more information on Roles, Role Services and Features see the [Microsoft TechNet article on the topic](http://technet.microsoft.com/en-us/library/cc754923.aspx). For a complete list of all features that are available on a node type either of the following commands at a command prompt:\n\nFor Dism:\n\n```text\ndism /online /Get-Features\n```\n\nFor ServerManagerCmd:\n\n```text\nservermanagercmd -query\n```\n\nFor PowerShell:\n\n```text\nget-windowsfeature\n```\n\n#### Actions\n\n- `:install` - install a Windows role/feature\n- `:remove` - remove a Windows role/feature\n- `:delete` - remove a Windows role/feature from the image (not supported by ServerManagerCmd)\n\n#### Properties\n\n- `feature_name` - name of the feature/role(s) to install. The same feature may have different names depending on the provider used (ie DHCPServer vs DHCP; DNS-Server-Full-Role vs DNS).\n- `all` - Boolean. Optional. Default: false. DISM and Powershell providers only. Forces all dependencies to be installed.\n- `source` - String. Optional. DISM provider only. Uses local repository for feature install.\n- `install_method` - Symbol. Optional. **REPLACEMENT FOR THE PREVIOUS PROVIDER OPTION** If not supplied, Chef will determine which method to use (in the order of `:windows_feature_dism`, `:windows_feature_servercmd`, `:windows_feature_powershell`)\n\n#### Examples\n\nInstall the DHCP Server feature\n\n```ruby\nwindows_feature 'DHCPServer' do\n action :install\nend\n```\n\nInstall the .Net 3.5.1 feature on Server 2012 using repository files on DVD and install all dependencies\n\n```ruby\nwindows_feature \"NetFx3\" do\n action :install\n all true\n source \"d:\\sources\\sxs\"\nend\n```\n\nRemove Telnet Server and Client features\n\n```ruby\nwindows_feature ['TelnetServer', 'TelnetClient'] do\n action :remove\nend\n```\n\nAdd the SMTP Server feature using the PowerShell provider\n\n```ruby\nwindows_feature \"smtp-server\" do\n action :install\n all true\n install_method :windows_feature_powershell\nend\n```\n\nInstall multiple features using one resource with the PowerShell provider\n\n```ruby\nwindows_feature ['Web-Asp-Net45', 'Web-Net-Ext45'] do\n action :install\n install_method :windows_feature_powershell\nend\n```\n\n### windows_font\n\nInstalls a font.\n\nFont files should be included in the cookbooks\n\n#### Actions\n\n- `:install` - install a font to the system fonts directory.\n\n#### Properties\n\n- `name` - The file name of the font file name to install. The path defaults to the files/default directory of the cookbook you're calling windows_font from. Defaults to the resource name.\n- `source` - Set an alternate path to the font file.\n\n#### Examples\n\n```ruby\nwindows_font 'Code New Roman.otf'\n```\n\n### windows_http_acl\n\nSets the Access Control List for an http URL to grant non-admin accounts permission to open HTTP endpoints.\n\n#### Actions\n\n- `:create` - creates or updates the ACL for a URL.\n- `:delete` - deletes the ACL from a URL.\n\n#### Properties\n\n- `url` - the name of the url to be created/deleted.\n- `sddl` - the DACL string configuring all permissions to URL. Mandatory for create if user is not provided. Can't be use with `user`.\n- `user` - the name (domain\\user) of the user or group to be granted permission to the URL. Mandatory for create if sddl is not provided. Can't be use with `sddl`. Only one user or group can be granted permission so this replaces any previously defined entry.\n\n#### Examples\n\n```ruby\nwindows_http_acl 'http://+:50051/' do\n user 'pc\\\\fred'\nend\n```\n\n```ruby\n# Grant access to users \"NT SERVICE\\WinRM\" and \"NT SERVICE\\Wecsvc\" via sddl\nwindows_http_acl 'http://+:5985/' do\n sddl 'D:(A;;GX;;;S-1-5-80-569256582-2953403351-2909559716-1301513147-412116970)(A;;GX;;;S-1-5-80-4059739203-877974739-1245631912-527174227-2996563517)'\nend\n```\n\n```ruby\nwindows_http_acl 'http://+:50051/' do\n action :delete\nend\n```\n\n### windows_pagefile\n\nConfigures the file that provides virtual memory for applications requiring more memory than available RAM or that are paged out to free up memory in use.\n\n\n#### Actions\n\n- `:set` - configures the default pagefile, creating if it doesn't exist.\n- `:delete` - deletes the specified pagefile.\n\n#### Properties\n\n- `name` - the path to the pagefile, String, name_property: true\n- `system_managed` - configures whether the system manages the pagefile size. [true, false]\n- `automatic_managed` - all of the settings are managed by the system. If this is set to true, other settings will be ignored. [true, false], default: false\n- `initial_size` - initial size of the pagefile in bytes. Integer\n- `maximum_size` - maximum size of the pagefile in bytes. Integer\n\n### windows_printer_port\n\nCreate and delete TCP/IPv4 printer ports.\n\n#### Actions\n\n- `:create` - Create a TCIP/IPv4 printer port. This is the default action.\n- `:delete` - Delete a TCIP/IPv4 printer port\n\n#### Properties\n\n- `ipv4_address` - Name attribute. Required. IPv4 address, e.g. '10.0.24.34'\n- `port_name` - Port name. Optional. Defaults to 'IP_' + `ipv4_address`\n- `port_number` - Port number. Optional. Defaults to 9100.\n- `port_description` - Port description. Optional.\n- `snmp_enabled` - Boolean. Optional. Defaults to false.\n- `port_protocol` - Port protocol, 1 (RAW), or 2 (LPR). Optional. Defaults to 1.\n\n#### Examples\n\nCreate a TCP/IP printer port named 'IP_10.4.64.37' with all defaults\n\n```ruby\nwindows_printer_port '10.4.64.37' do\n action :create\nend\n```\n\nDelete a printer port\n\n```ruby\nwindows_printer_port '10.4.64.37' do\n action :delete\nend\n```\n\nDelete a port with a custom port_name\n\n```ruby\nwindows_printer_port '10.4.64.38' do\n port_name 'My awesome port'\n action :delete\nend\n```\n\nCreate a port with more options\n\n```ruby\nwindows_printer_port '10.4.64.39' do\n port_name 'My awesome port'\n snmp_enabled true\n port_protocol 2\nend\n```\n\n### windows_printer\n\nCreate Windows printer. Note that this doesn't currently install a printer driver. You must already have the driver installed on the system.\n\nThe Windows Printer LWRP will automatically create a TCP/IP printer port for you using the `ipv4_address` property. If you want more granular control over the printer port, just create it using the `windows_printer_port` LWRP before creating the printer.\n\n#### Actions\n\n- `:create` - Create a new printer\n- `:delete` - Delete a new printer\n\n#### Properties\n\n- `device_id` - Name attribute. Required. Printer queue name, e.g. 'HP LJ 5200 in fifth floor copy room'\n- `comment` - Optional string describing the printer queue.\n- `default` - Boolean. Optional. Defaults to false. Note that Windows sets the first printer defined to the default printer regardless of this setting.\n- `driver_name` - String. Required. Exact name of printer driver. Note that the printer driver must already be installed on the node.\n- `location` - Printer location, e.g. 'Fifth floor copy room', or 'US/NYC/Floor42/Room4207'\n- `shared` - Boolean. Defaults to false.\n- `share_name` - Printer share name.\n- `ipv4_address` - Printer IPv4 address, e.g. '10.4.64.23'. You don't have to be able to ping the IP address to set it. Required.\n\nAn error of \"Set-WmiInstance : Generic failure\" is most likely due to the printer driver name not matching or not being installed.\n\n#### Examples\n\nCreate a printer\n\n```ruby\nwindows_printer 'HP LaserJet 5th Floor' do\n driver_name 'HP LaserJet 4100 Series PCL6'\n ipv4_address '10.4.64.38'\nend\n```\n\nDelete a printer. Note: this doesn't delete the associated printer port. See `windows_printer_port` above for how to delete the port.\n\n```ruby\nwindows_printer 'HP LaserJet 5th Floor' do\n action :delete\nend\n```\n\n### windows_share\n\nCreates, modifies and removes Windows shares. All properties are idempotent.\n\n#### Actions\n\n- :create: creates/modifies a share\n- :delete: deletes a share\n\n#### Properties\n\n- share_name: name attribute, the share name.\n- path: path to the directory to be shared. Required when creating. If the share already exists on a different path then it is deleted and re-created.\n- description: description to be applied to the share\n- full_users: array of users which should have \"Full control\" permissions\n- change_users: array of users which should have \"Change\" permissions\n- read_users: array of users which should have \"Read\" permissions\n\n#### Examples\n\n```ruby\nwindows_share \"foo\" do\n action :create\n path \"C:\\\\foo\"\n full_users [\"DOMAIN_A\\\\some_user\", \"DOMAIN_B\\\\some_other_user\"]\n read_users [\"DOMAIN_C\\\\Domain users\"]\nend\n```\n\n```ruby\nwindows_share \"foo\" do\n action :delete\nend\n```\n\n### windows_shortcut\n\nCreates and modifies Windows shortcuts.\n\n#### Actions\n\n- `:create` - create or modify a windows shortcut\n\n#### Properties\n\n- `name` - name attribute. The shortcut to create/modify.\n- `target` - what the shortcut links to\n- `arguments` - arguments to pass to the target when the shortcut is executed\n- `description` - description of the shortcut\n- `cwd` - Working directory to use when the target is executed\n- `iconlocation` - Icon to use, in the format of `\"path, index\"` where index is which icon in that file to use (See [WshShortcut.IconLocation](https://msdn.microsoft.com/en-us/library/3s9bx7at.aspx))\n\n#### Examples\n\nAdd a shortcut all users desktop:\n\n```ruby\nrequire 'win32ole'\nall_users_desktop = WIN32OLE.new(\"WScript.Shell\").SpecialFolders(\"AllUsersDesktop\")\n\nwindows_shortcut \"#{all_users_desktop}/Notepad.lnk\" do\n target \"C:\\\\WINDOWS\\\\notepad.exe\"\n description \"Launch Notepad\"\n iconlocation \"C:\\\\windows\\\\notepad.exe, 0\"\nend\n```\n\n#### Library Methods\n\n```ruby\nRegistry.value_exists?('HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run','BGINFO')\nRegistry.key_exists?('HKLM\\SOFTWARE\\Microsoft')\nBgInfo = Registry.get_value('HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run','BGINFO')\n```\n\n### windows_path\n\n#### Actions\n\n- `:add` - Add an item to the system path\n- `:remove` - Remove an item from the system path\n\n#### Properties\n\n- `path` - Name attribute. The name of the value to add to the system path\n\n#### Examples\n\nAdd Sysinternals to the system path\n\n```ruby\nwindows_path 'C:\\Sysinternals' do\n action :add\nend\n```\n\nRemove 7-Zip from the system path\n\n```ruby\nwindows_path 'C:\\7-Zip' do\n action :remove\nend\n```\n\n### windows_task\n\nCreates, deletes or runs a Windows scheduled task. Requires Windows Server 2008 due to API usage.\n\n#### Actions\n\n- `:create` - creates a task (or updates existing if user or command has changed)\n- `:delete` - deletes a task\n- `:run` - runs a task\n- `:end` - ends a task\n- `:change` - changes the un/pw or command of a task\n- `:enable` - enable a task\n- `:disable` - disable a task\n\n#### Properties\n\n- `task_name` - name attribute, The task name. (\"Task Name\" or \"/Task Name\")\n- `force` - When used with create, will update the task.\n- `command` - The command the task will run.\n- `cwd` - The directory the task will be run from.\n- `user` - The user to run the task as. (defaults to 'SYSTEM')\n- `password` - The user's password. (requires user)\n- `run_level` - Run with `:limited` or `:highest` privileges.\n- `frequency` - Frequency with which to run the task. (default is :hourly. Other valid values include :minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle) :once requires start_time\n- `frequency_modifier` - Multiple for frequency. (15 minutes, 2 days). Monthly tasks may also use these values\": ('FIRST', 'SECOND', 'THIRD', 'FOURTH', 'LAST', 'LASTDAY')\n- `start_day` - Specifies the first date on which the task runs. Optional string (MM/DD/YYYY)\n- `start_time` - Specifies the start time to run the task. Optional string (HH:mm)\n- `interactive_enabled` - (Allow task to run interactively or non-interactively. Requires user and password.)\n- `day` - For monthly or weekly tasks, the day(s) on which the task runs. (MON - SUN, *, 1 - 31)\n- `months` - The Months of the year on which the task runs. (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC, *). Multiple months should be comma delimited.\n- `idle_time` - For :on_idle frequency, the time (in minutes) without user activity that must pass to trigger the task. (1 - 999)\n\n#### Examples\n\nCreate a `chef-client` task with TaskPath `\\` running every 15 minutes\n\n```ruby\nwindows_task 'chef-client' do\n user 'Administrator'\n password '$ecR3t'\n cwd 'C:\\\\chef\\\\bin'\n command 'chef-client -L C:\\\\tmp\\\\'\n run_level :highest\n frequency :minute\n frequency_modifier 15\nend\n```\n\nUpdate `chef-client` task with new password and log location\n\n```ruby\nwindows_task 'chef-client' do\n user 'Administrator'\n password 'N3wPassW0Rd'\n cwd 'C:\\\\chef\\\\bin'\n command 'chef-client -L C:\\\\chef\\\\logs\\\\'\n action :change\nend\n```\n\nDelete a task named `old task`\n\n```ruby\nwindows_task 'old task' do\n action :delete\nend\n```\n\nEnable a task named `chef-client`\n\n```ruby\nwindows_task 'chef-client' do\n action :enable\nend\n```\n\nDisable a task named `ProgramDataUpdater` with TaskPath `\\Microsoft\\Windows\\Application Experience\\`\n\n```ruby\nwindows_task '\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater' do\n action :disable\nend\n```\n\n### windows_zipfile\n\nMost version of Windows do not ship with native cli utility for managing compressed files. This resource provides a pure-ruby implementation for managing zip files. Be sure to use the `not_if` or `only_if` meta parameters to guard the resource for idempotence or action will be taken every Chef run.\n\n#### Actions\n\n- `:unzip` - unzip a compressed file\n- `:zip` - zip a directory (recursively)\n\n#### Properties\n\n- `path` - name attribute. The path where files will be (un)zipped to.\n- `source` - source of the zip file (either a URI or local path) for :unzip, or directory to be zipped for :zip.\n- `overwrite` - force an overwrite of the files if they already exist.\n- `checksum` - for :unzip, useful if source is remote, if the local file matches the SHA-256 checksum, Chef will not download it.\n\n#### Examples\n\nUnzip a remote zip file locally\n\n```ruby\nwindows_zipfile 'c:/bin' do\n source 'http://download.sysinternals.com/Files/SysinternalsSuite.zip'\n action :unzip\n not_if {::File.exists?('c:/bin/PsExec.exe')}\nend\n```\n\nUnzip a local zipfile\n\n```ruby\nwindows_zipfile 'c:/the_codez' do\n source 'c:/foo/baz/the_codez.zip'\n action :unzip\nend\n```\n\nCreate a local zipfile\n\n```ruby\nwindows_zipfile 'c:/foo/baz/the_codez.zip' do\n source 'c:/the_codez'\n action :zip\nend\n```\n\n## Libraries\n\n### WindowsHelper\n\nHelper that allows you to use helpful functions in windows\n\n#### installed_packages\n\nReturns a hash of all DisplayNames installed\n\n```ruby\n# usage in a recipe\n::Chef::Recipe.send(:include, Windows::Helper)\nhash_of_installed_packages = installed_packages\n```\n\n#### is_package_installed?\n\n- `package_name` - The name of the package you want to query to see if it is installed\n- `returns` - true if the package is installed, false if it the package is not installed\n\nDownload a file if a package isn't installed\n\n```ruby\n# usage in a recipe to not download a file if package is already installed\n::Chef::Recipe.send(:include, Windows::Helper)\nis_win_sdk_installed = is_package_installed?('Windows Software Development Kit')\n\nremote_file 'C:\\windows\\temp\\windows_sdk.zip' do\n source 'http://url_to_download/windows_sdk.zip'\n action :create_if_missing\n not_if {is_win_sdk_installed}\nend\n```\n\nDo something if a package is installed\n\n```ruby\n# usage in a provider\ninclude Windows::Helper\nif is_package_installed?('Windows Software Development Kit')\n # do something if package is installed\nend\n```\n\n### Windows::VersionHelper\n\nHelper that allows you to get information of the windows version running on your node. It leverages windows ohai from kernel.os_info, easy to mock and to use even on linux.\n\n#### core_version?\n\nDetermines whether given node is running on a windows Core.\n\n```ruby\nif ::Windows::VersionHelper.core_version? node\n fail 'Windows Core is not supported'\nend\n```\n\n#### workstation_version?\n\nDetermines whether given node is a windows workstation version (XP, Vista, 7, 8, 8.1, 10)\n\n```ruby\nif ::Windows::VersionHelper.workstation_version? node\n fail 'Only server version of windows are supported'\nend\n```\n\n#### server_version?\n\nDetermines whether given node is a windows server version (Server 2003, Server 2008, Server 2012, Server 2016)\n\n```ruby\nif ::Windows::VersionHelper.server_version? node\n puts 'Server version of windows are cool'\nend\n```\n\n#### nt_version\n\nDetermines NT version of the given node\n\n```ruby\ncase ::Windows::VersionHelper.nt_version node\n when '6.0' then 'Windows vista or Server 2008'\n when '6.1' then 'Windows 7 or Server 2008R2'\n when '6.2' then 'Windows 8 or Server 2012'\n when '6.3' then 'Windows 8.1 or Server 2012R2'\n when '10.0' then 'Windows 10'\nend\n```\n\n## Windows ChefSpec Matchers\n\nThe Windows cookbook includes custom [ChefSpec](https://github.com/sethvargo/chefspec) matchers you can use to test your own cookbooks that consume Windows cookbook LWRPs.\n\n### Example Matcher Usage\n\n```ruby\nexpect(chef_run).to install_windows_package('Node.js').with(\n source: 'http://nodejs.org/dist/v0.10.26/x64/node-v0.10.26-x64.msi')\n```\n\n### Windows Cookbook Matchers\n\n- create_windows_auto_run\n- remove_windows_auto_run\n- create_windows_certificate\n- delete_windows_certificate\n- add_acl_to_windows_certificate\n- create_windows_certificate_binding\n- delete_windows_certificate_binding\n- install_windows_feature\n- install_windows_feature_dism\n- install_windows_feature_servermanagercmd\n- install_windows_feature_powershell\n- remove_windows_feature\n- remove_windows_feature_dism\n- remove_windows_feature_servermanagercmd\n- remove_windows_feature_powershell\n- delete_windows_feature\n- delete_windows_feature_dism\n- delete_windows_feature_powershell\n- install_windows_font\n- create_windows_http_acl\n- delete_windows_http_acl\n- install_windows_package\n- remove_windows_package\n- set_windows_pagefile\n- add_windows_path\n- remove_windows_path\n- create_windows_printer\n- delete_windows_printer\n- create_windows_printer_port\n- delete_windows_printer_port\n- create_windows_shortcut\n- create_windows_shortcut\n- create_windows_task\n- disable_windows_task\n- enable_windows_task\n- delete_windows_task\n- run_windows_task\n- change_windows_task\n- unzip_windows_zipfile_to\n- zip_windows_zipfile_to\n\n## Usage\n\nPlace an explicit dependency on this cookbook (using depends in the cookbook's metadata.rb) from any cookbook where you would like to use the Windows-specific resources/providers that ship with this cookbook.\n\n```ruby\ndepends 'windows'\n```\n\n## License & Authors\n\n- Author:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io))\n- Author:: Doug MacEachern ([dougm@vmware.com](mailto:dougm@vmware.com))\n- Author:: Paul Morton ([pmorton@biaprotect.com](mailto:pmorton@biaprotect.com))\n- Author:: Doug Ireton ([doug.ireton@nordstrom.com](mailto:doug.ireton@nordstrom.com))\n\n```text\nCopyright 2011-2016, Chef Software, Inc.\nCopyright 2010, VMware, Inc.\nCopyright 2011, Business Intelligence Associates, Inc\nCopyright 2012, Nordstrom, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"windows":">= 0.0.0"},"dependencies":{"ohai":">= 4.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/windows","issues_url":"https://github.com/chef-cookbooks/windows/issues","chef_version":[[">= 12.7"]],"ohai_version":[]}
@@ -0,0 +1,21 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Cookbook:: windows
4
+ # Recipe:: default
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
+ Chef::Log.warn('The windows::default recipe has been deprecated. The gems previously installed in this recipe ship in the Chef MSI.')
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Paul Morton (<pmorton@biaprotect.com>)
3
+ # Cookbook:: windows
4
+ # Resource:: auto_run
5
+ #
6
+ # Copyright:: 2011-2017, Business Intelligence Associates, Inc.
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 :program, String
23
+ property :name, String, name_property: true
24
+ property :args, String
25
+
26
+ action :create do
27
+ registry_key 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' do
28
+ values [{
29
+ name: new_resource.name,
30
+ type: :string,
31
+ data: "\"#{new_resource.program}\" #{new_resource.args}",
32
+ }]
33
+ action :create
34
+ end
35
+ end
36
+
37
+ action :remove do
38
+ registry_key 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' do
39
+ values [{
40
+ name: new_resource.name,
41
+ type: :string,
42
+ data: '',
43
+ }]
44
+ action :delete
45
+ end
46
+ end
@@ -0,0 +1,166 @@
1
+ #
2
+ # Author:: Richard Lavey (richard.lavey@calastone.com)
3
+ # Cookbook:: windows
4
+ # Resource:: certificate
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 Windows::Helper
22
+
23
+ property :source, String, name_property: true, required: true
24
+ property :pfx_password, String
25
+ property :private_key_acl, Array
26
+ property :store_name, String, default: 'MY', regex: /^(?:MY|CA|ROOT|TrustedPublisher|TRUSTEDPEOPLE)$/
27
+ property :user_store, [true, false], default: false
28
+
29
+ action :create do
30
+ hash = '$cert.GetCertHashString()'
31
+ code_script = cert_script(true) <<
32
+ within_store_script { |store| store + '.Add($cert)' } <<
33
+ acl_script(hash)
34
+
35
+ guard_script = cert_script(false) <<
36
+ cert_exists_script(hash)
37
+
38
+ converge_by("adding certificate #{new_resource.source} into #{new_resource.store_name} to #{cert_location}\\#{new_resource.store_name}") do
39
+ powershell_script new_resource.name do
40
+ guard_interpreter :powershell_script
41
+ convert_boolean_return true
42
+ code code_script
43
+ not_if guard_script
44
+ end
45
+ end
46
+ end
47
+
48
+ # acl_add is a modify-if-exists operation : not idempotent
49
+ action :acl_add do
50
+ if ::File.exist?(new_resource.source)
51
+ hash = '$cert.GetCertHashString()'
52
+ code_script = cert_script(false)
53
+ guard_script = cert_script(false)
54
+ else
55
+ # make sure we have no spaces in the hash string
56
+ hash = "\"#{new_resource.source.gsub(/\s/, '')}\""
57
+ code_script = ''
58
+ guard_script = ''
59
+ end
60
+ code_script << acl_script(hash)
61
+ guard_script << cert_exists_script(hash)
62
+
63
+ converge_by("setting the acls on #{new_resource.source} in #{cert_location}\\#{new_resource.store_name}") do
64
+ powershell_script new_resource.name do
65
+ guard_interpreter :powershell_script
66
+ convert_boolean_return true
67
+ code code_script
68
+ only_if guard_script
69
+ end
70
+ end
71
+ end
72
+
73
+ action :delete do
74
+ # do we have a hash or a subject?
75
+ # TODO: It's a bit annoying to know the thumbprint of a cert you want to remove when you already
76
+ # have the file. Support reading the hash directly from the file if provided.
77
+ search = if new_resource.source =~ /^[a-fA-F0-9]{40}$/
78
+ "Thumbprint -eq '#{new_resource.source}'"
79
+ else
80
+ "Subject -like '*#{new_resource.source.sub(/\*/, '`*')}*'" # escape any * in the source
81
+ end
82
+ cert_command = "Get-ChildItem Cert:\\#{cert_location}\\#{new_resource.store_name} | where { $_.#{search} }"
83
+
84
+ code_script = within_store_script do |store|
85
+ <<-EOH
86
+ foreach ($c in #{cert_command})
87
+ {
88
+ #{store}.Remove($c)
89
+ }
90
+ EOH
91
+ end
92
+ guard_script = "@(#{cert_command}).Count -gt 0\n"
93
+ converge_by("Removing certificate #{new_resource.source} from #{cert_location}\\#{new_resource.store_name}") do
94
+ powershell_script new_resource.name do
95
+ guard_interpreter :powershell_script
96
+ convert_boolean_return true
97
+ code code_script
98
+ only_if guard_script
99
+ end
100
+ end
101
+ end
102
+
103
+ action_class do
104
+ def cert_location
105
+ @location ||= new_resource.user_store ? 'CurrentUser' : 'LocalMachine'
106
+ end
107
+
108
+ def cert_script(persist)
109
+ cert_script = '$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2'
110
+ file = win_friendly_path(new_resource.source)
111
+ cert_script << " \"#{file}\""
112
+ if ::File.extname(file.downcase) == '.pfx'
113
+ cert_script << ", \"#{new_resource.pfx_password}\""
114
+ if persist && new_resource.user_store
115
+ cert_script << ', [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet'
116
+ elsif persist
117
+ cert_script << ', ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeyset)'
118
+ end
119
+ end
120
+ cert_script << "\n"
121
+ end
122
+
123
+ def cert_exists_script(hash)
124
+ <<-EOH
125
+ $hash = #{hash}
126
+ Test-Path "Cert:\\#{cert_location}\\#{new_resource.store_name}\\$hash"
127
+ EOH
128
+ end
129
+
130
+ def within_store_script
131
+ inner_script = yield '$store'
132
+ <<-EOH
133
+ $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "#{new_resource.store_name}", ([System.Security.Cryptography.X509Certificates.StoreLocation]::#{cert_location})
134
+ $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
135
+ #{inner_script}
136
+ $store.Close()
137
+ EOH
138
+ end
139
+
140
+ def acl_script(hash)
141
+ return '' if new_resource.private_key_acl.nil? || new_resource.private_key_acl.empty?
142
+ # this PS came from http://blogs.technet.com/b/operationsguy/archive/2010/11/29/provide-access-to-private-keys-commandline-vs-powershell.aspx
143
+ # and from https://msdn.microsoft.com/en-us/library/windows/desktop/bb204778(v=vs.85).aspx
144
+ set_acl_script = <<-EOH
145
+ $hash = #{hash}
146
+ $storeCert = Get-ChildItem "cert:\\#{cert_location}\\#{new_resource.store_name}\\$hash"
147
+ if ($storeCert -eq $null) { throw 'no key exists.' }
148
+ $keyname = $storeCert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
149
+ if ($keyname -eq $null) { throw 'no private key exists.' }
150
+ if ($storeCert.PrivateKey.CspKeyContainerInfo.MachineKeyStore)
151
+ {
152
+ $fullpath = "$Env:ProgramData\\Microsoft\\Crypto\\RSA\\MachineKeys\\$keyname"
153
+ }
154
+ else
155
+ {
156
+ $currentUser = New-Object System.Security.Principal.NTAccount($Env:UserDomain, $Env:UserName)
157
+ $userSID = $currentUser.Translate([System.Security.Principal.SecurityIdentifier]).Value
158
+ $fullpath = "$Env:ProgramData\\Microsoft\\Crypto\\RSA\\$userSID\\$keyname"
159
+ }
160
+ EOH
161
+ new_resource.private_key_acl.each do |name|
162
+ set_acl_script << "$uname='#{name}'; icacls $fullpath /grant $uname`:RX\n"
163
+ end
164
+ set_acl_script
165
+ end
166
+ end