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,356 @@
1
+ #
2
+ # Author:: Doug MacEachern (<dougm@vmware.com>)
3
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
4
+ # Author:: Paul Morton (<pmorton@biaprotect.com>)
5
+ # Cookbook:: windows
6
+ # Provider:: registry
7
+ #
8
+ # Copyright:: 2010-2017, VMware, Inc.
9
+ # Copyright:: 2011-2017, Chef Software, Inc.
10
+ # Copyright:: 2011-2017, Business Intelligence Associates, Inc
11
+ #
12
+ # Licensed under the Apache License, Version 2.0 (the "License");
13
+ # you may not use this file except in compliance with the License.
14
+ # You may obtain a copy of the License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the License is distributed on an "AS IS" BASIS,
20
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ # See the License for the specific language governing permissions and
22
+ # limitations under the License.
23
+ #
24
+
25
+ if RUBY_PLATFORM =~ /mswin|mingw32|windows/
26
+ require 'win32/registry'
27
+ require_relative 'wmi_helper'
28
+ end
29
+
30
+ module Windows
31
+ module RegistryHelper
32
+ @@native_registry_constant = if ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64' ||
33
+ ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64'
34
+ 0x0100
35
+ else
36
+ 0x0200
37
+ end
38
+
39
+ def get_hive_name(path)
40
+ Chef::Log.debug('Resolving registry shortcuts to full names')
41
+
42
+ reg_path = path.split('\\')
43
+ hive_name = reg_path.shift
44
+
45
+ hkey = {
46
+ 'HKLM' => 'HKEY_LOCAL_MACHINE',
47
+ 'HKCU' => 'HKEY_CURRENT_USER',
48
+ 'HKU' => 'HKEY_USERS',
49
+ }[hive_name] || hive_name
50
+
51
+ Chef::Log.debug("Hive resolved to #{hkey}")
52
+ hkey
53
+ end
54
+
55
+ def get_hive(path)
56
+ Chef::Log.debug("Getting hive for #{path}")
57
+ reg_path = path.split('\\')
58
+ hive_name = reg_path.shift
59
+
60
+ hkey = get_hive_name(path)
61
+
62
+ hive = {
63
+ 'HKEY_LOCAL_MACHINE' => ::Win32::Registry::HKEY_LOCAL_MACHINE,
64
+ 'HKEY_USERS' => ::Win32::Registry::HKEY_USERS,
65
+ 'HKEY_CURRENT_USER' => ::Win32::Registry::HKEY_CURRENT_USER,
66
+ }[hkey]
67
+
68
+ unless hive
69
+ Chef::Application.fatal!("Unsupported registry hive '#{hive_name}'")
70
+ end
71
+
72
+ Chef::Log.debug("Registry hive resolved to #{hkey}")
73
+ hive
74
+ end
75
+
76
+ def unload_hive(path)
77
+ hive = get_hive(path)
78
+ if hive == ::Win32::Registry::HKEY_USERS
79
+ reg_path = path.split('\\')
80
+ priv = Chef::WindowsPrivileged.new
81
+ begin
82
+ priv.reg_unload_key(reg_path[1])
83
+ rescue
84
+ end
85
+ end
86
+ end
87
+
88
+ def set_value(mode, path, values, type = nil)
89
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
90
+ key_name = reg_path.join('\\')
91
+
92
+ Chef::Log.debug("Creating #{path}")
93
+
94
+ create_key(path) unless key_exists?(path, true)
95
+
96
+ hive.send(mode, key_name, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg|
97
+ changed_something = false
98
+ values.each do |k, val|
99
+ key = k.to_s # wtf. avoid "can't modify frozen string" in win32/registry.rb
100
+ cur_val = nil
101
+ begin
102
+ cur_val = reg[key]
103
+ rescue
104
+ # subkey does not exist (ok)
105
+ end
106
+
107
+ next unless cur_val != val
108
+
109
+ Chef::Log.debug("setting #{key}=#{val}")
110
+
111
+ type = :string if type.nil?
112
+
113
+ reg_type = {
114
+ binary: ::Win32::Registry::REG_BINARY,
115
+ string: ::Win32::Registry::REG_SZ,
116
+ multi_string: ::Win32::Registry::REG_MULTI_SZ,
117
+ expand_string: ::Win32::Registry::REG_EXPAND_SZ,
118
+ dword: ::Win32::Registry::REG_DWORD,
119
+ dword_big_endian: ::Win32::Registry::REG_DWORD_BIG_ENDIAN,
120
+ qword: ::Win32::Registry::REG_QWORD,
121
+ }[type]
122
+
123
+ reg.write(key, reg_type, val)
124
+
125
+ ensure_hive_unloaded(hive_loaded)
126
+
127
+ changed_something = true
128
+ end
129
+ return changed_something
130
+ end
131
+ false
132
+ end
133
+
134
+ def get_value(path, value)
135
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
136
+ key = reg_path.join('\\')
137
+
138
+ hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg|
139
+ begin
140
+ return reg[value]
141
+ rescue
142
+ return nil
143
+ ensure
144
+ ensure_hive_unloaded(hive_loaded)
145
+ end
146
+ end
147
+ end
148
+
149
+ def get_values(path)
150
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
151
+ key = reg_path.join('\\')
152
+ hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg|
153
+ values = []
154
+ begin
155
+ reg.each_value do |name, type, data|
156
+ values << [name, type, data]
157
+ end
158
+ rescue
159
+ ensure
160
+ ensure_hive_unloaded(hive_loaded)
161
+ end
162
+ values
163
+ end
164
+ end
165
+
166
+ def delete_value(path, values)
167
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
168
+ key = reg_path.join('\\')
169
+ Chef::Log.debug("Deleting values in #{path}")
170
+ hive.open(key, ::Win32::Registry::KEY_ALL_ACCESS | @@native_registry_constant) do |reg|
171
+ values.each_key do |key|
172
+ name = key.to_s
173
+ # Ensure delete operation is idempotent.
174
+ if value_exists?(path, key)
175
+ Chef::Log.debug("Deleting value #{name} in #{path}")
176
+ reg.delete_value(name)
177
+ else
178
+ Chef::Log.debug("Value #{name} in #{path} does not exist, skipping.")
179
+ end
180
+ end
181
+ end
182
+ end
183
+
184
+ def create_key(path)
185
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
186
+ key = reg_path.join('\\')
187
+ Chef::Log.debug("Creating registry key #{path}")
188
+ hive.create(key)
189
+ end
190
+
191
+ def value_exists?(path, value)
192
+ if key_exists?(path, true)
193
+
194
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
195
+ key = reg_path.join('\\')
196
+
197
+ Chef::Log.debug("Attempting to open #{key}")
198
+ Chef::Log.debug("Native Constant #{@@native_registry_constant}")
199
+ Chef::Log.debug("Hive #{hive}")
200
+
201
+ hive.open(key, ::Win32::Registry::KEY_READ | @@native_registry_constant) do |reg|
202
+ begin
203
+ rtn_value = reg[value]
204
+ return true
205
+ rescue
206
+ return false
207
+ ensure
208
+ ensure_hive_unloaded(hive_loaded)
209
+ end
210
+ end
211
+
212
+ end
213
+ false
214
+ end
215
+
216
+ # TODO: Does not load user registry...
217
+ def key_exists?(path, load_hive = false)
218
+ if load_hive
219
+ hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
220
+ key = reg_path.join('\\')
221
+ else
222
+ hive = get_hive(path)
223
+ reg_path = path.split('\\')
224
+ hive_name = reg_path.shift
225
+ root_key = reg_path[0]
226
+ key = reg_path.join('\\')
227
+ hive_loaded = false
228
+ end
229
+
230
+ begin
231
+ hive.open(key, ::Win32::Registry::Constants::KEY_READ | @@native_registry_constant)
232
+ return true
233
+ rescue
234
+ return false
235
+ ensure
236
+ ensure_hive_unloaded(hive_loaded)
237
+ end
238
+ end
239
+
240
+ def get_user_hive_location(sid)
241
+ reg_key = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\#{sid}"
242
+ Chef::Log.debug("Looking for profile at #{reg_key}")
243
+ if key_exists?(reg_key)
244
+ return get_value(reg_key, 'ProfileImagePath')
245
+ else
246
+ return nil
247
+ end
248
+ end
249
+
250
+ def resolve_user_to_sid(username)
251
+ user_query = execute_wmi_query("select * from Win32_UserAccount where Name='#{username}'")
252
+ sid = nil
253
+
254
+ user_query.each do |user|
255
+ sid = wmi_object_property(user, 'sid')
256
+ break
257
+ end
258
+
259
+ Chef::Log.debug("Resolved user SID to #{sid}")
260
+ return sid
261
+ rescue
262
+ return nil
263
+ end
264
+
265
+ def hive_loaded?(path)
266
+ hive = get_hive(path)
267
+ reg_path = path.split('\\')
268
+ hive_name = reg_path.shift
269
+ user_hive = path[0]
270
+
271
+ if user_hive?(hive)
272
+ return key_exists?("#{hive_name}\\#{user_hive}")
273
+ else
274
+ return true
275
+ end
276
+ end
277
+
278
+ def user_hive?(hive)
279
+ hive == ::Win32::Registry::HKEY_USERS
280
+ end
281
+
282
+ def get_reg_path_info(path)
283
+ hive = get_hive(path)
284
+ reg_path = path.split('\\')
285
+ hive_name = reg_path.shift
286
+ root_key = reg_path[0]
287
+ hive_loaded = false
288
+
289
+ if user_hive?(hive) && !key_exists?("#{hive_name}\\#{root_key}")
290
+ reg_path, hive_loaded = load_user_hive(hive, reg_path, root_key)
291
+ root_key = reg_path[0]
292
+ Chef::Log.debug("Resolved user (#{path}) to (#{reg_path.join('/')})")
293
+ end
294
+
295
+ [hive, reg_path, hive_name, root_key, hive_loaded]
296
+ end
297
+
298
+ def load_user_hive(hive, reg_path, user_hive)
299
+ Chef::Log.debug("Reg Path #{reg_path}")
300
+ # See if the hive is loaded. Logged in users will have a key that is named their SID
301
+ # if the user has specified the a path by SID and the user is logged in, this function
302
+ # should not be executed.
303
+ if user_hive?(hive) && !key_exists?("HKU\\#{user_hive}")
304
+ Chef::Log.debug('The user is not logged in and has not been specified by SID')
305
+ sid = resolve_user_to_sid(user_hive)
306
+ Chef::Log.debug("User SID resolved to (#{sid})")
307
+ # Now that the user has been resolved to a SID, check and see if the hive exists.
308
+ # If this exists by SID, the user is logged in and we should use that key.
309
+ # TODO: Replace the username with the sid and send it back because the username
310
+ # does not exist as the key location.
311
+ load_reg = false
312
+ if key_exists?("HKU\\#{sid}")
313
+ reg_path[0] = sid # use the active profile (user is logged on)
314
+ Chef::Log.debug("HKEY_USERS Mapped: #{user_hive} -> #{sid}")
315
+ else
316
+ Chef::Log.debug('User is not logged in')
317
+ load_reg = true
318
+ end
319
+
320
+ # The user is not logged in, so we should load the registry from disk
321
+ if load_reg
322
+ profile_path = get_user_hive_location(sid)
323
+ unless profile_path.nil?
324
+ ntuser_dat = "#{profile_path}\\NTUSER.DAT"
325
+ if ::File.exist?(ntuser_dat)
326
+ priv = Chef::WindowsPrivileged.new
327
+ if priv.reg_load_key(sid, ntuser_dat)
328
+ Chef::Log.debug("RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})")
329
+ reg_path[0] = sid
330
+ else
331
+ Chef::Log.debug("Failed RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})")
332
+ end
333
+ end
334
+ end
335
+ end
336
+ end
337
+
338
+ [reg_path, load_reg]
339
+ end
340
+
341
+ private
342
+
343
+ def ensure_hive_unloaded(hive_loaded = false)
344
+ if hive_loaded
345
+ Chef::Log.debug('Hive was loaded, we really should unload it')
346
+ unload_hive(path)
347
+ end
348
+ end
349
+ end
350
+ end
351
+
352
+ module Registry
353
+ module_function
354
+
355
+ extend Windows::RegistryHelper
356
+ end
@@ -0,0 +1,207 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Cookbook:: windows
4
+ # Library:: version
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
+ if RUBY_PLATFORM =~ /mswin|mingw32|windows/
22
+ require_relative 'wmi_helper'
23
+ require 'Win32API'
24
+ end
25
+
26
+ module Windows
27
+ class Version
28
+ # http://msdn.microsoft.com/en-us/library/ms724833(v=vs.85).aspx
29
+
30
+ # Suite Masks
31
+ # Microsoft BackOffice components are installed.
32
+ VER_SUITE_BACKOFFICE = 0x00000004 unless defined?(VER_SUITE_BACKOFFICE)
33
+ # Windows Server 2003, Web Edition is installed.
34
+ VER_SUITE_BLADE = 0x00000400 unless defined?(VER_SUITE_BLADE)
35
+ # Windows Server 2003, Compute Cluster Edition is installed.
36
+ VER_SUITE_COMPUTE_SERVER = 0x00004000 unless defined?(VER_SUITE_COMPUTE_SERVER)
37
+ # Windows Server 2008 Datacenter, Windows Server 2003, Datacenter Edition, or Windows 2000 Datacenter Server is installed.
38
+ VER_SUITE_DATACENTER = 0x00000080 unless defined?(VER_SUITE_DATACENTER)
39
+ # Windows Server 2008 Enterprise, Windows Server 2003, Enterprise Edition, or Windows 2000 Advanced Server is installed. Refer to the Remarks section for more information about this bit flag.
40
+ VER_SUITE_ENTERPRISE = 0x00000002 unless defined?(VER_SUITE_ENTERPRISE)
41
+ # Windows XP Embedded is installed.
42
+ VER_SUITE_EMBEDDEDNT = 0x00000040 unless defined?(VER_SUITE_EMBEDDEDNT)
43
+ # Windows Vista Home Premium, Windows Vista Home Basic, or Windows XP Home Edition is installed.
44
+ VER_SUITE_PERSONAL = 0x00000200 unless defined?(VER_SUITE_PERSONAL)
45
+ # Remote Desktop is supported, but only one interactive session is supported. This value is set unless the system is running in application server mode.
46
+ VER_SUITE_SINGLEUSERTS = 0x00000100 unless defined?(VER_SUITE_SINGLEUSERTS)
47
+ # Microsoft Small Business Server was once installed on the system, but may have been upgraded to another version of Windows. Refer to the Remarks section for more information about this bit flag.
48
+ VER_SUITE_SMALLBUSINESS = 0x00000001 unless defined?(VER_SUITE_SMALLBUSINESS)
49
+ # Microsoft Small Business Server is installed with the restrictive client license in force. Refer to the Remarks section for more information about this bit flag.
50
+ VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x00000020 unless defined?(VER_SUITE_SMALLBUSINESS_RESTRICTED)
51
+ # Windows Storage Server 2003 R2 or Windows Storage Server 2003is installed.
52
+ VER_SUITE_STORAGE_SERVER = 0x00002000 unless defined?(VER_SUITE_STORAGE_SERVER)
53
+ # Terminal Services is installed. This value is always set.
54
+ # If VER_SUITE_TERMINAL is set but VER_SUITE_SINGLEUSERTS is not set, the system is running in application server mode.
55
+ VER_SUITE_TERMINAL = 0x00000010 unless defined?(VER_SUITE_TERMINAL)
56
+ # Windows Home Server is installed.
57
+ VER_SUITE_WH_SERVER = 0x00008000 unless defined?(VER_SUITE_WH_SERVER)
58
+
59
+ # Product Type
60
+ # The system is a domain controller and the operating system is Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
61
+ VER_NT_DOMAIN_CONTROLLER = 0x0000002 unless defined?(VER_NT_DOMAIN_CONTROLLER)
62
+ # The operating system is Windows Server 2012, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
63
+ # Note that a server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER.
64
+ VER_NT_SERVER = 0x0000003 unless defined?(VER_NT_SERVER)
65
+ # The operating system is Windows 7, Windows Vista, Windows XP Professional, Windows XP Home Edition, or Windows 2000 Professional.
66
+ VER_NT_WORKSTATION = 0x0000001 unless defined?(VER_NT_WORKSTATION)
67
+
68
+ # GetSystemMetrics
69
+ # The build number if the system is Windows Server 2003 R2; otherwise, 0.
70
+ SM_SERVERR2 = 89 unless defined?(SM_SERVERR2)
71
+
72
+ # http://msdn.microsoft.com/en-us/library/ms724358(v=vs.85).aspx
73
+ SKU = {
74
+ 0x00000006 => { ms_const: 'PRODUCT_BUSINESS', name: 'Business' },
75
+ 0x00000010 => { ms_const: 'PRODUCT_BUSINESS_N', name: 'Business N' },
76
+ 0x00000012 => { ms_const: 'PRODUCT_CLUSTER_SERVER', name: 'HPC Edition' },
77
+ 0x00000008 => { ms_const: 'PRODUCT_DATACENTER_SERVER', name: 'Server Datacenter (full installation)' },
78
+ 0x0000000C => { ms_const: 'PRODUCT_DATACENTER_SERVER_CORE', name: 'Server Datacenter (core installation)' },
79
+ 0x00000027 => { ms_const: 'PRODUCT_DATACENTER_SERVER_CORE_V', name: 'Server Datacenter without Hyper-V (core installation)' },
80
+ 0x00000025 => { ms_const: 'PRODUCT_DATACENTER_SERVER_V', name: 'Server Datacenter without Hyper-V (full installation)' },
81
+ 0x00000004 => { ms_const: 'PRODUCT_ENTERPRISE', name: 'Enterprise' },
82
+ 0x00000046 => { ms_const: 'PRODUCT_ENTERPRISE_E', name: 'Not supported' },
83
+ 0x0000001B => { ms_const: 'PRODUCT_ENTERPRISE_N', name: 'Enterprise N' },
84
+ 0x0000000A => { ms_const: 'PRODUCT_ENTERPRISE_SERVER', name: 'Server Enterprise (full installation)' },
85
+ 0x0000000E => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_CORE', name: 'Server Enterprise (core installation)' },
86
+ 0x00000029 => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_CORE_V', name: 'Server Enterprise without Hyper-V (core installation)' },
87
+ 0x0000000F => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_IA64', name: 'Server Enterprise for Itanium-based Systems' },
88
+ 0x00000026 => { ms_const: 'PRODUCT_ENTERPRISE_SERVER_V', name: 'Server Enterprise without Hyper-V (full installation)' },
89
+ 0x00000002 => { ms_const: 'PRODUCT_HOME_BASIC', name: 'Home Basic' },
90
+ 0x00000043 => { ms_const: 'PRODUCT_HOME_BASIC_E', name: 'Not supported' },
91
+ 0x00000005 => { ms_const: 'PRODUCT_HOME_BASIC_N', name: 'Home Basic N' },
92
+ 0x00000003 => { ms_const: 'PRODUCT_HOME_PREMIUM', name: 'Home Premium' },
93
+ 0x00000044 => { ms_const: 'PRODUCT_HOME_PREMIUM_E', name: 'Not supported' },
94
+ 0x0000001A => { ms_const: 'PRODUCT_HOME_PREMIUM_N', name: 'Home Premium N' },
95
+ 0x0000002A => { ms_const: 'PRODUCT_HYPERV', name: 'Microsoft Hyper-V Server' },
96
+ 0x0000001E => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT', name: 'Windows Essential Business Server Management Server' },
97
+ 0x00000020 => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING', name: 'Windows Essential Business Server Messaging Server' },
98
+ 0x0000001F => { ms_const: 'PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY', name: 'Windows Essential Business Server Security Server' },
99
+ 0x00000030 => { ms_const: 'PRODUCT_PROFESSIONAL', name: 'Professional' },
100
+ 0x00000045 => { ms_const: 'PRODUCT_PROFESSIONAL_E', name: 'Not supported' },
101
+ 0x00000031 => { ms_const: 'PRODUCT_PROFESSIONAL_N', name: 'Professional N' },
102
+ 0x00000067 => { ms_const: 'PRODUCT_PROFESSIONAL_WMC', name: 'Professional with Media Center' },
103
+ 0x00000018 => { ms_const: 'PRODUCT_SERVER_FOR_SMALLBUSINESS', name: 'Windows Server 2008 for Windows Essential Server Solutions' },
104
+ 0x00000023 => { ms_const: 'PRODUCT_SERVER_FOR_SMALLBUSINESS_V', name: 'Windows Server 2008 without Hyper-V for Windows Essential Server Solutions' },
105
+ 0x00000021 => { ms_const: 'PRODUCT_SERVER_FOUNDATION', name: 'Server Foundation' },
106
+ 0x00000022 => { ms_const: 'PRODUCT_HOME_PREMIUM_SERVER', name: 'Windows Home Server 2011' },
107
+ 0x00000032 => { ms_const: 'PRODUCT_SB_SOLUTION_SERVER', name: 'Windows Small Business Server 2011 Essentials' },
108
+ 0x00000013 => { ms_const: 'PRODUCT_HOME_SERVER', name: 'Windows Storage Server 2008 R2 Essentials' },
109
+ 0x00000009 => { ms_const: 'PRODUCT_SMALLBUSINESS_SERVER', name: 'Windows Small Business Server' },
110
+ 0x00000038 => { ms_const: 'PRODUCT_SOLUTION_EMBEDDEDSERVER', name: 'Windows MultiPoint Server' },
111
+ 0x00000007 => { ms_const: 'PRODUCT_STANDARD_SERVER', name: 'Server Standard (full installation)' },
112
+ 0x0000000D => { ms_const: 'PRODUCT_STANDARD_SERVER_CORE', name: 'Server Standard (core installation)' },
113
+ 0x00000028 => { ms_const: 'PRODUCT_STANDARD_SERVER_CORE_V', name: 'Server Standard without Hyper-V (core installation)' },
114
+ 0x00000024 => { ms_const: 'PRODUCT_STANDARD_SERVER_V', name: 'Server Standard without Hyper-V (full installation)' },
115
+ 0x0000000B => { ms_const: 'PRODUCT_STARTER', name: 'Starter' },
116
+ 0x00000042 => { ms_const: 'PRODUCT_STARTER_E', name: 'Not supported' },
117
+ 0x0000002F => { ms_const: 'PRODUCT_STARTER_N', name: 'Starter N' },
118
+ 0x00000017 => { ms_const: 'PRODUCT_STORAGE_ENTERPRISE_SERVER', name: 'Storage Server Enterprise' },
119
+ 0x00000014 => { ms_const: 'PRODUCT_STORAGE_EXPRESS_SERVER', name: 'Storage Server Express' },
120
+ 0x00000015 => { ms_const: 'PRODUCT_STORAGE_STANDARD_SERVER', name: 'Storage Server Standard' },
121
+ 0x00000016 => { ms_const: 'PRODUCT_STORAGE_WORKGROUP_SERVER', name: 'Storage Server Workgroup' },
122
+ 0x00000000 => { ms_const: 'PRODUCT_UNDEFINED', name: 'An unknown product' },
123
+ 0x00000001 => { ms_const: 'PRODUCT_ULTIMATE', name: 'Ultimate' },
124
+ 0x00000047 => { ms_const: 'PRODUCT_ULTIMATE_E', name: 'Not supported' },
125
+ 0x0000001C => { ms_const: 'PRODUCT_ULTIMATE_N', name: 'Ultimate N' },
126
+ 0x00000011 => { ms_const: 'PRODUCT_WEB_SERVER', name: 'Web Server (full installation)' },
127
+ 0x0000001D => { ms_const: 'PRODUCT_WEB_SERVER_CORE', name: 'Web Server (core installation)' },
128
+ }.freeze unless defined?(SKU)
129
+
130
+ attr_reader :major_version, :minor_version, :build_number, :service_pack_major_version, :service_pack_minor_version
131
+ attr_reader :version, :product_type, :product_suite, :sku
132
+
133
+ def initialize
134
+ unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
135
+ raise NotImplementedError, 'only valid on Windows platform'
136
+ end
137
+ @version, @product_type, @product_suite, @sku, @service_pack_major_version, @service_pack_minor_version = get_os_info
138
+ @major_version, @minor_version, @build_number = version.split('.').map(&:to_i)
139
+ end
140
+
141
+ WIN_VERSIONS = {
142
+ 'Windows Server 2012 R2' => { major: 6, minor: 3, callable: -> { @product_type != VER_NT_WORKSTATION } },
143
+ 'Windows 8' => { major: 6, minor: 2, callable: -> { @product_type == VER_NT_WORKSTATION } },
144
+ 'Windows Server 2012' => { major: 6, minor: 2, callable: -> { @product_type != VER_NT_WORKSTATION } },
145
+ 'Windows 7' => { major: 6, minor: 1, callable: -> { @product_type == VER_NT_WORKSTATION } },
146
+ 'Windows Server 2008 R2' => { major: 6, minor: 1, callable: -> { @product_type != VER_NT_WORKSTATION } },
147
+ 'Windows Server 2008' => { major: 6, minor: 0, callable: -> { @product_type != VER_NT_WORKSTATION } },
148
+ 'Windows Vista' => { major: 6, minor: 0, callable: -> { @product_type == VER_NT_WORKSTATION } },
149
+ 'Windows Server 2003 R2' => { major: 5, minor: 2, callable: -> { Win32API.new('user32', 'GetSystemMetrics', 'I', 'I').call(SM_SERVERR2) != 0 } },
150
+ 'Windows Home Server' => { major: 5, minor: 2, callable: -> { (@product_suite & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } },
151
+ 'Windows Server 2003' => { major: 5, minor: 2, callable: -> { Win32API.new('user32', 'GetSystemMetrics', 'I', 'I').call(SM_SERVERR2) == 0 } },
152
+ 'Windows XP' => { major: 5, minor: 1 },
153
+ 'Windows 2000' => { major: 5, minor: 0 },
154
+ }.freeze unless defined?(WIN_VERSIONS)
155
+
156
+ marketing_names = []
157
+
158
+ # General Windows checks
159
+ WIN_VERSIONS.each do |k, v|
160
+ method_name = "#{k.gsub(/\s/, '_').downcase}?"
161
+ define_method(method_name) do
162
+ (@major_version == v[:major]) &&
163
+ (@minor_version == v[:minor]) &&
164
+ (v[:callable] ? v[:callable].call : true)
165
+ end
166
+ marketing_names << [k, method_name]
167
+ end
168
+
169
+ define_method(:marketing_name) do
170
+ marketing_names.each do |mn|
171
+ break mn[0] if send(mn[1])
172
+ end
173
+ end
174
+
175
+ # Server Type checks
176
+ %w( core full datacenter ).each do |m|
177
+ define_method("server_#{m}?") do
178
+ if @sku
179
+ !(SKU[@sku][:name] =~ /#{m}/i).nil?
180
+ else
181
+ false
182
+ end
183
+ end
184
+ end
185
+
186
+ private
187
+
188
+ # Win32API call to GetSystemMetrics(SM_SERVERR2)
189
+ # returns: The build number if the system is Windows Server 2003 R2; otherwise, 0.
190
+ def sm_serverr2
191
+ @sm_serverr2 ||= Win32API.new('user32', 'GetSystemMetrics', 'I', 'I').call(SM_SERVERR2)
192
+ end
193
+
194
+ # query WMI Win32_OperatingSystem for required OS info
195
+ def get_os_info
196
+ cols = %w( Version ProductType OSProductSuite OperatingSystemSKU ServicePackMajorVersion ServicePackMinorVersion )
197
+ os_info = execute_wmi_query('select * from Win32_OperatingSystem').each.next
198
+ cols.map do |c|
199
+ begin
200
+ wmi_object_property(os_info, c)
201
+ rescue # OperatingSystemSKU doesn't exist in all versions of Windows
202
+ nil
203
+ end
204
+ end
205
+ end
206
+ end
207
+ end
@@ -0,0 +1,79 @@
1
+ #
2
+ # Cookbook:: windows
3
+ # Library:: version_helper
4
+ # Author:: Baptiste Courtois (<b.courtois@criteo.com>)
5
+ #
6
+ # Copyright:: 2015-2017, Criteo
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
+ module Windows
21
+ # Module based on windows ohai kernel.cs_info providing version helpers
22
+ module VersionHelper
23
+ # Module referencing CORE SKU contants from product type
24
+ # see. https://msdn.microsoft.com/windows/desktop/ms724358#PRODUCT_DATACENTER_SERVER_CORE
25
+ # n.b. Prefix - PRODUCT_ - and suffix - _CORE- have been removed
26
+ module CoreSKU
27
+ # Server Datacenter Core
28
+ DATACENTER_SERVER = 0x0C unless constants.include?(:DATACENTER_SERVER)
29
+ # Server Datacenter without Hyper-V Core
30
+ DATACENTER_SERVER_V = 0x27 unless constants.include?(:DATACENTER_SERVER_V)
31
+ # Server Enterprise Core
32
+ ENTERPRISE_SERVER = 0x0E unless constants.include?(:ENTERPRISE_SERVER)
33
+ # Server Enterprise without Hyper-V Core
34
+ ENTERPRISE_SERVER_V = 0x29 unless constants.include?(:ENTERPRISE_SERVER_V)
35
+ # Server Standard Core
36
+ STANDARD_SERVER = 0x0D unless constants.include?(:STANDARD_SERVER)
37
+ # Server Standard without Hyper-V Core
38
+ STANDARD_SERVER_V = 0x28 unless constants.include?(:STANDARD_SERVER_V)
39
+ end
40
+
41
+ # Module referencing product type contants
42
+ # see. https://msdn.microsoft.com/windows/desktop/ms724833#VER_NT_SERVER
43
+ # n.b. Prefix - VER_NT_ - has been removed
44
+ module ProductType
45
+ WORKSTATION = 0x1 unless constants.include?(:WORKSTATION)
46
+ DOMAIN_CONTROLLER = 0x2 unless constants.include?(:DOMAIN_CONTROLLER)
47
+ SERVER = 0x3 unless constants.include?(:SERVER)
48
+ end
49
+
50
+ # Determines whether current node is running a windows Core version
51
+ def self.core_version?(node)
52
+ validate_platform node
53
+
54
+ CoreSKU.constants.any? { |c| CoreSKU.const_get(c) == node['kernel']['os_info']['operating_system_sku'] }
55
+ end
56
+
57
+ # Determines whether current node is a workstation version
58
+ def self.workstation_version?(node)
59
+ validate_platform node
60
+ node['kernel']['os_info']['product_type'] == ProductType::WORKSTATION
61
+ end
62
+
63
+ # Determines whether current node is a server version
64
+ def self.server_version?(node)
65
+ !workstation_version?(node)
66
+ end
67
+
68
+ # Determines NT version of the current node
69
+ def self.nt_version(node)
70
+ validate_platform node
71
+
72
+ node['platform_version'].to_f
73
+ end
74
+
75
+ def self.validate_platform(node)
76
+ raise 'Windows helper are only supported on windows platform!' if node['platform'] != 'windows'
77
+ end
78
+ end
79
+ end