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,152 @@
1
+ #
2
+ # Author:: Kevin Moser (<kevin.moser@nordstrom.com>)
3
+ # Cookbook:: windows
4
+ # Resource:: pagefile
5
+ #
6
+ # Copyright:: 2012-2017, Nordstrom, 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 :name, String, name_property: true
23
+ property :system_managed, [true, false]
24
+ property :automatic_managed, [true, false], default: false
25
+ property :initial_size, Integer
26
+ property :maximum_size, Integer
27
+
28
+ include Chef::Mixin::ShellOut
29
+ include Windows::Helper
30
+
31
+ action :set do
32
+ pagefile = new_resource.name
33
+ initial_size = new_resource.initial_size
34
+ maximum_size = new_resource.maximum_size
35
+ system_managed = new_resource.system_managed
36
+ automatic_managed = new_resource.automatic_managed
37
+
38
+ if automatic_managed
39
+ set_automatic_managed unless automatic_managed?
40
+ else
41
+ unset_automatic_managed if automatic_managed?
42
+
43
+ # Check that the resource is not just trying to unset automatic managed, if it is do nothing more
44
+ if (initial_size && maximum_size) || system_managed
45
+ validate_name
46
+ create(pagefile) unless exists?(pagefile)
47
+
48
+ if system_managed
49
+ set_system_managed(pagefile) unless max_and_min_set?(pagefile, 0, 0)
50
+ else
51
+ unless max_and_min_set?(pagefile, initial_size, maximum_size)
52
+ set_custom_size(pagefile, initial_size, maximum_size)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ action :delete do
60
+ validate_name
61
+ pagefile = new_resource.name
62
+ delete(pagefile) if exists?(pagefile)
63
+ end
64
+
65
+ action_class do
66
+ def validate_name
67
+ return if /^.:.*.sys/ =~ new_resource.name
68
+ raise "#{new_resource.name} does not match the format DRIVE:\\path\\file.sys for pagefiles. Example: C:\\pagefile.sys"
69
+ end
70
+
71
+ def exists?(pagefile)
72
+ @exists ||= begin
73
+ Chef::Log.debug("Checking if #{pagefile} exists")
74
+ cmd = shell_out("#{wmic} pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" list /format:list", returns: [0])
75
+ cmd.stderr.empty? && (cmd.stdout =~ /SettingID=#{get_setting_id(pagefile)}/i)
76
+ end
77
+ end
78
+
79
+ def max_and_min_set?(pagefile, min, max)
80
+ @max_and_min_set ||= begin
81
+ Chef::Log.debug("Checking if #{pagefile} min: #{min} and max #{max} are set")
82
+ cmd = shell_out("#{wmic} pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" list /format:list", returns: [0])
83
+ cmd.stderr.empty? && (cmd.stdout =~ /InitialSize=#{min}/i) && (cmd.stdout =~ /MaximumSize=#{max}/i)
84
+ end
85
+ end
86
+
87
+ def create(pagefile)
88
+ converge_by("create pagefile #{pagefile}") do
89
+ cmd = shell_out("#{wmic} pagefileset create name=\"#{win_friendly_path(pagefile)}\"")
90
+ check_for_errors(cmd.stderr)
91
+ end
92
+ end
93
+
94
+ def delete(pagefile)
95
+ converge_by("remove pagefile #{pagefile}") do
96
+ cmd = shell_out("#{wmic} pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" delete")
97
+ check_for_errors(cmd.stderr)
98
+ end
99
+ end
100
+
101
+ def automatic_managed?
102
+ @automatic_managed ||= begin
103
+ Chef::Log.debug('Checking if pagefiles are automatically managed')
104
+ cmd = shell_out("#{wmic} computersystem where name=\"%computername%\" get AutomaticManagedPagefile /format:list")
105
+ cmd.stderr.empty? && (cmd.stdout =~ /AutomaticManagedPagefile=TRUE/i)
106
+ end
107
+ end
108
+
109
+ def set_automatic_managed
110
+ converge_by('set pagefile to Automatic Managed') do
111
+ cmd = shell_out("#{wmic} computersystem where name=\"%computername%\" set AutomaticManagedPagefile=True")
112
+ check_for_errors(cmd.stderr)
113
+ end
114
+ end
115
+
116
+ def unset_automatic_managed
117
+ converge_by('set pagefile to User Managed') do
118
+ cmd = shell_out("#{wmic} computersystem where name=\"%computername%\" set AutomaticManagedPagefile=False")
119
+ check_for_errors(cmd.stderr)
120
+ end
121
+ end
122
+
123
+ def set_custom_size(pagefile, min, max)
124
+ converge_by("set #{pagefile} to InitialSize=#{min} & MaximumSize=#{max}") do
125
+ cmd = shell_out("#{wmic} pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" set InitialSize=#{min},MaximumSize=#{max}", returns: [0])
126
+ check_for_errors(cmd.stderr)
127
+ end
128
+ end
129
+
130
+ def set_system_managed(pagefile) # rubocop: disable Style/AccessorMethodName
131
+ converge_by("set #{pagefile} to System Managed") do
132
+ cmd = shell_out("#{wmic} pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" set InitialSize=0,MaximumSize=0", returns: [0])
133
+ check_for_errors(cmd.stderr)
134
+ end
135
+ end
136
+
137
+ def get_setting_id(pagefile)
138
+ pagefile = win_friendly_path(pagefile)
139
+ pagefile = pagefile.split('\\')
140
+ "#{pagefile[1]} @ #{pagefile[0]}"
141
+ end
142
+
143
+ def check_for_errors(stderr)
144
+ Chef::Log.fatal(stderr) unless stderr.empty?
145
+ end
146
+
147
+ def wmic
148
+ @wmic ||= begin
149
+ locate_sysnative_cmd('wmic.exe')
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # Author:: Paul Morton (<pmorton@biaprotect.com>)
3
+ # Cookbook:: windows
4
+ # Resource:: path
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 :path, String, name_property: true
23
+
24
+ include Windows::Helper
25
+
26
+ action :add do
27
+ env 'path' do
28
+ action :modify
29
+ delim ::File::PATH_SEPARATOR
30
+ value new_resource.path.tr('/', '\\')
31
+ notifies :run, "ruby_block[fix ruby ENV['PATH']]", :immediately
32
+ end
33
+
34
+ # The windows Env provider does not correctly expand variables in
35
+ # the PATH environment variable. Ruby expects these to be expanded.
36
+ # This is a temporary fix for that.
37
+ #
38
+ # Follow at https://github.com/chef/chef/pull/1876
39
+ #
40
+ ruby_block "fix ruby ENV['PATH']" do
41
+ block do
42
+ ENV['PATH'] = expand_env_vars(ENV['PATH'])
43
+ end
44
+ action :nothing
45
+ end
46
+ end
47
+
48
+ action :remove do
49
+ env 'path' do
50
+ action :delete
51
+ delim ::File::PATH_SEPARATOR
52
+ value new_resource.path.tr('/', '\\')
53
+ end
54
+ end
@@ -0,0 +1,103 @@
1
+ #
2
+ # Author:: Doug Ireton (<doug.ireton@nordstrom.com>)
3
+ # Cookbook:: windows
4
+ # Resource:: printer
5
+ #
6
+ # Copyright:: 2012-2017, Nordstrom, 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
+ # See here for more info:
21
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394492(v=vs.85).aspx
22
+
23
+ require 'resolv'
24
+
25
+ property :device_id, String, name_property: true, required: true
26
+ property :comment, String
27
+ property :default, [true, false], default: false
28
+ property :driver_name, String, required: true
29
+ property :location, String
30
+ property :shared, [true, false], default: false
31
+ property :share_name, String
32
+ property :ipv4_address, String, regex: Resolv::IPv4::Regex
33
+ property :exists, [true, false], desired_state: true
34
+
35
+ PRINTERS_REG_KEY = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\\'.freeze unless defined?(PRINTERS_REG_KEY)
36
+
37
+ def printer_exists?(name)
38
+ printer_reg_key = PRINTERS_REG_KEY + name
39
+ Chef::Log.debug "Checking to see if this reg key exists: '#{printer_reg_key}'"
40
+ Registry.key_exists?(printer_reg_key)
41
+ end
42
+
43
+ load_current_value do |desired|
44
+ name desired.name
45
+ exists printer_exists?(desired.name)
46
+ # TODO: Set @current_resource printer properties from registry
47
+ end
48
+
49
+ action :create do
50
+ if @current_resource.exists
51
+ Chef::Log.info "#{@new_resource} already exists - nothing to do."
52
+ else
53
+ converge_by("Create #{@new_resource}") do
54
+ create_printer
55
+ end
56
+ end
57
+ end
58
+
59
+ action :delete do
60
+ if @current_resource.exists
61
+ converge_by("Delete #{@new_resource}") do
62
+ delete_printer
63
+ end
64
+ else
65
+ Chef::Log.info "#{@current_resource} doesn't exist - can't delete."
66
+ end
67
+ end
68
+
69
+ action_class do
70
+ def create_printer
71
+ # Create the printer port first
72
+ windows_printer_port new_resource.ipv4_address do
73
+ end
74
+
75
+ port_name = "IP_#{new_resource.ipv4_address}"
76
+
77
+ powershell_script "Creating printer: #{new_resource.name}" do
78
+ code <<-EOH
79
+
80
+ Set-WmiInstance -class Win32_Printer `
81
+ -EnableAllPrivileges `
82
+ -Argument @{ DeviceID = "#{new_resource.device_id}";
83
+ Comment = "#{new_resource.comment}";
84
+ Default = "$#{new_resource.default}";
85
+ DriverName = "#{new_resource.driver_name}";
86
+ Location = "#{new_resource.location}";
87
+ PortName = "#{port_name}";
88
+ Shared = "$#{new_resource.shared}";
89
+ ShareName = "#{new_resource.share_name}";
90
+ }
91
+ EOH
92
+ end
93
+ end
94
+
95
+ def delete_printer
96
+ powershell_script "Deleting printer: #{new_resource.name}" do
97
+ code <<-EOH
98
+ $printer = Get-WMIObject -class Win32_Printer -EnableAllPrivileges -Filter "name = '#{new_resource.name}'"
99
+ $printer.Delete()
100
+ EOH
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,101 @@
1
+ #
2
+ # Author:: Doug Ireton (<doug.ireton@nordstrom.com>)
3
+ # Cookbook:: windows
4
+ # Resource:: printer_port
5
+ #
6
+ # Copyright:: 2012-2017, Nordstrom, 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
+ # See here for more info:
21
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394492(v=vs.85).aspx
22
+
23
+ require 'resolv'
24
+
25
+ property :ipv4_address, String, name_attribute: true, required: true, regex: Resolv::IPv4::Regex
26
+ property :port_name, String
27
+ property :port_number, Integer, default: 9100
28
+ property :port_description, String
29
+ property :snmp_enabled, [true, false], default: false
30
+ property :port_protocol, Integer, default: 1, equal_to: [1, 2]
31
+ property :exists, [true, false], desired_state: true
32
+
33
+ PORTS_REG_KEY = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\\'.freeze unless defined?(PORTS_REG_KEY)
34
+
35
+ def port_exists?(name)
36
+ port_reg_key = PORTS_REG_KEY + name
37
+
38
+ Chef::Log.debug "Checking to see if this reg key exists: '#{port_reg_key}'"
39
+ Registry.key_exists?(port_reg_key)
40
+ end
41
+
42
+ load_current_value do |desired|
43
+ name desired.name
44
+ ipv4_address desired.ipv4_address
45
+ port_name desired.port_name || "IP_#{@new_resource.ipv4_address}"
46
+ exists port_exists?(desired.port_name)
47
+ # TODO: Set @current_resource port properties from registry
48
+ end
49
+
50
+ action :create do
51
+ if current_resource.exists
52
+ Chef::Log.info "#{@new_resource} already exists - nothing to do."
53
+ else
54
+ converge_by("Create #{@new_resource}") do
55
+ create_printer_port
56
+ end
57
+ end
58
+ end
59
+
60
+ action :delete do
61
+ if current_resource.exists
62
+ converge_by("Delete #{@new_resource}") do
63
+ delete_printer_port
64
+ end
65
+ else
66
+ Chef::Log.info "#{@current_resource} doesn't exist - can't delete."
67
+ end
68
+ end
69
+
70
+ action_class do
71
+ def create_printer_port
72
+ port_name = new_resource.port_name || "IP_#{new_resource.ipv4_address}"
73
+
74
+ # create the printer port using PowerShell
75
+ powershell_script "Creating printer port #{new_resource.port_name}" do
76
+ code <<-EOH
77
+
78
+ Set-WmiInstance -class Win32_TCPIPPrinterPort `
79
+ -EnableAllPrivileges `
80
+ -Argument @{ HostAddress = "#{new_resource.ipv4_address}";
81
+ Name = "#{port_name}";
82
+ Description = "#{new_resource.port_description}";
83
+ PortNumber = "#{new_resource.port_number}";
84
+ Protocol = "#{new_resource.port_protocol}";
85
+ SNMPEnabled = "$#{new_resource.snmp_enabled}";
86
+ }
87
+ EOH
88
+ end
89
+ end
90
+
91
+ def delete_printer_port
92
+ port_name = new_resource.port_name || "IP_#{new_resource.ipv4_address}"
93
+
94
+ powershell_script "Deleting printer port: #{new_resource.port_name}" do
95
+ code <<-EOH
96
+ $port = Get-WMIObject -class Win32_TCPIPPrinterPort -EnableAllPrivileges -Filter "name = '#{port_name}'"
97
+ $port.Delete()
98
+ EOH
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,291 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Author:: Sölvi Páll Ásgeirsson (<solvip@gmail.com>), Richard Lavey (richard.lavey@calastone.com)
4
+ # Cookbook:: windows
5
+ # Resource:: share
6
+ #
7
+ # Copyright:: 2014-2017, Sölvi Páll Ásgeirsson.
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 :share_name, String, name_property: true
23
+ property :path, String
24
+ property :description, String, default: ''
25
+ property :full_users, Array, default: []
26
+ property :change_users, Array, default: []
27
+ property :read_users, Array, default: []
28
+
29
+ include Windows::Helper
30
+ include Chef::Mixin::PowershellOut
31
+
32
+ require 'win32ole' if RUBY_PLATFORM =~ /mswin|mingw32|windows/
33
+
34
+ ACCESS_FULL = 2_032_127
35
+ ACCESS_CHANGE = 1_245_631
36
+ ACCESS_READ = 1_179_817
37
+
38
+ action :create do
39
+ raise 'No path property set' unless new_resource.path
40
+
41
+ if different_path?
42
+ unless current_resource.path.nil? || current_resource.path.empty?
43
+ converge_by('Removing previous share') do
44
+ delete_share
45
+ end
46
+ end
47
+ converge_by("Creating share #{current_resource.share_name}") do
48
+ create_share
49
+ end
50
+ end
51
+
52
+ if different_members?(:full_users) ||
53
+ different_members?(:change_users) ||
54
+ different_members?(:read_users) ||
55
+ different_description?
56
+ converge_by("Setting permissions and description for #{new_resource.share_name}") do
57
+ set_share_permissions
58
+ end
59
+ end
60
+ end
61
+
62
+ action :delete do
63
+ if !current_resource.path.nil? && !current_resource.path.empty?
64
+ converge_by("Deleting #{current_resource.share_name}") do
65
+ delete_share
66
+ end
67
+ else
68
+ Chef::Log.debug("#{current_resource.share_name} does not exist - nothing to do")
69
+ end
70
+ end
71
+
72
+ load_current_value do |desired|
73
+ wmi = WIN32OLE.connect('winmgmts://')
74
+ shares = wmi.ExecQuery("SELECT * FROM Win32_Share WHERE name = '#{desired.share_name}'")
75
+ existing_share = shares.Count == 0 ? nil : shares.ItemIndex(0)
76
+
77
+ description ''
78
+ unless existing_share.nil?
79
+ path existing_share.Path
80
+ description existing_share.Description
81
+ end
82
+
83
+ perms = share_permissions name
84
+ unless perms.nil?
85
+ full_users perms[:full_users]
86
+ change_users perms[:change_users]
87
+ read_users perms[:read_users]
88
+ end
89
+ end
90
+
91
+ def share_permissions(name)
92
+ wmi = WIN32OLE.connect('winmgmts://')
93
+ shares = wmi.ExecQuery("SELECT * FROM Win32_LogicalShareSecuritySetting WHERE name = '#{name}'")
94
+
95
+ # The security descriptor is an output parameter
96
+ sd = nil
97
+ begin
98
+ shares.ItemIndex(0).GetSecurityDescriptor(sd)
99
+ sd = WIN32OLE::ARGV[0]
100
+ rescue WIN32OLERuntimeError
101
+ Chef::Log.warn('Failed to retrieve any security information about the share.')
102
+ end
103
+
104
+ read = []
105
+ change = []
106
+ full = []
107
+
108
+ unless sd.nil?
109
+ sd.DACL.each do |dacl|
110
+ trustee = "#{dacl.Trustee.Domain}\\#{dacl.Trustee.Name}".downcase
111
+ case dacl.AccessMask
112
+ when ACCESS_FULL
113
+ full.push(trustee)
114
+ when ACCESS_CHANGE
115
+ change.push(trustee)
116
+ when ACCESS_READ
117
+ read.push(trustee)
118
+ else
119
+ Chef::Log.warn "Unknown access mask #{dacl.AccessMask} for user #{trustee}. This will be lost if permissions are updated"
120
+ end
121
+ end
122
+ end
123
+
124
+ {
125
+ full_users: full,
126
+ change_users: change,
127
+ read_users: read,
128
+ }
129
+ end
130
+
131
+ action_class do
132
+ def description_exists?(resource)
133
+ !resource.description.nil?
134
+ end
135
+
136
+ def different_description?
137
+ if description_exists?(new_resource) && description_exists?(current_resource)
138
+ new_resource.description.casecmp(current_resource.description) != 0
139
+ else
140
+ description_exists?(new_resource) || description_exists?(current_resource)
141
+ end
142
+ end
143
+
144
+ def different_path?
145
+ return true if current_resource.path.nil?
146
+ win_friendly_path(new_resource.path).casecmp(win_friendly_path(current_resource.path)) != 0
147
+ end
148
+
149
+ def different_members?(permission_type)
150
+ !(current_resource.send(permission_type.to_sym) - new_resource.send(permission_type.to_sym).map(&:downcase)).empty? &&
151
+ !(new_resource.send(permission_type.to_sym).map(&:downcase) - current_resource.send(permission_type.to_sym)).empty?
152
+ end
153
+
154
+ def find_share_by_name(name)
155
+ wmi = WIN32OLE.connect('winmgmts://')
156
+ shares = wmi.ExecQuery("SELECT * FROM Win32_Share WHERE name = '#{name}'")
157
+ shares.Count == 0 ? nil : shares.ItemIndex(0)
158
+ end
159
+
160
+ def delete_share
161
+ find_share_by_name(new_resource.share_name).delete
162
+ end
163
+
164
+ def create_share
165
+ raise "#{new_resource.path} is missing or not a directory" unless ::File.directory? new_resource.path
166
+ new_share_script = <<-EOH
167
+ $share = [wmiclass]"\\\\#{ENV['COMPUTERNAME']}\\root\\CimV2:Win32_Share"
168
+ $result=$share.Create('#{new_resource.path}',
169
+ '#{new_resource.share_name}',
170
+ 0,
171
+ 16777216,
172
+ '#{new_resource.description}',
173
+ $null,
174
+ $null)
175
+ exit $result.returnValue
176
+ EOH
177
+ r = powershell_out new_share_script
178
+ message = case r.exitstatus
179
+ when 2
180
+ '2 : Access Denied'
181
+ when 8
182
+ '8 : Unknown Failure'
183
+ when 9
184
+ '9 : Invalid Name'
185
+ when 10
186
+ '10 : Invalid Level'
187
+ when 21
188
+ '21 : Invalid Parameter'
189
+ when 22
190
+ '22 : Duplicate Share'
191
+ when 23
192
+ '23 : Redirected Path'
193
+ when 24
194
+ '24 : Unknown Device or Directory'
195
+ when 25
196
+ '25 : Net Name Not Found'
197
+ else
198
+ r.exitstatus.to_s
199
+ end
200
+
201
+ raise "Could not create share. Win32_Share.create returned #{message}" if r.error?
202
+ end
203
+
204
+ # set_share_permissions - Enforce the share permissions as dictated by the resource attributes
205
+ def set_share_permissions
206
+ share_permissions_script = <<-EOH
207
+ Function New-SecurityDescriptor
208
+ {
209
+ param (
210
+ [array]$ACEs
211
+ )
212
+ #Create SeCDesc object
213
+ $SecDesc = ([WMIClass] "\\\\$env:ComputerName\\root\\cimv2:Win32_SecurityDescriptor").CreateInstance()
214
+
215
+ foreach ($ACE in $ACEs )
216
+ {
217
+ $SecDesc.DACL += $ACE.psobject.baseobject
218
+ }
219
+
220
+ #Return the security Descriptor
221
+ return $SecDesc
222
+ }
223
+
224
+ Function New-ACE
225
+ {
226
+ param (
227
+ [string] $Name,
228
+ [string] $Domain,
229
+ [string] $Permission = "Read"
230
+ )
231
+ #Create the Trusteee Object
232
+ $Trustee = ([WMIClass] "\\\\$env:computername\\root\\cimv2:Win32_Trustee").CreateInstance()
233
+ $account = get-wmiobject Win32_Account -filter "Name like '$Name' and Domain like '$Domain'"
234
+ $accountSID = [WMI] "\\\\$env:ComputerName\\root\\cimv2:Win32_SID.SID='$($account.sid)'"
235
+
236
+ $Trustee.Domain = $Domain
237
+ $Trustee.Name = $Name
238
+ $Trustee.SID = $accountSID.BinaryRepresentation
239
+
240
+ #Create ACE (Access Control List) object.
241
+ $ACE = ([WMIClass] "\\\\$env:ComputerName\\root\\cimv2:Win32_ACE").CreateInstance()
242
+ switch ($Permission)
243
+ {
244
+ "Read" { $ACE.AccessMask = 1179817 }
245
+ "Change" { $ACE.AccessMask = 1245631 }
246
+ "Full" { $ACE.AccessMask = 2032127 }
247
+ default { throw "$Permission is not a supported permission value. Possible values are 'Read','Change','Full'" }
248
+ }
249
+
250
+ $ACE.AceFlags = 3
251
+ $ACE.AceType = 0
252
+ $ACE.Trustee = $Trustee
253
+
254
+ $ACE
255
+ }
256
+
257
+ $dacl_array = @()
258
+
259
+ EOH
260
+ new_resource.full_users.each do |user|
261
+ share_permissions_script += user_to_ace(user, 'Full')
262
+ end
263
+
264
+ new_resource.change_users.each do |user|
265
+ share_permissions_script += user_to_ace(user, 'Change')
266
+ end
267
+
268
+ new_resource.read_users.each do |user|
269
+ share_permissions_script += user_to_ace(user, 'Read')
270
+ end
271
+
272
+ share_permissions_script += <<-EOH
273
+
274
+ $dacl = New-SecurityDescriptor -Aces $dacl_array
275
+
276
+ $share = get-wmiobject win32_share -filter 'Name like "#{new_resource.share_name}"'
277
+ $return = $share.SetShareInfo($null, '#{new_resource.description}', $dacl)
278
+ exit $return.returnValue
279
+ EOH
280
+ r = powershell_out(share_permissions_script)
281
+ raise "Could not set share permissions. Win32_Share.SedtShareInfo returned #{r.exitstatus}" if r.error?
282
+ end
283
+
284
+ def user_to_ace(fully_qualified_user_name, access)
285
+ domain, user = fully_qualified_user_name.split('\\')
286
+ unless domain && user
287
+ raise "Invalid user entry #{fully_qualified_user_name}. The user names must be specified as 'DOMAIN\\user'"
288
+ end
289
+ "\n$dacl_array += new-ace -Name '#{user}' -domain '#{domain}' -permission '#{access}'"
290
+ end
291
+ end