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,83 @@
1
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh']['repositoryid'] = 'centos-sclo-rh'
2
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh']['description'] =
3
+ "CentOS-#{node['platform_version'].to_i} - SCLo rh"
4
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh']['baseurl'] =
5
+ "http://mirror.centos.org/centos/#{node['platform_version'].to_i}/sclo/$basearch/rh/"
6
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh']['gpgcheck'] = true
7
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
8
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh']['enabled'] = true
9
+
10
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-testing']['repositoryid'] = 'centos-sclo-rh-testing'
11
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-testing']['description'] =
12
+ "CentOS-#{node['platform_version'].to_i} - SCLo rh Testing"
13
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-testing']['baseurl'] =
14
+ "http://buildlogs.centos.org/centos/#{node['platform_version'].to_i}/sclo/$basearch/rh/"
15
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-testing']['gpgcheck'] = false
16
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-testing']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
17
+
18
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-testing']['enabled'] =
19
+ default['yum-scl']['enable_testing']
20
+
21
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-source']['repositoryid'] = 'centos-sclo-rh-source'
22
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-source']['description'] =
23
+ "CentOS-#{node['platform_version'].to_i} - SCLo rh Sources"
24
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-source']['baseurl'] =
25
+ "http://buildlogs.centos.org/centos/#{node['platform_version'].to_i}/sclo/Source/rh/"
26
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-source']['gpgcheck'] = true
27
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-source']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
28
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-source']['enabled'] =
29
+ default['yum-scl']['enable_source']
30
+
31
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-debuginfo']['repositoryid'] =
32
+ 'centos-sclo-rh-debuginfo'
33
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-debuginfo']['description'] =
34
+ "CentOS-#{node['platform_version'].to_i} - SCLo rh Debuginfo"
35
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-debuginfo']['baseurl'] =
36
+ "http://buildlogs.centos.org/centos/#{node['platform_version'].to_i}/sclo/Source/rh/"
37
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-debuginfo']['gpgcheck'] = true
38
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-debuginfo']['gpgkey'] =
39
+ 'RPM-GPG-KEY-CentOS-SIG-SCLo'
40
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-rh-debuginfo']['enabled'] =
41
+ default['yum-scl']['enable_debuginfo']
42
+
43
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo']['repositoryid'] = 'centos-sclo-sclo'
44
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo']['description'] =
45
+ "CentOS-#{node['platform_version'].to_i} - SCLo"
46
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo']['baseurl'] =
47
+ "http://mirror.centos.org/centos/#{node['platform_version'].to_i}/sclo/$basearch/sclo/"
48
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo']['gpgcheck'] = true
49
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
50
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo']['enabled'] = true
51
+
52
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-testing']['repositoryid'] = 'centos-sclo-sclo-testing'
53
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-testing']['description'] =
54
+ "CentOS-#{node['platform_version'].to_i} - SCLo Testing"
55
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-testing']['baseurl'] =
56
+ "http://mirror.centos.org/centos/#{node['platform_version'].to_i}/sclo/$basearch/sclo/"
57
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-testing']['gpgcheck'] = false
58
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-testing']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
59
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-testing']['enabled'] =
60
+ default['yum-scl']['enable_testing']
61
+
62
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-source']['repositoryid'] = 'centos-sclo-sclo-source'
63
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-source']['description'] =
64
+ "CentOS-#{node['platform_version'].to_i} - SCLo Sources"
65
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-source']['baseurl'] =
66
+ "http://mirror.centos.org/centos/#{node['platform_version'].to_i}/sclo/$basearch/sclo/"
67
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-source']['gpgcheck'] = true
68
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-source']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
69
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-source']['enabled'] =
70
+ default['yum-scl']['enable_source']
71
+
72
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-debuginfo']['repositoryid'] =
73
+ 'centos-sclo-sclo-debuginfo'
74
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-debuginfo']['description'] =
75
+ "CentOS-#{node['platform_version'].to_i} - SCLo Debuginfo"
76
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-debuginfo']['baseurl'] =
77
+ "http://mirror.centos.org/centos/#{node['platform_version'].to_i}/sclo/$basearch/sclo/"
78
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-debuginfo']['gpgcheck'] = true
79
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-debuginfo']['gpgkey'] = 'RPM-GPG-KEY-CentOS-SIG-SCLo'
80
+ default['yum-scl']['repos']['centos']['>=6.0']['centos-sclo-sclo-debuginfo']['enabled'] =
81
+ default['yum-scl']['enable_debuginfo']
82
+
83
+ default['yum-scl']['repos']['centos']['default'] = nil
@@ -0,0 +1,15 @@
1
+ default['yum-scl']['prefer_os_package'] = true
2
+
3
+ default['yum-scl']['enable_testing'] = false
4
+ default['yum-scl']['enable_source'] = false
5
+ default['yum-scl']['enable_debuginfo'] = false
6
+
7
+ default['yum-scl']['native_packages'] = value_for_platform(
8
+ centos: {
9
+ '>= 6.0' => %w(centos-release-scl-rh centos-release-scl),
10
+ 'default' => nil
11
+ },
12
+ default: nil
13
+ )
14
+
15
+ default['yum-scl']['repos']['default'] = nil
@@ -0,0 +1 @@
1
+ default['yum-scl']['repos']['scientific'] = default['yum-scl']['repos']['centos']
@@ -0,0 +1,20 @@
1
+ -----BEGIN PGP PUBLIC KEY BLOCK-----
2
+ Version: GnuPG v2.0.22 (GNU/Linux)
3
+
4
+ mQENBFYM/AoBCADR9Q5cb+H5ndx+QkzNBQ88wcD+g112yvnHNlSiBMOnNEGHuKPJ
5
+ tujZ+eWXP3K6ucJckT91WxfQ2fxPr9jQ0xpZytcHcZdTfn3vKL9+OwR0npp+qmcz
6
+ rK8/EzVz/SWSgBQ5xT/HUvaeoVAbzBHSng0r2njnBAqABKAoTxgyRGKSCWduKD32
7
+ 7PF2ZpqeDFFhd99Ykt6ar8SlV8ToqH6F7An0ILeejINVbHUxd6+wsbpcOwQ4mGAa
8
+ /CPXeqqLGj62ASBv36xQr34hlN/9zQMViaKkacl8zkuvwhuHf4b4VlGVCe6VILpQ
9
+ 8ytKMV/lcg7YpMfRq4KVWBjCwkvk6zg6KxaHABEBAAG0aENlbnRPUyBTb2Z0d2Fy
10
+ ZUNvbGxlY3Rpb25zIFNJRyAoaHR0cHM6Ly93aWtpLmNlbnRvcy5vcmcvU3BlY2lh
11
+ bEludGVyZXN0R3JvdXAvU0NMbykgPHNlY3VyaXR5QGNlbnRvcy5vcmc+iQE5BBMB
12
+ AgAjBQJWDPwKAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQTrhOcfLu
13
+ nVXNewgAg7RVclomjTY4w80XiztUuUaFlCHyR76KazdaGfx/8XckWH2GdQtwii+3
14
+ Tg7+PT2H0Xyuj1aod+jVTPXTPVUr+rEHAjuNDY+xyAJrNljoOHiz111zs9pk7PLX
15
+ CPwKWQLnmrcKIi8v/51L79FFsUMvhClTBdLUQ51lkCwbcXQi+bOhPvZTVbRhjoB/
16
+ a9z0d8t65X16zEzE7fBhnVoj4xye/MPMbTH41Mv+FWVciBTuAepOLmgJ9oxODliv
17
+ rgZa28IEWkvHQ8m9GLJ0y9mI6olh0cGFybnd5y4Ss1cMttlRGR4qthLhN2gHZpO9
18
+ 2y4WgkeVXCj1BK1fzVrDMLPbuNNCZQ==
19
+ =UtPD
20
+ -----END PGP PUBLIC KEY BLOCK-----
@@ -0,0 +1,33 @@
1
+ # YumSCL is a module containing yum-softwarecollections cookbook helper
2
+ module YumSCL
3
+ # Helper module for yum-softwarecollections cookbook
4
+ module Helper
5
+ def yum_scl_use_os_native_package?(prefer_os, packages_list)
6
+ return false unless prefer_os
7
+ if packages_list.nil?
8
+ Chef::Log.warn 'prefer_os_package detected, but no softwarecollections'\
9
+ " package available on #{node['platform']}-"\
10
+ "#{node['platform_version']}. Fall back to use attribute"\
11
+ ' specified repositories.'
12
+ return false
13
+ end
14
+ true
15
+ end
16
+
17
+ def yum_scl_enable_repo(repository_name, enabled)
18
+ shell_out!('yum-config-manager', enabled ? '--enable' : '--disable', repository_name)
19
+ end
20
+
21
+ def yum_scl_package_repo_files(package_name)
22
+ yum_scl_package_files(package_name, %r{^/etc/yum.repos.d/.+.repo$})
23
+ end
24
+
25
+ def yum_scl_package_files(package_name, file_mask = /.*/)
26
+ matched_files = []
27
+ shell_out!('rpm', '-q', '-l', package_name).stdout.chomp.split("\n").each do |package_file|
28
+ matched_files.push(package_file) if file_mask.match(package_file)
29
+ end
30
+ matched_files
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "yum-scl",
3
+ "description": "Installs/Configures softwarecollections repositories",
4
+ "long_description": "# yum-scl Cookbook\n\nConfigures softwarecollections yum repository\n\n## Requirements\n\n### Platforms\n\n- Scientific Linux 6.0 or later\n- CentoOS Linux 6.0 or later\n\n### Chef\n\n- Chef 12.0 or later\n\n## Attributes\n\n- default['yum-scl']['prefer_os_package'] - configure repository using package provided by OS (if available)\n- default['yum-scl']['enable_testing'] = false - enable testing repositories of softwarecollections\n- default['yum-scl']['enable_source'] = false - enable source repositories of softwarecollections\n- default['yum-scl']['enable_debuginfo'] = false - enable debuginfo repositories of softwarecollections\n\n## Recipes\n\n### yum-scl::default\n\nThe default recipe tries to install package for softwarecollection repositories provided by OS then falls to \ninstallation using yum_repository resource\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[yum-scl]\"\n ]\n}\n```\n\n### yum-scl::native_install\n\nThe recipe installs package for softwarecollection repositories provided by OS\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[yum-scl::native_install]\"\n ]\n}\n```\n\n### yum-scl::chef_install\n\nThe recipe adds yum repositories using chef yum_repository resource\n\n```json\n{\n \"name\":\"my_node\",\n \"run_list\": [\n \"recipe[yum-scl::chef_install]\"\n ]\n}\n```\n\n## Contributing\n\n1. Fork the repository on Github\n2. Create a named feature branch (like `add_component_x`)\n3. Write your change\n4. Write tests for your change (if applicable)\n5. Run the tests, ensuring they all pass\n6. Submit a Pull Request using Github\n\n## License and Authors\n\nAuthors: Dmitry Shestoperov\n",
5
+ "maintainer": "Dmitry Shestoperov",
6
+ "maintainer_email": "dmitry@shestoperov.info",
7
+ "license": "All rights reserved",
8
+ "platforms": {
9
+
10
+ },
11
+ "dependencies": {
12
+ "yum": ">= 0.0.0",
13
+ "inifile_chef_gem": ">= 0.0.0"
14
+ },
15
+ "recommendations": {
16
+
17
+ },
18
+ "suggestions": {
19
+
20
+ },
21
+ "conflicting": {
22
+
23
+ },
24
+ "providing": {
25
+
26
+ },
27
+ "replacing": {
28
+
29
+ },
30
+ "attributes": {
31
+
32
+ },
33
+ "groupings": {
34
+
35
+ },
36
+ "recipes": {
37
+
38
+ },
39
+ "version": "0.2.0",
40
+ "source_url": "https://github.com/dimsh99/yum-scl",
41
+ "issues_url": "https://github.com/dimsh99/yum-scl/issues"
42
+ }
@@ -0,0 +1,12 @@
1
+ name 'yum-scl'
2
+ maintainer 'Dmitry Shestoperov'
3
+ maintainer_email 'dmitry@shestoperov.info'
4
+ license 'All rights reserved'
5
+ description 'Installs/Configures softwarecollections repositories'
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version '0.2.0'
8
+ issues_url 'https://github.com/dimsh99/yum-scl/issues'
9
+ source_url 'https://github.com/dimsh99/yum-scl'
10
+
11
+ depends 'yum'
12
+ depends 'inifile_chef_gem'
@@ -0,0 +1,52 @@
1
+ repositories = value_for_platform(node['yum-scl']['repos'])
2
+ if repositories.nil?
3
+ raise 'No softwarecollections repository is available '\
4
+ "for #{node['platform']}-#{node['platform_version']}"
5
+ end
6
+ # rubocop:disable Metrics/BlockLength
7
+ repositories.each_pair do |repository_name, repository_spec|
8
+ yum_repository repository_name do
9
+ baseurl repository_spec['baseurl'] unless repository_spec['baseurl'].nil?
10
+ cost repository_spec['cost'] unless repository_spec['cost'].nil?
11
+ description repository_spec['description'] unless repository_spec['description'].nil?
12
+ enabled repository_spec['enabled'] unless repository_spec['enabled'].nil?
13
+ enablegroups repository_spec['enablegroups'] unless repository_spec['enablegroups'].nil?
14
+ exclude repository_spec['exclude'] unless repository_spec['exclude'].nil?
15
+ failovermethod repository_spec['failovermethod'] unless repository_spec['failovermethod'].nil?
16
+ fastestmirror_enabled repository_spec['fastestmirror_enabled'] unless repository_spec['fastestmirror_enabled'].nil?
17
+ gpgcheck repository_spec['gpgcheck'] unless repository_spec['gpgcheck'].nil?
18
+ gpgkey "file:///etc/pki/rpm-gpg/#{repository_spec['gpgkey']}" unless repository_spec['gpgkey'].nil?
19
+ http_caching repository_spec['http_caching'] unless repository_spec['http_caching'].nil?
20
+ include_config repository_spec['include_config'] unless repository_spec['include_config'].nil?
21
+ includepkgs repository_spec['includepkgs'] unless repository_spec['includepkgs'].nil?
22
+ keepalive repository_spec['keepalive'] unless repository_spec['keepalive'].nil?
23
+ make_cache repository_spec['make_cache'] unless repository_spec['make_cache'].nil?
24
+ max_retries repository_spec['max_retries'] unless repository_spec['max_retries'].nil?
25
+ metadata_expire repository_spec['metadata_expire'] unless repository_spec['metadata_expire'].nil?
26
+ mirror_expire repository_spec['mirror_expire'] unless repository_spec['mirror_expire'].nil?
27
+ mirrorlist repository_spec['mirrorlist'] unless repository_spec['mirrorlist'].nil?
28
+ mirrorlist_expire repository_spec['mirrorlist_expire'] unless repository_spec['mirrorlist_expire'].nil?
29
+ password repository_spec['password'] unless repository_spec['password'].nil?
30
+ priority repository_spec['priority'] unless repository_spec['priority'].nil?
31
+ proxy repository_spec['proxy'] unless repository_spec['proxy'].nil?
32
+ proxy_username repository_spec['proxy_username'] unless repository_spec['proxy_username'].nil?
33
+ proxy_password repository_spec['proxy_password'] unless repository_spec['proxy_password'].nil?
34
+ report_instanceid repository_spec['report_instanceid'] unless repository_spec['report_instanceid'].nil?
35
+ repositoryid repository_spec['repositoryid'] unless repository_spec['repositoryid'].nil?
36
+ skip_if_unavailable repository_spec['skip_if_unavailable'] unless repository_spec['skip_if_unavailable'].nil?
37
+ source repository_spec['source'] unless repository_spec['source'].nil?
38
+ sslcacert repository_spec['sslcacert'] unless repository_spec['sslcacert'].nil?
39
+ sslclientcert repository_spec['sslclientcert'] unless repository_spec['sslclientcert'].nil?
40
+ sslclientkey repository_spec['sslclientkey'] unless repository_spec['sslclientkey'].nil?
41
+ sslverify repository_spec['sslverify'] unless repository_spec['sslverify'].nil?
42
+ timeout repository_spec['timeout'] unless repository_spec['timeout'].nil?
43
+ username repository_spec['username'] unless repository_spec['username'].nil?
44
+ end
45
+ cookbook_file "#{repository_name}-gpgkey" do
46
+ path "/etc/pki/rpm-gpg/#{repository_spec['gpgkey']}"
47
+ source repository_spec['gpgkey']
48
+ action :create
49
+ not_if { repository_spec['gpgkey'].nil? }
50
+ end
51
+ end
52
+ # rubocop:enable Metrics/BlockLength
@@ -0,0 +1,17 @@
1
+ #
2
+ # Cookbook Name:: yum-softwarecollections
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2017, YOUR_COMPANY_NAME
6
+ #
7
+ # All rights reserved - Do Not Redistribute
8
+ #
9
+
10
+ Chef::Recipe.send(:include, YumSCL::Helper)
11
+
12
+ if yum_scl_use_os_native_package?(node['yum-scl']['prefer_os_package'],
13
+ node['yum-scl']['native_packages'])
14
+ include_recipe "#{cookbook_name}::native_install"
15
+ else
16
+ include_recipe "#{cookbook_name}::chef_install"
17
+ end
@@ -0,0 +1,35 @@
1
+
2
+ Chef::Recipe.send(:include, YumSCL::Helper)
3
+
4
+ inifile_chef_gem 'default' do
5
+ action :install
6
+ end
7
+
8
+ package 'yum-utils' do
9
+ action :install
10
+ end
11
+
12
+ node['yum-scl']['native_packages'].each do |package|
13
+ # Install packages
14
+ package package do
15
+ action :install
16
+ end
17
+ # Enable/disable repositories
18
+ ruby_block "Enable/disable repositories for #{package}" do
19
+ block do
20
+ Chef::Resource.send(:include, YumSCL::Helper)
21
+ require 'inifile'
22
+ yum_scl_package_repo_files(package).each do |repo_conf|
23
+ %w(testing source debuginfo).each do |ext_repo|
24
+ repo_ini = IniFile.load(repo_conf)
25
+ matched_repos = repo_ini.sections.select do |repository_name|
26
+ /^.+-#{ext_repo}$/.match(repository_name)
27
+ end
28
+ matched_repos.each do |repository_name|
29
+ yum_scl_enable_repo(repository_name, node['yum-scl']["enable_#{ext_repo}"])
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,77 +1,82 @@
1
- require_relative '../command/errors'
2
- require_relative '../utils/vagrantfile_manager'
3
- require_relative 'provider/docker'
4
-
5
- require 'optparse'
1
+ require 'json'
2
+ require 'docker'
6
3
 
