madscience 0.0.1

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 (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.madscience_gem_location +0 -0
  4. data/Cheffile +9 -0
  5. data/Cheffile.lock +34 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +9 -0
  8. data/README.md +126 -0
  9. data/Rakefile +1 -0
  10. data/TODO +17 -0
  11. data/bin/madscience +90 -0
  12. data/cookbooks/apt/CHANGELOG.md +183 -0
  13. data/cookbooks/apt/README.md +255 -0
  14. data/cookbooks/apt/attributes/default.rb +29 -0
  15. data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  16. data/cookbooks/apt/libraries/helpers.rb +49 -0
  17. data/cookbooks/apt/libraries/matchers.rb +17 -0
  18. data/cookbooks/apt/libraries/network.rb +31 -0
  19. data/cookbooks/apt/metadata.json +54 -0
  20. data/cookbooks/apt/metadata.rb +34 -0
  21. data/cookbooks/apt/providers/preference.rb +63 -0
  22. data/cookbooks/apt/providers/repository.rb +150 -0
  23. data/cookbooks/apt/recipes/cacher-client.rb +81 -0
  24. data/cookbooks/apt/recipes/cacher-ng.rb +43 -0
  25. data/cookbooks/apt/recipes/default.rb +91 -0
  26. data/cookbooks/apt/resources/preference.rb +32 -0
  27. data/cookbooks/apt/resources/repository.rb +43 -0
  28. data/cookbooks/apt/templates/debian-6.0/acng.conf.erb +173 -0
  29. data/cookbooks/apt/templates/default/01proxy.erb +5 -0
  30. data/cookbooks/apt/templates/default/acng.conf.erb +275 -0
  31. data/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +269 -0
  32. data/cookbooks/chef_handler/CHANGELOG.md +44 -0
  33. data/cookbooks/chef_handler/README.md +103 -0
  34. data/cookbooks/chef_handler/attributes/default.rb +30 -0
  35. data/cookbooks/chef_handler/files/default/handlers/README +1 -0
  36. data/cookbooks/chef_handler/libraries/matchers.rb +29 -0
  37. data/cookbooks/chef_handler/metadata.json +29 -0
  38. data/cookbooks/chef_handler/metadata.rb +7 -0
  39. data/cookbooks/chef_handler/providers/default.rb +97 -0
  40. data/cookbooks/chef_handler/recipes/default.rb +33 -0
  41. data/cookbooks/chef_handler/recipes/json_file.rb +28 -0
  42. data/cookbooks/chef_handler/resources/default.rb +34 -0
  43. data/cookbooks/dmg/CHANGELOG.md +75 -0
  44. data/cookbooks/dmg/README.md +143 -0
  45. data/cookbooks/dmg/attributes/default.rb +20 -0
  46. data/cookbooks/dmg/metadata.json +30 -0
  47. data/cookbooks/dmg/metadata.rb +9 -0
  48. data/cookbooks/dmg/providers/package.rb +91 -0
  49. data/cookbooks/dmg/recipes/default.rb +18 -0
  50. data/cookbooks/dmg/resources/package.rb +37 -0
  51. data/cookbooks/vagrant/Berksfile +2 -0
  52. data/cookbooks/vagrant/CHANGELOG.md +7 -0
  53. data/cookbooks/vagrant/README.md +146 -0
  54. data/cookbooks/vagrant/TESTING.md +25 -0
  55. data/cookbooks/vagrant/attributes/default.rb +22 -0
  56. data/cookbooks/vagrant/metadata.rb +14 -0
  57. data/cookbooks/vagrant/providers/plugin.rb +50 -0
  58. data/cookbooks/vagrant/recipes/debian.rb +9 -0
  59. data/cookbooks/vagrant/recipes/default.rb +34 -0
  60. data/cookbooks/vagrant/recipes/fedora.rb +1 -0
  61. data/cookbooks/vagrant/recipes/mac_os_x.rb +7 -0
  62. data/cookbooks/vagrant/recipes/rhel.rb +9 -0
  63. data/cookbooks/vagrant/recipes/uninstall_gem.rb +7 -0
  64. data/cookbooks/vagrant/recipes/windows.rb +5 -0
  65. data/cookbooks/vagrant/resources/plugin.rb +8 -0
  66. data/cookbooks/virtualbox/README.md +167 -0
  67. data/cookbooks/virtualbox/attributes/default.rb +32 -0
  68. data/cookbooks/virtualbox/attributes/user.rb +22 -0
  69. data/cookbooks/virtualbox/attributes/webportal.rb +22 -0
  70. data/cookbooks/virtualbox/attributes/webservice.rb +24 -0
  71. data/cookbooks/virtualbox/files/ubuntu/machines_enabled +1 -0
  72. data/cookbooks/virtualbox/files/ubuntu/vboxcontrol +104 -0
  73. data/cookbooks/virtualbox/libraries/helpers.rb +30 -0
  74. data/cookbooks/virtualbox/metadata.rb +16 -0
  75. data/cookbooks/virtualbox/recipes/default.rb +70 -0
  76. data/cookbooks/virtualbox/recipes/systemservice.rb +56 -0
  77. data/cookbooks/virtualbox/recipes/user.rb +39 -0
  78. data/cookbooks/virtualbox/recipes/webportal.rb +58 -0
  79. data/cookbooks/virtualbox/recipes/webservice.rb +44 -0
  80. data/cookbooks/virtualbox/templates/ubuntu/config.erb +3 -0
  81. data/cookbooks/virtualbox/templates/ubuntu/config.php.erb +183 -0
  82. data/cookbooks/virtualbox/templates/ubuntu/vbox.cfg.erb +51 -0
  83. data/cookbooks/windows/CHANGELOG.md +268 -0
  84. data/cookbooks/windows/README.md +665 -0
  85. data/cookbooks/windows/attributes/default.rb +23 -0
  86. data/cookbooks/windows/files/default/handlers/windows_reboot_handler.rb +76 -0
  87. data/cookbooks/windows/libraries/feature_base.rb +59 -0
  88. data/cookbooks/windows/libraries/matchers.rb +450 -0
  89. data/cookbooks/windows/libraries/powershell_helper.rb +59 -0
  90. data/cookbooks/windows/libraries/powershell_out.rb +79 -0
  91. data/cookbooks/windows/libraries/registry_helper.rb +357 -0
  92. data/cookbooks/windows/libraries/version.rb +206 -0
  93. data/cookbooks/windows/libraries/windows_architecture_helper.rb +86 -0
  94. data/cookbooks/windows/libraries/windows_helper.rb +88 -0
  95. data/cookbooks/windows/libraries/windows_privileged.rb +94 -0
  96. data/cookbooks/windows/metadata.json +31 -0
  97. data/cookbooks/windows/metadata.rb +9 -0
  98. data/cookbooks/windows/providers/auto_run.rb +32 -0
  99. data/cookbooks/windows/providers/batch.rb +62 -0
  100. data/cookbooks/windows/providers/feature_dism.rb +64 -0
  101. data/cookbooks/windows/providers/feature_powershell.rb +38 -0
  102. data/cookbooks/windows/providers/feature_servermanagercmd.rb +47 -0
  103. data/cookbooks/windows/providers/package.rb +252 -0
  104. data/cookbooks/windows/providers/pagefile.rb +153 -0
  105. data/cookbooks/windows/providers/path.rb +35 -0
  106. data/cookbooks/windows/providers/printer.rb +100 -0
  107. data/cookbooks/windows/providers/printer_port.rb +102 -0
  108. data/cookbooks/windows/providers/reboot.rb +31 -0
  109. data/cookbooks/windows/providers/registry.rb +72 -0
  110. data/cookbooks/windows/providers/shortcut.rb +56 -0
  111. data/cookbooks/windows/providers/task.rb +128 -0
  112. data/cookbooks/windows/providers/zipfile.rb +91 -0
  113. data/cookbooks/windows/recipes/default.rb +34 -0
  114. data/cookbooks/windows/recipes/reboot_handler.rb +32 -0
  115. data/cookbooks/windows/resources/auto_run.rb +30 -0
  116. data/cookbooks/windows/resources/batch.rb +36 -0
  117. data/cookbooks/windows/resources/feature.rb +44 -0
  118. data/cookbooks/windows/resources/package.rb +46 -0
  119. data/cookbooks/windows/resources/pagefile.rb +29 -0
  120. data/cookbooks/windows/resources/path.rb +28 -0
  121. data/cookbooks/windows/resources/printer.rb +41 -0
  122. data/cookbooks/windows/resources/printer_port.rb +40 -0
  123. data/cookbooks/windows/resources/reboot.rb +29 -0
  124. data/cookbooks/windows/resources/registry.rb +34 -0
  125. data/cookbooks/windows/resources/shortcut.rb +35 -0
  126. data/cookbooks/windows/resources/task.rb +50 -0
  127. data/cookbooks/windows/resources/zipfile.rb +33 -0
  128. data/cookbooks/yum/CHANGELOG.md +212 -0
  129. data/cookbooks/yum/README.md +268 -0
  130. data/cookbooks/yum/attributes/main.rb +97 -0
  131. data/cookbooks/yum/libraries/matchers.rb +27 -0
  132. data/cookbooks/yum/metadata.json +34 -0
  133. data/cookbooks/yum/metadata.rb +13 -0
  134. data/cookbooks/yum/providers/globalconfig.rb +37 -0
  135. data/cookbooks/yum/providers/repository.rb +85 -0
  136. data/cookbooks/yum/recipes/default.rb +34 -0
  137. data/cookbooks/yum/resources/globalconfig.rb +105 -0
  138. data/cookbooks/yum/resources/repository.rb +63 -0
  139. data/cookbooks/yum/templates/default/main.erb +251 -0
  140. data/cookbooks/yum/templates/default/repo.erb +109 -0
  141. data/lib/madscience/version.rb +3 -0
  142. data/lib/madscience.rb +5 -0
  143. data/madscience.gemspec +44 -0
  144. data/new_gem_version.rb +6 -0
  145. data/node-data.json +3 -0
  146. data/site-cookbooks/madscience-vagrant-cookbook/CHANGELOG.md +13 -0
  147. data/site-cookbooks/madscience-vagrant-cookbook/README.md +53 -0
  148. data/site-cookbooks/madscience-vagrant-cookbook/metadata.rb +17 -0
  149. data/site-cookbooks/madscience-vagrant-cookbook/recipes/default.rb +87 -0
  150. data/solo.rb +6 -0
  151. metadata +337 -0
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "dmg",
3
+ "version": "2.2.0",
4
+ "description": "LWRP to install OS X applications from dmgs",
5
+ "long_description": "dmg Cookbook\n============\nLightweight resource and provider to install OS X applications (.app) from dmg files.\n\n\nRequirements\n------------\n### Platform\n- Mac OS X\n\n\nResources/Providers\n-------------------\n### dmg_package\n\nThis resource will install a DMG \"Package\". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef:\n\n```bash\nknife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb\n```\n\nOptionally, the LWRP can install an \"mpkg\" or \"pkg\" package using installer(8).\n\n#### Actions\n- :install - Installs the application.\n\n#### Parameter attributes:\n- `app` - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications.\n- `source` - remote URL for the dmg to download if specified. Default is nil.\n- `owner` - owner that should own the package installation.\n- `destination` - directory to copy the .app into. Default is /Applications.\n- `checksum` - sha256 checksum of the dmg to download. Default is nil.\n- `type` - type of package, \"app\", \"pkg\" or \"mpkg\". Default is \"app\". When using \"pkg\" or \"mpkg\", the destination must be /Applications.\n- `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute.\n- `package_id` - Package id registered with pkgutil when a pkg or mpkg is installed\n- `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces.\n- `dmg_passphrase` - Specify a passphrase to use to unencrypt the dmg while mounting.\n- `accept_eula` - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false.\n\n#### Examples\nInstall `/Applications/Tunnelblick.app` from the primary download site.\n\n```ruby\ndmg_package 'Tunnelblick' do\n source 'http://tunnelblick.googlecode.com/files/Tunnelblick_3.1.2.dmg'\n checksum 'a3fae60b6833175f32df20c90cd3a3603a'\n action :install\nend\n```\n\nInstall Google Chrome. Uses the `dmg_name` because the application name has spaces. Installs in `/Applications/Google Chrome.app`.\n\n```ruby\ndmg_package 'Google Chrome' do\n dmg_name 'googlechrome'\n source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'\n checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'\n action :install\nend\n```\n\nInstall Dropbox. Uses `volumes_dir` because the mounted directory is different than the name of the application directory. Installs in `/Applications/Dropbox.app`.\n\n```ruby\ndmg_package 'Dropbox' do\n volumes_dir 'Dropbox Installer'\n source 'http://www.dropbox.com/download?plat=mac'\n checksum 'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13'\n action :install\nend\n```\n\nInstall MacIrssi to `~/Applications` from the local file downloaded to the cache path into an Applications directory in the current user's home directory. Chef should run as a non-root user for this.\n\n```ruby\ndirectory \"#{ENV['HOME']}/Applications\"\n\ndmg_package 'MacIrssi' do\n destination \"#{ENV['HOME']}/Applications\"\n action :install\nend\n```\n\nInstall Virtualbox to `/Applications` from the .mpkg:\n\n```ruby\ndmg_package 'Virtualbox' do\n source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'\n type 'mpkg'\nend\n```\n\nInstall pgAdmin to `/Applications` and automatically accept the EULA:\n\n```ruby\ndmg_package 'pgAdmin3' do\n source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'\n checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'\n accept_eula true\nend\n```\n\nInstall Pivotal Tracker to `/Applications` using a password-protected dmg:\n\n```ruby\ndmg_package 'Pivotal Tracker' do\n volumes_dir 'tracker'\n source 'http://cheffiles.pivotallabs.com/fluid_tracker.dmg'\n dmg_passphrase 'xyz'\nend\n```\n\nInstall Silverlight, with idempotence check based on pkgutil:\n\n```ruby\ndmg_package 'Silerlight' do\n source 'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg'\n type 'pkg'\n checksum '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc'\n package_id 'com.microsoft.installSilverlightPlugin'\nend\n```\n\n\nLicense & Authors\n-----------------\n- Author:: Joshua Timberman (joshua@opscode.com)\n\n```text\nCopyright 2011, Joshua Timberman <cookbooks@housepub.org>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
6
+ "maintainer": "Opscode, Inc",
7
+ "maintainer_email": "cookbooks@opscode.com",
8
+ "license": "Apache 2.0",
9
+ "platforms": {
10
+ "mac_os_x": ">= 0.0.0"
11
+ },
12
+ "dependencies": {
13
+ },
14
+ "recommendations": {
15
+ },
16
+ "suggestions": {
17
+ },
18
+ "conflicting": {
19
+ },
20
+ "providing": {
21
+ },
22
+ "replacing": {
23
+ },
24
+ "attributes": {
25
+ },
26
+ "groupings": {
27
+ },
28
+ "recipes": {
29
+ }
30
+ }
@@ -0,0 +1,9 @@
1
+ # Encoding: utf-8
2
+ name 'dmg'
3
+ maintainer 'Opscode, Inc'
4
+ maintainer_email 'cookbooks@opscode.com'
5
+ license 'Apache 2.0'
6
+ description 'LWRP to install OS X applications from dmgs'
7
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
8
+ version '2.2.0'
9
+ supports 'mac_os_x'
@@ -0,0 +1,91 @@
1
+ # Encoding: utf-8
2
+ # Cookbook Name:: dmg
3
+ # Provider:: package
4
+ #
5
+ # Copyright 2011, Joshua Timberman
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include Chef::Mixin::ShellOut
21
+
22
+ use_inline_resources if defined?(use_inline_resources)
23
+
24
+ def load_current_resource
25
+ @dmgpkg = Chef::Resource::DmgPackage.new(new_resource.name)
26
+ @dmgpkg.app(new_resource.app)
27
+ Chef::Log.debug("Checking for application #{new_resource.app}")
28
+ @dmgpkg.installed(installed?)
29
+ end
30
+
31
+ action :install do
32
+ unless @dmgpkg.installed
33
+
34
+ volumes_dir = new_resource.volumes_dir ? new_resource.volumes_dir : new_resource.app
35
+ dmg_name = new_resource.dmg_name ? new_resource.dmg_name : new_resource.app
36
+ dmg_file = "#{Chef::Config[:file_cache_path]}/#{dmg_name}.dmg"
37
+
38
+ if new_resource.source
39
+ remote_file "#{dmg_file} - #{@dmgpkg.name}" do
40
+ path dmg_file
41
+ source new_resource.source
42
+ checksum new_resource.checksum if new_resource.checksum
43
+ end
44
+ end
45
+
46
+ passphrase_cmd = new_resource.dmg_passphrase ? "-passphrase #{new_resource.dmg_passphrase}" : ''
47
+ ruby_block "attach #{dmg_file}" do
48
+ block do
49
+ cmd = shell_out("hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}' | grep -q 'Software License Agreement: true'")
50
+ software_license_agreement = (cmd.exitstatus == 0)
51
+ fail "Requires EULA Acceptance; add 'accept_eula true' to package resource" if software_license_agreement && !new_resource.accept_eula
52
+ accept_eula_cmd = new_resource.accept_eula ? 'echo Y | PAGER=true' : ''
53
+ shell_out!("#{accept_eula_cmd} hdiutil attach #{passphrase_cmd} '#{dmg_file}' -quiet")
54
+ end
55
+ not_if "hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'"
56
+ end
57
+
58
+ case new_resource.type
59
+ when 'app'
60
+ execute "rsync --force --recursive --links --perms --executability --owner --group --times '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'" do
61
+ user new_resource.owner if new_resource.owner
62
+ end
63
+
64
+ file "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}" do
65
+ mode 0755
66
+ ignore_failure true
67
+ end
68
+ when 'mpkg', 'pkg'
69
+ execute "sudo installer -pkg '/Volumes/#{volumes_dir}/#{new_resource.app}.#{new_resource.type}' -target /" do
70
+ # Prevent cfprefsd from holding up hdiutil detach for certain disk images
71
+ environment('__CFPREFERENCES_AVOID_DAEMON' => '1') if Gem::Version.new(node['platform_version']) >= Gem::Version.new('10.8')
72
+ end
73
+ end
74
+
75
+ execute "hdiutil detach '/Volumes/#{volumes_dir}' || hdiutil detach '/Volumes/#{volumes_dir}' -force"
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def installed?
82
+ if ::File.directory?("#{new_resource.destination}/#{new_resource.app}.app")
83
+ Chef::Log.info "Already installed; to upgrade, remove \"#{new_resource.destination}/#{new_resource.app}.app\""
84
+ true
85
+ elsif shell_out("pkgutil --pkgs='#{new_resource.package_id}'").exitstatus == 0
86
+ Chef::Log.info "Already installed; to upgrade, try \"sudo pkgutil --forget '#{new_resource.package_id}'\""
87
+ true
88
+ else
89
+ false
90
+ end
91
+ end
@@ -0,0 +1,18 @@
1
+ # Encoding: utf-8
2
+ # Cookbook Name:: dmg
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2011, Joshua Timberman
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
@@ -0,0 +1,37 @@
1
+ # Encoding: utf-8
2
+ # Cookbook Name:: dmg
3
+ # Resource:: package
4
+ #
5
+ # Copyright 2011, Joshua Timberman
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ actions :install
20
+
21
+ attribute :app, :kind_of => String, :name_attribute => true
22
+ attribute :source, :kind_of => String, :default => nil
23
+ attribute :owner, :kind_of => String, :default => nil
24
+ attribute :destination, :kind_of => String, :default => "/Applications"
25
+ attribute :checksum, :kind_of => String, :default => nil
26
+ attribute :volumes_dir, :kind_of => String, :default => nil
27
+ attribute :dmg_name, :kind_of => String, :default => nil
28
+ attribute :type, :kind_of => String, :default => 'app'
29
+ attribute :installed, :kind_of => [TrueClass, FalseClass], :default => false
30
+ attribute :package_id, :kind_of => String, :default => nil
31
+ attribute :dmg_passphrase, :kind_of => String, :default => nil
32
+ attribute :accept_eula, :kind_of => [TrueClass, FalseClass], :default => false
33
+
34
+ def initialize(name, run_context = nil)
35
+ super
36
+ @action = :install
37
+ end
@@ -0,0 +1,2 @@
1
+ site :opscode
2
+ metadata
@@ -0,0 +1,7 @@
1
+ ## 0.2.0:
2
+
3
+ * Add `uninstall_gem` recipe to remove vagrant (1.0) gem.
4
+
5
+ ## 0.1.1:
6
+
7
+ * Initial release of vagrant
@@ -0,0 +1,146 @@
1
+ vagrant Cookbook
2
+ ================
3
+
4
+ Installs Vagrant 1.1+ and manages vagrant plugins w/ a custom
5
+ resource.
6
+
7
+ * Vagrant: http://www.vagrantup.com/
8
+
9
+ This cookbook is not intended to be used for vagrant "1.0" (gem
10
+ install) versions. A recipe is provided for removing the gem, see __Recipes__.
11
+
12
+ Requirements
13
+ ------------
14
+
15
+ Tested with Test Kitchen:
16
+
17
+ * Debian 7.4
18
+ * Ubuntu 14.04
19
+ * CentOS 6.5
20
+
21
+ May work on other Debian/RHEL family distributions with or without modification.
22
+
23
+ Support exists for Windows and OS X but this has not yet been added to test-kitchen (`.kitchen.yml`).
24
+
25
+ The URL and Checksum attributes must be set, see __Attributes__
26
+
27
+ Because Vagrant is installed as a native system package, Chef must run as a privileged user (e.g., root).
28
+
29
+ Attributes
30
+ ==========
31
+
32
+ The following attributes *must* be set. See `.kitchen.yml` for example values.
33
+
34
+ * `node['vagrant']['url']` - URL to the Vagrant installation package.
35
+ * `node['vagrant']['checksum']` - SHA256 checksum of the Vagrant
36
+ installation package.
37
+
38
+ If the node is Windows, the MSI version must be set. This is used by
39
+ the `windows_package` resource to determine if the package is
40
+ installed.
41
+
42
+ * `node['vagrant']['msi_version']` - Version string of the installed
43
+ MSI "package" on Windows.
44
+
45
+ The following attribute is optional.
46
+
47
+ * `node['vagrant']['plugins']` - An array of plugins. The elements in
48
+ the array can be a string or a hash. String elements should be the
49
+ names of plugins to install. Hash elements should have two keys,
50
+ "name" and "version", for the plugin name and its version to
51
+ install. This is used by the `vagrant_plugin` resource in the
52
+ default recipe.
53
+
54
+ Resources
55
+ =========
56
+
57
+ This cookbook includes the `vagrant_plugin` resource, for managing
58
+ vagrant plugins.
59
+
60
+ ## vagrant_plugin
61
+
62
+ ### Actions
63
+
64
+ - `:install`: installs the specified plugin. Default.
65
+ - `:uninstall`: uninstalls the specified plugin
66
+ - `:remove`: uninstalls the specified plugin
67
+
68
+ ### Attribute Parameters
69
+
70
+ - `:plugin_name`: name attribute, the name of the plugin, e.g.
71
+ "vagrant-omnibus".
72
+ - `:version`: version of the plugin to installed, must be specified as
73
+ a string, e.g., "1.0.2"
74
+
75
+ ### Examples
76
+
77
+ vagrant_plugin "vagrant-omnibus"
78
+
79
+ vagrant_plugin "vagrant-berkshelf"
80
+ version "1.2.0"
81
+ end
82
+
83
+ Recipes
84
+ =======
85
+
86
+ ## default
87
+
88
+ The default recipe includes the platform-family specific recipe to
89
+ install Vagrant. It then iterates over the
90
+ `node['vagrant']['plugins']` attribute to install any required vagrant
91
+ plugins.
92
+
93
+ ## debian, fedora, mac_os_x, rhel, windows
94
+
95
+ These are the platform family recipes included by the default recipe.
96
+ The `fedora` recipe will include `rhel`.
97
+
98
+ ## uninstall_gem
99
+
100
+ This recipe will attempt to uninstall the `vagrant` gem with the
101
+ `gem_package` and `chef_gem` resources. Meaning, it will use the `gem`
102
+ binary in the `PATH` of the shell executing Chef to uninstall, and
103
+ then use Chef's built-in RubyGems to uninstall. If you have a
104
+ customized Ruby environment, such as with rbenv or rvm (or other), you
105
+ may need to manually remove and clean up anything leftover, such as
106
+ running `rbenv rehash`. Likewise, if you have multiple copies of the
107
+ vagrant gem installed, you'll need to clean up all versions. This
108
+ recipe won't support such craziness :-).
109
+
110
+ Usage
111
+ =====
112
+
113
+ Set the url and checksum attributes on the node. Do this in a role, or
114
+ a "wrapper" cookbook.
115
+
116
+ Then include the default recipe on the node's run list.
117
+
118
+ To specify plugins for installation in the default recipe, specify an
119
+ array for the `node['vagrant']['plugins']` attribute. For example, to
120
+ install the `vagrant-omnibus` plugin (any version) and version "1.2.0"
121
+ of the `vagrant-berkshelf` plugin:
122
+
123
+ node.set['vagrant']['plugins'] = [
124
+ "vagrant-omnibus",
125
+ {"name" => "vagrant-berkshelf", "version" => "1.2.0"}
126
+ ]
127
+
128
+ See the attribute description above.
129
+
130
+ License and Authors
131
+ -------------------
132
+
133
+ * Author:: Joshua Timberman <opensource@housepub.org>
134
+ * Copyright (c) 2013-2014, Joshua Timberman
135
+
136
+ Licensed under the Apache License, Version 2.0 (the "License");
137
+ you may not use this file except in compliance with the License.
138
+ You may obtain a copy of the License at
139
+
140
+ http://www.apache.org/licenses/LICENSE-2.0
141
+
142
+ Unless required by applicable law or agreed to in writing, software
143
+ distributed under the License is distributed on an "AS IS" BASIS,
144
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145
+ See the License for the specific language governing permissions and
146
+ limitations under the License.
@@ -0,0 +1,25 @@
1
+ This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
2
+
3
+ 1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
4
+ 2. You must have Vagrant 1.1+ installed.
5
+ 3. You must have a "sane" Ruby 1.9.3 environment.
6
+
7
+ Once the above requirements are met, install the additional requirements:
8
+
9
+ Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
10
+
11
+ vagrant plugin install vagrant-berkshelf
12
+ gem install berkshelf
13
+
14
+ Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
15
+
16
+ gem install test-kitchen --pre
17
+
18
+ Install the Vagrant driver for Test Kitchen.
19
+
20
+ gem install kitchen-vagrant
21
+
22
+ Once the above are installed, you should be able to run Test Kitchen:
23
+
24
+ kitchen list
25
+ kitchen test
@@ -0,0 +1,22 @@
1
+ #
2
+ # Author:: Joshua Timberman <opensource@housepub.org>
3
+ # Copyright (c) 2013-2014, Joshua Timberman
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ default['vagrant']['url'] = nil
20
+ default['vagrant']['checksum'] = nil
21
+ default['vagrant']['plugins'] = []
22
+ default['vagrant']['msi_version'] = ""
@@ -0,0 +1,14 @@
1
+ name 'vagrant'
2
+ maintainer 'Joshua Timberman'
3
+ maintainer_email 'cookbooks@housepub.org'
4
+ license 'Apache 2.0'
5
+ description 'Installs/Configures vagrant'
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version '0.2.0'
8
+
9
+ supports 'debian', '>= 6.0'
10
+ supports 'ubuntu', '>= 12.04'
11
+ supports 'redhat', '>= 6.3'
12
+
13
+ depends "dmg"
14
+ depends "windows"
@@ -0,0 +1,50 @@
1
+ require 'chef/mixin/shell_out'
2
+ include Chef::Mixin::ShellOut
3
+
4
+ def load_current_resource
5
+ @current_resource = Chef::Resource::VagrantPlugin.new(new_resource)
6
+ vp = shell_out("vagrant plugin list")
7
+ if vp.stdout.include?(new_resource.plugin_name)
8
+ @current_resource.installed(true)
9
+ @current_resource.installed_version(vp.stdout.split[1].gsub(/[\(\)]/, ''))
10
+ end
11
+ @current_resource
12
+ end
13
+
14
+ action :install do
15
+ unless installed?
16
+ plugin_args = ""
17
+ plugin_args += "--plugin-version #{new_resource.version}" if new_resource.version
18
+ shell_out("vagrant plugin install #{new_resource.plugin_name} #{plugin_args}")
19
+ new_resource.updated_by_last_action(true)
20
+ end
21
+ end
22
+
23
+ action :remove do
24
+ uninstall if @current_resource.installed
25
+ new_resource.updated_by_last_action(true)
26
+ end
27
+
28
+ action :uninstall do
29
+ uninstall if @current_resource.installed
30
+ new_resource.updated_by_last_action(true)
31
+ end
32
+
33
+ def uninstall
34
+ shell_out("vagrant plugin uninstall #{new_resource.plugin_name}")
35
+ end
36
+
37
+ def installed?
38
+ @current_resource.installed && version_match
39
+ end
40
+
41
+ def version_match
42
+ # if the version is specified, we need to check if it matches what
43
+ # is installed already
44
+ if new_resource.version
45
+ @current_resource.installed_version == new_resource.version
46
+ else
47
+ # the version matches otherwise because it's installed
48
+ true
49
+ end
50
+ end
@@ -0,0 +1,9 @@
1
+ remote_file "#{Chef::Config[:file_cache_path]}/vagrant.deb" do
2
+ source node['vagrant']['url']
3
+ checksum node['vagrant']['checksum']
4
+ notifies :install, "dpkg_package[vagrant]", :immediately
5
+ end
6
+
7
+ dpkg_package "vagrant" do
8
+ source "#{Chef::Config[:file_cache_path]}/vagrant.deb"
9
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Cookbook Name:: vagrant
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2013, Joshua Timberman
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe "vagrant::#{node['platform_family']}"
21
+
22
+ node['vagrant']['plugins'].each do |plugin|
23
+ if plugin.respond_to?(:keys)
24
+
25
+ vagrant_plugin plugin['name'] do
26
+ version plugin['version']
27
+ end
28
+
29
+ else
30
+
31
+ vagrant_plugin plugin
32
+
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ include_recipe "vagrant::rhel"
@@ -0,0 +1,7 @@
1
+ dmg_package "Vagrant" do
2
+ source node['vagrant']['url']
3
+ checksum node['vagrant']['checksum']
4
+ type "pkg"
5
+ package_id "com.vagrant.vagrant"
6
+ action :install
7
+ end
@@ -0,0 +1,9 @@
1
+ remote_file "#{Chef::Config[:file_cache_path]}/vagrant.rpm" do
2
+ source node['vagrant']['url']
3
+ checksum node['vagrant']['checksum']
4
+ notifies :install, "rpm_package[vagrant]", :immediately
5
+ end
6
+
7
+ rpm_package "vagrant" do
8
+ source "#{Chef::Config[:file_cache_path]}/vagrant.rpm"
9
+ end
@@ -0,0 +1,7 @@
1
+ gem_package "vagrant" do
2
+ action :remove
3
+ end
4
+
5
+ chef_gem "vagrant" do
6
+ action :remove
7
+ end
@@ -0,0 +1,5 @@
1
+ windows_package "Vagrant #{node['vagrant']['msi_version']}" do
2
+ source node['vagrant']['url']
3
+ checksum node['vagrant']['checksum']
4
+ action :install
5
+ end
@@ -0,0 +1,8 @@
1
+ actions :install, :remove, :uninstall
2
+
3
+ default_action :install
4
+
5
+ attribute :plugin_name, :name_attribute => true
6
+ attribute :version, :kind_of => [String]
7
+ attribute :installed, :kind_of => [TrueClass, FalseClass]
8
+ attribute :installed_version, :kind_of => [String]