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,167 @@
1
+ Description
2
+ ===========
3
+
4
+ Installs Virtualbox on OS X, Debian/Ubuntu or Windows.
5
+
6
+ Changes
7
+ =======
8
+
9
+ ## PENDING
10
+
11
+ * Use platform_family attribute to expand platform support.
12
+ * Use Oracle's VirtualBox package repositories for Debian / RHEL, and
13
+ the Opscode apt/yum cookbook resources accordingly.
14
+ * Add Vbox::Helpers module in libraries/.
15
+ * Add additional platforms supported
16
+ * Add dependencies on required per-platform cookbooks (required for
17
+ Chef 11's chef-solo).
18
+
19
+ ## v0.7.2:
20
+
21
+ * Update OS X installer to use new pkg format - thanks josephholsten.
22
+
23
+ ## v0.7.0:
24
+
25
+ * Add Windows support
26
+ * No more "open source edition" - extension pack must now be downloaded
27
+ separately from Oracle.
28
+ * Optionally install PHP web porta.
29
+
30
+ ## v0.6.0:
31
+
32
+ * Install via Sun's package archive in Ubuntu
33
+ * Optionally install open-source edition from the Ubuntu repository
34
+ * Tested in Ubuntu 11.04
35
+
36
+ ## v0.5.0:
37
+
38
+ * initial version, tested on OSX only
39
+
40
+ Requirements
41
+ ============
42
+
43
+ Requires Chef version 0.10.10+ and Ohai 0.6.10 for `platform_family`
44
+ attribute.
45
+
46
+ ## Platform:
47
+
48
+ * Mac OS X
49
+ * Ubuntu and Debian, 64 bit (amd64/x86\_64)
50
+ * RHEL/CentOS (tested on 6.3)
51
+ * Windows
52
+
53
+ Other related platform family distributions may work.
54
+
55
+ ## Cookbooks
56
+
57
+ You'll also need the respective package manager cookbook for your platform:
58
+
59
+ * dmg (for OS X installation)
60
+ * apt (for Debian family)
61
+ * yum (for RHEL family)
62
+ * windows (for Windows installation)
63
+
64
+ These are dependencies to ensure that the recipes work when using Chef
65
+ Solo, and because it's the right thing to do.
66
+
67
+ Attributes
68
+ ==========
69
+
70
+ * `node['virtualbox']['url']` - URL to the VirtualBox download file.
71
+ Used on Windows and OS X only to the ".exe" or ".dmg," respectively.
72
+ * `node['virtualbox']['version']` - Version of VirtualBox package to
73
+ install. On Windows, this is automatically detected with the
74
+ Vbox::Helpers module as the three-dotted version (e.g., 4.2.8). On
75
+ Debian and RHEL platforms, this is the version suffix for the
76
+ package to ensure that the correct version from the Virtualbox
77
+ repository is installed (e.g., 4.2).
78
+
79
+ Deprecated/unused attributes:
80
+
81
+ * `node['virtualbox']['urlbase']` - This is automatically
82
+ used/calculated in the Vbox::Helpers module and not used elsewhere.
83
+ * `node['virtualbox']['arch']` - This was used for architecture
84
+ specific packages for Linux distributions, which is deprecated in
85
+ favor of the package repository.
86
+ * `node['virtualbox']['open_source_edition']` - This was not used in
87
+ any recipe / template in this cookbook and has been removed.
88
+
89
+ Recipes
90
+ =======
91
+
92
+ # default
93
+
94
+ This recipe will install VirtualBox for supported platforms. On
95
+ Windows and OS X, the file specified by the url attribute (see above)
96
+ will be downloaded and installed. On Linux (Debian and RHEL families
97
+ are supported), the appropriate OS package repository will be added
98
+ (apt or yum, respectively), along with Oracle's VirtualBox package
99
+ signing key, and the package installed from the repository. The
100
+ packages seem to handle all the kernel module recompilation, so this
101
+ recipe doesn't handle that.
102
+
103
+ # Other recipes
104
+
105
+ The following recipes are also available, but have not yet been documented.
106
+
107
+ * systemservice
108
+ * user
109
+ * webportal
110
+ * webservice
111
+
112
+ Helper Library
113
+ ==============
114
+
115
+ The Vbox::Helpers module includes two methods.
116
+
117
+ * `vbox_sha256sum` - Given an absolute URL to the VirtualBox download
118
+ file (.exe or .dmg), the SHA256 checksum will be retrieved from the
119
+ VirtualBox site. This assumes the default URLs from virtualbox.org's
120
+ download site, and may be quite brittle if you're hosting your own
121
+ packages.
122
+
123
+ * `vbox_version` - Given an absolute URL to the download file, the
124
+ version is calculated. This is used on Windows systems because the
125
+ "package" name in Windows includes the version.
126
+
127
+ Usage
128
+ =====
129
+
130
+ Include the virtualbox default recipe in a role run list. If you want
131
+ to install from a different source URL, provide it with the url
132
+ attribute and the version if the Vbox::Helpers library cannot determine
133
+ it, such as:
134
+
135
+ name "role_for_vbox"
136
+ default_attributes(
137
+ "virtualbox" => {
138
+ "url" => "http://url.to/your/vbox.pkg",
139
+ "version" => "4.2"
140
+ })
141
+ run_list("recipe[virtualbox]")
142
+
143
+ Contributions
144
+ =============
145
+
146
+ The source for this cookbook is hosted on
147
+ [GitHub](https://github.com/peplin/virtualbox-cookbook). If you have any issues
148
+ with this cookbook, please follow up there.
149
+
150
+ License and Author
151
+ ==================
152
+
153
+ * Author: Joshua Timberman <cookbooks@housepub.org>
154
+ * Author: Ringo De Smet
155
+
156
+ * Copyright 2011-2013, Joshua Timberman <cookbooks@housepub.org>
157
+
158
+ Licensed under the Apache License, Version 2.0 (the "License");
159
+ you may not use this file except in compliance with the License.
160
+ You may obtain a copy of the License at
161
+
162
+ http://www.apache.org/licenses/LICENSE-2.0
163
+
164
+ Unless required by applicable law or agreed to in writing, software
165
+ distributed under the License is distributed on an "AS IS" BASIS,
166
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
167
+ See the License for the specific language governing permissions and
@@ -0,0 +1,32 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Attributes:: 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
+ #
19
+
20
+
21
+ default['virtualbox']['url'] = ''
22
+ default['virtualbox']['version'] = ''
23
+
24
+ case node['platform_family']
25
+ when 'mac_os_x'
26
+ default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.2.8/VirtualBox-4.2.8-83876-OSX.dmg'
27
+ when 'windows'
28
+ default['virtualbox']['url'] = 'http://download.virtualbox.org/virtualbox/4.2.8/VirtualBox-4.2.8-83876-Win.exe'
29
+ default['virtualbox']['version'] = Vbox::Helpers.vbox_version(node['virtualbox']['url'])
30
+ when 'debian', 'rhel'
31
+ default['virtualbox']['version'] = '4.2'
32
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Attributes:: user
4
+ #
5
+ # Copyright 2012, Ringo De Smet
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
+ # Settings for integrating virtualbox as a system service, automatically rebooting VMs at host startup
21
+ default['virtualbox']['user'] = 'virtualbox'
22
+ default['virtualbox']['group'] = 'vboxusers'
@@ -0,0 +1,22 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Attributes:: webportal
4
+ #
5
+ # Copyright 2012, Ringo De Smet
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
+ # Map major virtualbox version numbers to the phpvirtualbox build numbers
21
+ # https://code.google.com/p/phpvirtualbox/downloads/list
22
+ default['virtualbox']['webportal']['versions'] = { '4.0' => '7', '4.1' => '9' }
@@ -0,0 +1,24 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Attributes:: webservice
4
+ #
5
+ # Copyright 2012, Ringo De Smet
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
+ # Settings for activating the included vboxweb-service
21
+ default['virtualbox']['webservice']['log']['location'] = '/var/log/vboxwebsrv'
22
+ default['virtualbox']['webservice']['log']['rotate'] = 5 # archived log files
23
+ default['virtualbox']['webservice']['log']['size'] = 10485760 # 10 MByte
24
+ default['virtualbox']['webservice']['log']['interval'] = 604800 # 1 week
@@ -0,0 +1 @@
1
+ # Add the uid of VirtualBox VMs you want to see started at boot time of the host.
@@ -0,0 +1,104 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: virtualbox_vms
4
+ # Required-Start: $local_fs $syslog $remote_fs
5
+ # Required-Stop: $local_fs $syslog $remote_fs
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Control VirtualBox Virtual Machine instances
9
+ ### END INIT INFO
10
+ #
11
+ # Version 2008051100 by Jochem Kossen <jochem.kossen@gmail.com>
12
+ # http://farfewertoes.com
13
+ #
14
+ # Released in the public domain
15
+ #
16
+ # This file came with a README file containing the instructions on how
17
+ # to use this script.
18
+ #
19
+
20
+ . /lib/lsb/init-functions
21
+
22
+ # Are we running from init?
23
+ run_by_init() {
24
+ ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
25
+ }
26
+
27
+ ################################################################################
28
+ # INITIAL CONFIGURATION
29
+ VBOXDIR="/etc/virtualbox"
30
+ VM_USER="root"
31
+
32
+ export PATH="${PATH:+$PATH:}/bin:/usr/bin:/usr/sbin:/sbin"
33
+
34
+ if [ -f $VBOXDIR/config ]; then
35
+ . $VBOXDIR/config
36
+ else
37
+ echo "ERROR: $VBOXDIR/config does not exist. Exiting."
38
+ exit 1
39
+ fi
40
+
41
+ SU="su $VM_USER -c"
42
+ VBOXMANAGE="VBoxManage -nologo"
43
+
44
+ ################################################################################
45
+ # FUNCTIONS
46
+
47
+ # Check for running machines every few seconds; return when all machines are
48
+ # down
49
+ wait_for_closing_machines() {
50
+ RUNNING_MACHINES=`$SU "$VBOXMANAGE list runningvms" | wc -l`
51
+ if [ $RUNNING_MACHINES != 0 ]; then
52
+ sleep 5
53
+ wait_for_closing_machines
54
+ fi
55
+ }
56
+
57
+ ################################################################################
58
+ # RUN
59
+ case "$1" in
60
+ start)
61
+ if [ -f /etc/virtualbox/machines_enabled ]; then
62
+ cat /etc/virtualbox/machines_enabled | while read VM; do
63
+ log_action_msg "Starting VM: $VM ..."
64
+ $SU "$VBOXMANAGE startvm \"$VM\" -type vrdp"
65
+ done
66
+ fi
67
+ ;;
68
+ stop)
69
+ # NOTE: this stops all running VM's. Not just the ones listed in the
70
+ # config
71
+ $SU "$VBOXMANAGE list runningvms" | while read VM; do
72
+ VM=`echo $VM | cut -f1 -d ' ' -`
73
+ log_action_msg "Shutting down VM: $VM ..."
74
+ $SU "$VBOXMANAGE controlvm \"$VM\" savestate"
75
+ done
76
+
77
+ wait_for_closing_machines
78
+ ;;
79
+ start-vm)
80
+ log_action_msg "Starting VM: $2 ..."
81
+ $SU "$VBOXMANAGE startvm \"$2\" -type vrdp"
82
+ ;;
83
+ stop-vm)
84
+ log_action_msg "Stopping VM: $2 ..."
85
+ $SU "$VBOXMANAGE controlvm \"$2\" acpipowerbutton"
86
+ ;;
87
+ poweroff-vm)
88
+ log_action_msg "Powering off VM: $2 ..."
89
+ $SU "$VBOXMANAGE controlvm \"$2\" poweroff"
90
+ ;;
91
+ status)
92
+ log_action_msg "The following virtual machines are currently running:"
93
+ $SU "$VBOXMANAGE list runningvms" | while read VM; do
94
+ echo -n "$VM ("
95
+ echo -n `$SU "VBoxManage showvminfo $VM|grep Name:|sed -e 's/^Name:\s*//g'"`
96
+ echo ')'
97
+ done
98
+ ;;
99
+ *)
100
+ log_failure_msg "Usage: $0 {start|stop|status|start-vm <VM name>|stop-vm <VM name>|poweroff-vm <VM name>}"
101
+ exit 3
102
+ esac
103
+
104
+ exit 0
@@ -0,0 +1,30 @@
1
+ require 'open-uri'
2
+ require 'uri'
3
+
4
+ module Vbox
5
+ module Helpers
6
+
7
+ # Retrieves the SHA256 checksum from the VirtualBox downloads
8
+ # site's list of checksums.
9
+ def vbox_sha256sum(url)
10
+ filename = ::File.basename(::URI.parse(url).path)
11
+ urlbase = url.gsub("#{filename}", "")
12
+ sha256sum = ""
13
+ open("#{urlbase}/SHA256SUMS").each do |line|
14
+ sha256sum = line.split(" ")[0] if line =~ /#{filename}/
15
+ end
16
+ return sha256sum
17
+ end
18
+
19
+ # totally assumes the version is the directory in the URL where
20
+ # the filename is. e.g.:
21
+ # http://download.virtualbox.org/virtualbox/4.2.8/VirtualBox-4.2.8-83876-Win.exe
22
+ # returning "4.2.8"
23
+ def vbox_version(url)
24
+ version = File.dirname(URI.parse(url).path).split('/').last
25
+ return version
26
+ end
27
+ end
28
+ end
29
+
30
+ Chef::Recipe.send(:include, Vbox::Helpers)
@@ -0,0 +1,16 @@
1
+ name "virtualbox"
2
+ maintainer "Chris Peplin"
3
+ maintainer_email "chris.peplin@rhubarbtech.com"
4
+ license "Apache 2.0"
5
+ description "Installs virtualbox"
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "0.7.2"
8
+
9
+ %w{ubuntu debian centos redhat mac_os_x windows}.each do |os|
10
+ supports os
11
+ end
12
+
13
+ depends "dmg"
14
+ depends "windows"
15
+ depends "apt"
16
+ depends "yum"
@@ -0,0 +1,70 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2011-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
+ case node['platform_family']
21
+ when 'mac_os_x'
22
+
23
+ sha256sum = vbox_sha256sum(node['virtualbox']['url'])
24
+
25
+ dmg_package 'VirtualBox' do
26
+ source node['virtualbox']['url']
27
+ checksum sha256sum
28
+ type 'mpkg'
29
+ end
30
+
31
+ when 'windows'
32
+
33
+ sha256sum = vbox_sha256sum(node['virtualbox']['url'])
34
+ win_pkg_version = node['virtualbox']['version']
35
+ Chef::Log.debug("Inspecting windows package version: #{win_pkg_version.inspect}")
36
+
37
+ windows_package "Oracle VM VirtualBox #{win_pkg_version}" do
38
+ action :install
39
+ source node['virtualbox']['url']
40
+ checksum sha256sum
41
+ installer_type :custom
42
+ options "-s"
43
+ end
44
+
45
+ when 'debian'
46
+
47
+ apt_repository 'oracle-virtualbox' do
48
+ uri 'http://download.virtualbox.org/virtualbox/debian'
49
+ key 'http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc'
50
+ distribution node['lsb']['codename']
51
+ components ['contrib']
52
+ end
53
+
54
+ package "virtualbox-#{node['virtualbox']['version']}"
55
+ package 'dkms'
56
+
57
+ when 'rhel'
58
+
59
+ yum_key 'oracle-virtualbox' do
60
+ url 'http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc'
61
+ action :add
62
+ end
63
+
64
+ yum_repository 'oracle-virtualbox' do
65
+ description 'Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox'
66
+ url 'http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch'
67
+ end
68
+
69
+ package "VirtualBox-#{node['virtualbox']['version']}"
70
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Recipe:: systemservice
4
+ #
5
+ # Copyright 2012, Ringo De Smet
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 "virtualbox::user"
21
+
22
+ cookbook_file "/etc/init.d/vboxcontrol" do
23
+ source "vboxcontrol"
24
+ mode "0755"
25
+ end
26
+
27
+ directory "/etc/virtualbox" do
28
+ mode "0755"
29
+ end
30
+
31
+ unless FileTest.exists?("/etc/virtualbox/machines_enabled")
32
+ cookbook_file "/etc/virtualbox/machines_enabled" do
33
+ source "machines_enabled"
34
+ mode "0644"
35
+ end
36
+ end
37
+
38
+ host_interface = node[:network][:default_interface]
39
+ addresses = node[:network][:interfaces][host_interface][:addresses]
40
+ host_ip = 'unknown'
41
+ addresses.each do |ip, params|
42
+ host_ip = ip if params['family'].eql?('inet')
43
+ end
44
+
45
+ template "/etc/virtualbox/config" do
46
+ source "config.erb"
47
+ mode "0644"
48
+ variables(
49
+ :host_interface => host_interface,
50
+ :host_ip => host_ip
51
+ )
52
+ end
53
+
54
+ service "vboxcontrol" do
55
+ action [:enable, :start]
56
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Recipe:: user
4
+ #
5
+ # Copyright 2012, Ringo De Smet
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
+ # For the user to be created successfully, a data bag item with the MD5 hashed password
21
+ # needs to be added.
22
+
23
+ include_recipe "apt"
24
+
25
+ p = package "libshadow-ruby1.8" do
26
+ action :nothing
27
+ end
28
+
29
+ p.run_action(:install)
30
+
31
+ user 'virtualbox-user' do
32
+ username node['virtualbox']['user']
33
+ gid node['virtualbox']['group']
34
+ password data_bag_item('passwords','virtualbox-user')['password']
35
+ home "/home/#{node['virtualbox']['user']}"
36
+ shell "/bin/bash"
37
+ system true
38
+ manage_home true
39
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ # Cookbook Name:: virtualbox
3
+ # Recipe:: webportal
4
+ #
5
+ # Copyright 2012, Ringo De Smet
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
+ # The phpvirtualbox webportal requires the Virtualbox webservice api to be active
21
+ include_recipe "virtualbox::webservice"
22
+
23
+ # This recipe requires the apache2 cookbook to be available
24
+ include_recipe "apache2"
25
+ include_recipe "apache2::mod_php5"
26
+
27
+ vbox_version = node['virtualbox']['version']
28
+ phpvirtualbox_build = node['virtualbox']['webportal']['versions'][vbox_version]
29
+ phpvirtualbox_version = "#{vbox_version}-#{phpvirtualbox_build}"
30
+
31
+ remote_file "#{Chef::Config['file_cache_path']}/phpvirtualbox-#{phpvirtualbox_version}.zip" do
32
+ source "http://phpvirtualbox.googlecode.com/files/phpvirtualbox-#{phpvirtualbox_version}.zip"
33
+ mode "0644"
34
+ end
35
+
36
+ package "unzip" do
37
+ action :install
38
+ end
39
+
40
+ bash "extract-phpvirtualbox" do
41
+ code <<-EOH
42
+ cd /tmp
43
+ unzip #{Chef::Config['file_cache_path']}/phpvirtualbox-#{phpvirtualbox_version}.zip
44
+ cd phpvirtualbox-#{phpvirtualbox_version}
45
+ mv * /var/www
46
+ cd ..
47
+ rm -rf phpvirtualbox-#{phpvirtualbox_version}
48
+ EOH
49
+ end
50
+
51
+ template "/var/www/config.php" do
52
+ source "config.php.erb"
53
+ mode "0644"
54
+ notifies :restart, "service[apache2]", :immediately
55
+ variables(
56
+ :password => data_bag_item('passwords','vboxweb-service')['password']
57
+ )
58
+ end