7
4
  module VagrantClone
8
- class Command < Vagrant.plugin("2", "command")
5
+ class Clone < Vagrant.plugin('2', 'command')
6
+ CLONE_CON_OPT_DESC = 'Json string, that specifies how many clones of each machine to make or skip. ' +
7
+ 'Example: vagrant clone \'{"machine1":1,"machine2":3,...}\'. ' +
8
+ 'If machine exists in current config, but is not mentioned in clone config, then it will have 0 copies.'
9
9
 
10
- def initialize(argv, env)
11
- super
12
- @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
10
+ def self.synopsis
11
+ 'clone virtual machines into new Vagrant environment'
13
12
  end
14
13
 
15
- def execute
16
- options = {}
17
- opts = OptionParser.new do |o|
18
- o.banner = 'Usage: vagrant clone origin [options] [-h]'
19
- o.on('-n PATH_TO_NEW_VAGRANT_ENVIRONMENT', '--new-vagrant-env-path', 'Where to create new Vagrantfile') do |c|
20
- options[:new_vagrant_env_path] = c
14
+ def parse_options
15
+ options = {:clone_config => nil, :new_env_path => nil}
16
+ option_parser = OptionParser.new do |o|
17
+ o.banner = 'Usage: vagrant clone -c CLONE_CONFIG [-n NEW_VAGRANT_ENVIRONMENT_PATH] [-h]'
18
+ o.on('-c', '--clone-config CLONE_CONFIG', CLONE_CON_OPT_DESC) do |op|
19
+ begin
20
+ options[:clone_config] = JSON.parse op
21
+ options[:clone_config] = Hash[options[:clone_config].map {|k, v| [k.to_sym, v]}]
22
+ rescue Exception => e
23
+ @env.ui.error e.message
24
+ raise VagrantClone::Errors::InvalidCloneConfigOption
25
+ end
26
+ options[:clone_config].each_key do |key|
27
+ unless @env.machine_names.include? key
28
+ @env.ui.error "Machine #{key} does not exists in current Vagrant environment, check clone config..."
29
+ raise VagrantClone::Errors::InvalidCloneConfigOption
30
+ end
31
+ end
21
32
  end
22
- o.on('-h', '--help', 'Help') do |c|
23
- @env.ui.info(opts.help, :prefix => false)
33
+ o.on('-n', '--new-env-path NEW_VAGRANT_ENVIRONMENT_PATH', 'Path where to clone Vagrant environment') do |op|
34
+ raise VagrantClone::Errors::NewEnvironmentDirectoryExists if Dir.exist? op
35
+ raise VagrantClone::Errors::NewEnvironmentDirNotEmpty unless Dir.glob(Pathname.new(op).join('**/*')).empty?
36
+ options[:new_env_path] = op
37
+ end
38
+ o.on_tail('-h', '--help', 'Show this message') do
39
+ @env.ui.info o
24
40
  exit
25
41
  end
26
42
  end
27
- argv = parse_options(opts)
28
- timestamp = Time.new.to_i
29
- options[:vagrantfile_name] = 'Vagrantfile'
30
- options[:current_vagrant_env_path] = Dir.pwd
31
- unless File.exists?("#{options[:current_vagrant_env_path]}/#{options[:vagrantfile_name]}")
32
- raise VagrantClone::Errors::NotVagrantEnvironment
33
- end
34
- unless options[:new_vagrant_env_path]
35
- options[:new_vagrant_env_path] = File.expand_path("#{Dir.pwd}/../#{File.basename options[:current_vagrant_env_path]}_#{timestamp}")
36
- FileUtils.mkdir options[:new_vagrant_env_path]
43
+ option_parser.parse!
44
+ if options[:clone_config].nil?
45
+ @env.ui.error option_parser.help
46
+ raise OptionParser::MissingArgument
37
47
  end
38
- all_machines = Array.new
39
- current_vagrantfile = File.read("#{options[:current_vagrant_env_path]}/#{options[:vagrantfile_name]}")
40
- if argv.empty?
41
- if current_vagrantfile.match('config.vm.define')
42
- current_vagrantfile.split("\n").each do |line|
43
- match = line.match(/config\.vm\.define\s+([^\s]+)\s+/)
44
- if match
45
- all_machines.push match.captures[0].gsub("\"", '').gsub("'", '')
46
- end
47
- end
48
- else
49
- all_machines.push 'default'
50
- end
51
- else
52
- all_machines.push argv
53
- end
54
- all_machines.uniq!
55
- options[:vms_data] = Array.new
56
- # Checking all machines to be alive
57
- all_machines.each do |specific_machine|
58
- with_target_vms(specific_machine) do |machine|
59
- raise VagrantClone::Errors::VmNotCreated if machine.state.id == :not_created
48
+ @env.ui.info "Received args: #{options}"
49
+ return options[:clone_config], options[:new_env_path]
50
+ end
51
+
52
+ def get_machines_and_provider(vagrant_env)
53
+ machines = {}
54
+ providers = []
55
+ vagrant_env.machine_index.each do |entry|
56
+ if vagrant_env.machine_names.include? entry.name.to_sym and vagrant_env.local_data_path == entry.local_data_path
57
+ machine = vagrant_env.machine entry.name.to_sym, entry.provider.to_sym
58
+ machines[entry.name.to_sym] = machine
59
+ providers << entry.provider.to_sym
60
60
  end
61
61
  end
62
- all_machines.each do |specific_machine|
63
- with_target_vms(specific_machine) do |machine|
64
- vm_data = {
65
- :cloned_name => "#{machine.name}",
66
- :cloned_image_name => "#{machine.name}_#{timestamp}",
67
- :origin_id => machine.id,
68
- :provider => machine.provider
69
- }
70
- options[:vms_data].push (vm_data)
71
- Docker.new(vm_data, @env) if /Docker/.match(machine.provider.to_s)
72
- end
62
+ raise VagrantClone::Errors::MultipleProvidersNotSupported if providers.uniq.length > 1
63
+ return machines, providers.uniq[0]
64
+ end
65
+
66
+ def execute
67
+ clone_config, new_env_path = parse_options
68
+ machines, provider = get_machines_and_provider @env
69
+ require_relative '../util/clone_manager_base'
70
+ case provider
71
+ when :docker
72
+ require_relative '../util/clone_managers/docker'
73
+ when :libvirt
74
+ require_relative '../util/clone_managers/libvirt'
75
+ else
76
+ raise VagrantClone::Errors::UnsupportedProvider
73
77
  end
74
- VagrantfileManager.new(options, @env)
78
+ clone_manager = VagrantClone::CloneManager.new clone_config, new_env_path, machines, provider, @env
79
+ clone_manager.create_clones
75
80
  end
76
81
  end
77
82
  end
@@ -0,0 +1,61 @@
1
+ module VagrantClone
2
+ module Errors
3
+ class Error < Vagrant::Errors::VagrantError
4
+ error_namespace('vagrant-clone.errors')
5
+ end
6
+ class VmNotCreated < VagrantClone::Errors::Error
7
+ error_key('vm_not_created')
8
+ end
9
+ class DockerCloningError < VagrantClone::Errors::Error
10
+ error_key('docker_cloning_error')
11
+ end
12
+ class NotVagrantEnvironment < VagrantClone::Errors::Error
13
+ error_key('not_vagrant_environment')
14
+ end
15
+ class UnsupportedDockerVersion < VagrantClone::Errors::Error
16
+ error_key('unsupported_docker_version')
17
+ end
18
+ class UnsupportedProvider < VagrantClone::Errors::Error
19
+ error_key('unsupported_provider')
20
+ end
21
+ class NewEnvironmentDirectoryExists < VagrantClone::Errors::Error
22
+ error_key('new_environment_exists')
23
+ end
24
+ class NewEnvironmentDirNotEmpty < VagrantClone::Errors::Error
25
+ error_key('new_environment_directory_not_empty')
26
+ end
27
+ class InvalidCloneConfigOption < VagrantClone::Errors::Error
28
+ error_key('invalid_clone_config_option')
29
+ end
30
+ class MultipleProvidersNotSupported < VagrantClone::Errors::Error
31
+ error_key('multiple_providers_not_supported')
32
+ end
33
+ class VirtCloneCommandNotFound < VagrantClone::Errors::Error
34
+ error_key('virt_clone_command_not_found')
35
+ end
36
+ class VirtCloneCommandFailed < VagrantClone::Errors::Error
37
+ error_key('virt_clone_command_failed')
38
+ end
39
+ class SSHNotAccessible < VagrantClone::Errors::Error
40
+ error_key('ssh_not_accessible')
41
+ end
42
+ class VagrantBoxAlreadyExists < VagrantClone::Errors::Error
43
+ error_key('vagrant_box_already_exists')
44
+ end
45
+ class QemuImgCommandNotFound < VagrantClone::Errors::Error
46
+ error_key('qemu_img_command_not_found')
47
+ end
48
+ class QemuImgCommandFailed < VagrantClone::Errors::Error
49
+ error_key('qemu_img_command_failed')
50
+ end
51
+ class MachineStateNotAchieved < VagrantClone::Errors::Error
52
+ error_key('machine_state_not_achieved')
53
+ end
54
+ class FailedToCreateNewImagesOrBoxes < VagrantClone::Errors::Error
55
+ error_key('failed_to_create_new_images_or_boxes')
56
+ end
57
+ class TarNotInstalled < VagrantClone::Errors::Error
58
+ error_key('tar_not_installed')
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,69 @@
1
+ require 'fileutils'
2
+ require 'docker'
3
+
4
+ module VagrantClone
5
+ class CloneManagerBase
6
+
7
+ def initialize(clone_config, new_env_path, machines, provider, vagrant_env)
8
+ @clone_config = clone_config
9
+ @new_env_path = new_env_path
10
+ @machines = machines
11
+ @provider = provider
12
+ @vagrant_env = vagrant_env
13
+ end
14
+
15
+ def create_image_or_box(machine)
16
+ raise NotImplementedError
17
+ end
18
+
19
+ def update_clone_config
20
+ config = {}
21
+ @vagrant_env.machine_names.each do |name|
22
+ if @clone_config.keys.include? name
23
+ amount = @clone_config[name]
24
+ unless @machines.has_key? name
25
+ @vagrant_env.ui.error "Virtual machine '#{name}' must be brought up at least once!"
26
+ raise VagrantClone::Errors::VmNotCreated
27
+ end
28
+ config[name] = {
29
+ :box_or_image => create_image_or_box(@machines[name]),
30
+ :amount => amount <= 0 ? 0 : amount
31
+ }
32
+ else
33
+ config[name] = {
34
+ :box_or_image => nil,
35
+ :amount => 0
36
+ }
37
+ end
38
+ end
39
+ @clone_config = config
40
+ @vagrant_env.ui.info "Clone config updated: #{config}"
41
+ end
42
+
43
+ def create_new_env_dir
44
+ if @new_env_path.nil?
45
+ cur_env_path = Pathname.new File.expand_path @vagrant_env.cwd
46
+ cur_env_name = cur_env_path.basename
47
+ @new_env_path = cur_env_path.dirname.join "#{cur_env_name}_#{Time.new.to_i}"
48
+ end
49
+ @vagrant_env.ui.info "Creating new Vagrant environment in: #{@new_env_path}..."
50
+ Dir.mkdir @new_env_path
51
+ end
52
+
53
+ def create_clones
54
+ update_clone_config
55
+ create_new_env_dir
56
+ case @provider
57
+ when :docker
58
+ require_relative '../util/vagrantfile_managers/docker'
59
+ when :libvirt
60
+ require_relative '../util/vagrantfile_managers/libvirt'
61
+ else
62
+ raise VagrantClone::Errors::UnsupportedProvider
63
+ end
64
+ vagrantfile_manager = VagrantClone::VagrantfileManager.new @clone_config, @new_env_path, @vagrant_env
65
+ vagrantfile_manager.rewrite
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,31 @@
1
+ require 'docker'
2
+ require 'net/ssh'
3
+
4
+ module VagrantClone
5
+ class CloneManager < CloneManagerBase
6
+
7
+ VAGRANT_DEFAULT_PUBLIC_KEY = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key'
8
+
9
+ def add_default_vagrant_public_key(machine)
10
+ machine.action 'up', {:destroy_on_error => false, :provision => false, :provider => :docker}
11
+ host=machine.ssh_info[:host]
12
+ port=machine.ssh_info[:port]
13
+ user=machine.ssh_info[:username]
14
+ private_key_paths=machine.ssh_info[:private_key_path]
15
+ @vagrant_env.ui.info "Inserting default vagrant key via ssh to: #{machine.name}..."
16
+ Net::SSH.start(host, user, :port => port, :keys => private_key_paths, :paranoid => Net::SSH::Verifiers::Null.new) do |ssh|
17
+ ssh.exec! "echo '#{VAGRANT_DEFAULT_PUBLIC_KEY}' >> $HOME/.ssh/authorized_keys"
18
+ end
19
+ end
20
+
21
+ def create_image_or_box(machine)
22
+ add_default_vagrant_public_key(machine)
23
+ machine.action 'halt', {:destroy_on_error => false, :provision => false, :provider => :docker}
24
+ container = Docker::Container.get machine.id
25
+ @vagrant_env.ui.info "Creating machine image from container via commit from: #{machine.name}..."
26
+ image = container.commit
27
+ @vagrant_env.ui.info "Created image id is: #{image.id}..."
28
+ image.id
29
+ end
30
+ end
31
+ end