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,103 @@
1
+ Description
2
+ ===========
3
+
4
+ Creates a configured handler path for distributing [Chef report and exception handlers](http://docs.opscode.com/handlers.html). Also exposes an LWRP for enabling Chef handlers from within recipe code (as opposed to hard coding in the client.rb file). This is useful for cookbook authors who may want to ship a product specific handler (see the `cloudkick` cookbook for an example) with their cookbook.
5
+
6
+ Attributes
7
+ ==========
8
+
9
+ `node["chef_handler"]["handler_path"]` - location to drop off handlers directory, default is `/var/chef/handlers`.
10
+
11
+ Resource/Provider
12
+ =================
13
+
14
+ `chef_handler`
15
+ --------------
16
+
17
+ Requires, configures and enables handlers on the node for the current Chef run. Also has the ability to pass arguments to the handlers initializer. This allows initialization data to be pulled from a node's attribute data.
18
+
19
+ It is best to declare `chef_handler` resources early on in the compile phase so they are available to fire for any exceptions during the Chef run. If you have a base role you would want any recipes that register Chef handlers to come first in the run_list.
20
+
21
+ ### Actions
22
+
23
+ - :enable: Enables the Chef handler for the current Chef run on the current node
24
+ - :disable: Disables the Chef handler for the current Chef run on the current node
25
+
26
+ ### Attribute Parameters
27
+
28
+ - class_name: name attribute. The name of the handler class (can be module name-spaced).
29
+ - source: full path to the handler file. can also be a gem path if the handler ships as part of a Ruby gem.
30
+ - arguments: an array of arguments to pass the handler's class initializer
31
+ - supports: type of Chef Handler to register as, ie :report, :exception or both. default is `:report => true, :exception => true`
32
+
33
+ ### Example
34
+
35
+ # register the Chef::Handler::JsonFile handler
36
+ # that ships with the Chef gem
37
+ chef_handler "Chef::Handler::JsonFile" do
38
+ source "chef/handler/json_file"
39
+ arguments :path => '/var/chef/reports'
40
+ action :enable
41
+ end
42
+
43
+ # do the same but during the compile phase
44
+ chef_handler "Chef::Handler::JsonFile" do
45
+ source "chef/handler/json_file"
46
+ arguments :path => '/var/chef/reports'
47
+ action :nothing
48
+ end.run_action(:enable)
49
+
50
+ # handle exceptions only
51
+ chef_handler "Chef::Handler::JsonFile" do
52
+ source "chef/handler/json_file"
53
+ arguments :path => '/var/chef/reports'
54
+ supports :exception => true
55
+ action :enable
56
+ end
57
+
58
+
59
+ # enable the CloudkickHandler which was
60
+ # dropped off in the default handler path.
61
+ # passes the oauth key/secret to the handler's
62
+ # intializer.
63
+ chef_handler "CloudkickHandler" do
64
+ source "#{node['chef_handler']['handler_path']}/cloudkick_handler.rb"
65
+ arguments [node['cloudkick']['oauth_key'], node['cloudkick']['oauth_secret']]
66
+ action :enable
67
+ end
68
+
69
+
70
+ Usage
71
+ =====
72
+
73
+ default
74
+ -------
75
+
76
+ Put the recipe `chef_handler` at the start of the node's run list to make sure that custom handlers are dropped off early on in the Chef run and available for later recipes.
77
+
78
+ For information on how to write report and exception handlers for Chef, please see the Chef wiki pages:
79
+ http://wiki.opscode.com/display/chef/Exception+and+Report+Handlers
80
+
81
+ json_file
82
+ ---------
83
+
84
+ Leverages the `chef_handler` LWRP to automatically register the `Chef::Handler::JsonFile` handler that ships as part of Chef. This handler serializes the run status data to a JSON file located at `/var/chef/reports`.
85
+
86
+ License and Author
87
+ ==================
88
+
89
+ Author:: Seth Chisamore (<schisamo@opscode.com>)
90
+
91
+ Copyright:: 2011, Opscode, Inc
92
+
93
+ Licensed under the Apache License, Version 2.0 (the "License");
94
+ you may not use this file except in compliance with the License.
95
+ You may obtain a copy of the License at
96
+
97
+ http://www.apache.org/licenses/LICENSE-2.0
98
+
99
+ Unless required by applicable law or agreed to in writing, software
100
+ distributed under the License is distributed on an "AS IS" BASIS,
101
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
102
+ See the License for the specific language governing permissions and
103
+ limitations under the License.
@@ -0,0 +1,30 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: chef_handlers
4
+ # Attribute:: default
5
+ #
6
+ # Copyright 2011-2013, Opscode, Inc
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ default["chef_handler"]["root_user"] = "root"
22
+
23
+ case platform
24
+ when "openbsd", "freebsd", "mac_os_x", "mac_os_x_server"
25
+ default["chef_handler"]["root_group"] = "wheel"
26
+ else
27
+ default["chef_handler"]["root_group"] = "root"
28
+ end
29
+
30
+ default["chef_handler"]["handler_path"] = "#{File.expand_path(File.join(Chef::Config[:file_cache_path], '..'))}/handlers"
@@ -0,0 +1 @@
1
+ This directory contains Chef handlers to distribute to your nodes.
@@ -0,0 +1,29 @@
1
+ #
2
+ # Author:: Douglas Thrift (<douglas.thrift@rightscale.com>)
3
+ # Cookbook Name:: chef_handler
4
+ # Library:: matchers
5
+ #
6
+ # Copyright 2014, Chef Software, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ if defined?(ChefSpec)
22
+ def enable_chef_handler(resource_name)
23
+ ChefSpec::Matchers::ResourceMatcher.new(:chef_handler, :enable, resource_name)
24
+ end
25
+
26
+ def disable_chef_handler(resource_name)
27
+ ChefSpec::Matchers::ResourceMatcher.new(:chef_handler, :disable, resource_name)
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "chef_handler",
3
+ "version": "1.1.6",
4
+ "description": "Distribute and enable Chef Exception and Report handlers",
5
+ "long_description": "Description\n===========\n\nCreates a configured handler path for distributing [Chef report and exception handlers](http://docs.opscode.com/handlers.html). Also exposes an LWRP for enabling Chef handlers from within recipe code (as opposed to hard coding in the client.rb file). This is useful for cookbook authors who may want to ship a product specific handler (see the `cloudkick` cookbook for an example) with their cookbook.\n\nAttributes\n==========\n\n`node[\"chef_handler\"][\"handler_path\"]` - location to drop off handlers directory, default is `/var/chef/handlers`.\n\nResource/Provider\n=================\n\n`chef_handler`\n--------------\n\nRequires, configures and enables handlers on the node for the current Chef run. Also has the ability to pass arguments to the handlers initializer. This allows initialization data to be pulled from a node's attribute data.\n\nIt is best to declare `chef_handler` resources early on in the compile phase so they are available to fire for any exceptions during the Chef run. If you have a base role you would want any recipes that register Chef handlers to come first in the run_list.\n\n### Actions\n\n- :enable: Enables the Chef handler for the current Chef run on the current node\n- :disable: Disables the Chef handler for the current Chef run on the current node\n\n### Attribute Parameters\n\n- class_name: name attribute. The name of the handler class (can be module name-spaced).\n- source: full path to the handler file. can also be a gem path if the handler ships as part of a Ruby gem.\n- arguments: an array of arguments to pass the handler's class initializer\n- supports: type of Chef Handler to register as, ie :report, :exception or both. default is `:report => true, :exception => true`\n\n### Example\n\n # register the Chef::Handler::JsonFile handler\n # that ships with the Chef gem\n chef_handler \"Chef::Handler::JsonFile\" do\n source \"chef/handler/json_file\"\n arguments :path => '/var/chef/reports'\n action :enable\n end\n\n # do the same but during the compile phase\n chef_handler \"Chef::Handler::JsonFile\" do\n source \"chef/handler/json_file\"\n arguments :path => '/var/chef/reports'\n action :nothing\n end.run_action(:enable)\n\n # handle exceptions only\n chef_handler \"Chef::Handler::JsonFile\" do\n source \"chef/handler/json_file\"\n arguments :path => '/var/chef/reports'\n supports :exception => true\n action :enable\n end\n\n\n # enable the CloudkickHandler which was\n # dropped off in the default handler path.\n # passes the oauth key/secret to the handler's\n # intializer.\n chef_handler \"CloudkickHandler\" do\n source \"#{node['chef_handler']['handler_path']}/cloudkick_handler.rb\"\n arguments [node['cloudkick']['oauth_key'], node['cloudkick']['oauth_secret']]\n action :enable\n end\n\n\nUsage\n=====\n\ndefault\n-------\n\nPut the recipe `chef_handler` at the start of the node's run list to make sure that custom handlers are dropped off early on in the Chef run and available for later recipes.\n\nFor information on how to write report and exception handlers for Chef, please see the Chef wiki pages:\nhttp://wiki.opscode.com/display/chef/Exception+and+Report+Handlers\n\njson_file\n---------\n\nLeverages the `chef_handler` LWRP to automatically register the `Chef::Handler::JsonFile` handler that ships as part of Chef. This handler serializes the run status data to a JSON file located at `/var/chef/reports`.\n\nLicense and Author\n==================\n\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright:: 2011, Opscode, Inc\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",
6
+ "maintainer": "Opscode, Inc.",
7
+ "maintainer_email": "cookbooks@opscode.com",
8
+ "license": "Apache 2.0",
9
+ "platforms": {
10
+ },
11
+ "dependencies": {
12
+ },
13
+ "recommendations": {
14
+ },
15
+ "suggestions": {
16
+ },
17
+ "conflicting": {
18
+ },
19
+ "providing": {
20
+ },
21
+ "replacing": {
22
+ },
23
+ "attributes": {
24
+ },
25
+ "groupings": {
26
+ },
27
+ "recipes": {
28
+ }
29
+ }
@@ -0,0 +1,7 @@
1
+ name "chef_handler"
2
+ maintainer "Opscode, Inc."
3
+ maintainer_email "cookbooks@opscode.com"
4
+ license "Apache 2.0"
5
+ description "Distribute and enable Chef Exception and Report handlers"
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "1.1.6"
@@ -0,0 +1,97 @@
1
+ #
2
+ # Author:: Seth Chisamore <schisamo@opscode.com>
3
+ # Cookbook Name:: chef_handler
4
+ # Provider:: default
5
+ #
6
+ # Copyright:: 2011-2013, Opscode, Inc <legal@opscode.com>
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ def whyrun_supported?
22
+ true
23
+ end
24
+
25
+ action :enable do
26
+ # use load instead of require to ensure the handler file
27
+ # is reloaded into memory each chef run. fixes COOK-620
28
+ handler = nil
29
+ converge_by("load #{@new_resource.source}") do
30
+ begin
31
+ Object.send(:remove_const, klass)
32
+ GC.start
33
+ rescue
34
+ Chef::Log.debug("#{@new_resource.class_name} has not been loaded.")
35
+ end
36
+ file_name = @new_resource.source
37
+ file_name << ".rb" unless file_name =~ /.*\.rb$/
38
+ load file_name
39
+ handler = klass.send(:new, *collect_args(@new_resource.arguments))
40
+ end
41
+ @new_resource.supports.each do |type, enable|
42
+ if enable
43
+ # we have to re-enable the handler every chef run
44
+ # to ensure daemonized Chef always has the latest
45
+ # handler code. TODO: add a :reload action
46
+ converge_by("enable #{@new_resource} as a #{type} handler") do
47
+ Chef::Log.info("Enabling #{@new_resource} as a #{type} handler")
48
+ Chef::Config.send("#{type.to_s}_handlers").delete_if { |v| v.class.to_s.include? @new_resource.class_name.split('::', 3).last }
49
+ Chef::Config.send("#{type.to_s}_handlers") << handler
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ action :disable do
56
+ @new_resource.supports.each_key do |type|
57
+ if enabled?(type)
58
+ converge_by("disable #{@new_resource} as a #{type} handler") do
59
+ Chef::Log.info("Disabling #{@new_resource} as a #{type} handler")
60
+ Chef::Config.send("#{type.to_s}_handlers").delete_if { |v| v.class.to_s.include? @new_resource.class_name.split('::', 3).last }
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ def load_current_resource
67
+ @current_resource = Chef::Resource::ChefHandler.new(@new_resource.name)
68
+ @current_resource.class_name(@new_resource.class_name)
69
+ @current_resource.source(@new_resource.source)
70
+ @current_resource
71
+ end
72
+
73
+ private
74
+
75
+ def enabled?(type)
76
+ Chef::Config.send("#{type.to_s}_handlers").select do |handler|
77
+ handler.class.to_s.include? @new_resource.class_name
78
+ end.size >= 1
79
+ end
80
+
81
+ def collect_args(resource_args = [])
82
+ if resource_args.is_a? Array
83
+ resource_args
84
+ else
85
+ [resource_args]
86
+ end
87
+ end
88
+
89
+ def klass
90
+ @klass ||= begin
91
+ # we need to search the ancestors only for the
92
+ # first/uppermost namespace of the class, so we need
93
+ # to enable the #const_get inherit paramenter only when
94
+ # we are searching in Kernel scope (see COOK-4117).
95
+ @new_resource.class_name.split('::').inject(Kernel) { |scope, const_name| scope.const_get(const_name, scope === Kernel) }
96
+ end
97
+ end
@@ -0,0 +1,33 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: chef_handlers
4
+ # Recipe:: default
5
+ #
6
+ # Copyright 2011, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ Chef::Log.info("Chef Handlers will be at: #{node['chef_handler']['handler_path']}")
22
+
23
+ remote_directory node['chef_handler']['handler_path'] do
24
+ source 'handlers'
25
+ # Just inherit permissions on Windows, don't try to set POSIX perms
26
+ if node["platform"] != "windows"
27
+ owner node['chef_handler']['root_user']
28
+ group node['chef_handler']['root_group']
29
+ mode "0755"
30
+ recursive true
31
+ end
32
+ action :nothing
33
+ end.run_action(:create)
@@ -0,0 +1,28 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: chef_handlers
4
+ # Recipe:: json_file
5
+ #
6
+ # Copyright 2011, Opscode, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ # force resource actions in compile phase so exception handler
22
+ # fires for compile phase exceptions
23
+
24
+ chef_handler "Chef::Handler::JsonFile" do
25
+ source "chef/handler/json_file"
26
+ arguments :path => '/var/chef/reports'
27
+ action :nothing
28
+ end.run_action(:enable)
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Seth Chisamore <schisamo@opscode.com>
3
+ # Cookbook Name:: chef_handler
4
+ # Resource:: default
5
+ #
6
+ # Copyright:: 2011-2013, Opscode, Inc <legal@opscode.com>
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ actions :enable, :disable
22
+
23
+ attribute :class_name, :kind_of => String, :name_attribute => true
24
+ attribute :source, :default => nil, :kind_of => String
25
+ attribute :arguments, :default => []
26
+ attribute :supports, :kind_of => Hash, :default => { :report => true, :exception => true }
27
+
28
+ # we have to set default for the supports attribute
29
+ # in initializer since it is a 'reserved' attribute name
30
+ def initialize(*args)
31
+ super
32
+ @action = :enable
33
+ @supports = { :report => true, :exception => true }
34
+ end
@@ -0,0 +1,75 @@
1
+ dmg Cookbook CHANGELOG
2
+ ======================
3
+ This file is used to list changes made in each version of the dmg ookbook.
4
+
5
+
6
+ v2.2.0 (2014-02-25)
7
+ -------------------
8
+ - [COOK-4285] Accept long EULAs
9
+
10
+
11
+ v2.1.4 (2014-01-26)
12
+ -------------------
13
+ * [COOK-4157] - dmg_package LWRP broken due to "puts" instead of "system"
14
+ * [COOK-4065] - dmg cookbook outputs the name of packages when checking if they are installed
15
+
16
+
17
+ v2.1.2
18
+ ------
19
+ Cleaning up merge errors
20
+
21
+
22
+ v2.1.0
23
+ ------
24
+ ### Bug
25
+ - **[COOK-3946](https://tickets.opscode.com/browse/COOK-3946)** - Syntax error in resources/package.rb
26
+ - **[COOK-2672](https://tickets.opscode.com/browse/COOK-2672)** - EULA for package is displayed instead accepted
27
+
28
+
29
+ v2.0.8
30
+ ------
31
+ Adding a Chef 10 compatibility check in provider
32
+
33
+
34
+ v2.0.6
35
+ ------
36
+ # BUG
37
+ - [COOK-3302] - Sometimes hdiutil detach fails due to cfprefsd running in background
38
+ # IMPROVEMENT
39
+ - Adding foodcritic and rubocop to .travis.yml
40
+
41
+
42
+ v2.0.4
43
+ ------
44
+ ### Bug
45
+ - **[COOK-3331](https://tickets.opscode.com/browse/COOK-3331)** - Fix an issue where `dmg_package` with no source raises an exception
46
+
47
+
48
+ v2.0.2
49
+ ------
50
+ ### Bug
51
+ - **[COOK-3578](https://tickets.opscode.com/browse/COOK-3578)** - Support `package_id`s with spaces
52
+ - **[COOK-3302](https://tickets.opscode.com/browse/COOK-3302)** - Fix an issue where `hdiutil detach` fails due to `cfprefsd` running in the background
53
+
54
+ v2.0.0
55
+ ------
56
+ ### Bug
57
+ - **[COOK-3389](https://tickets.opscode.com/browse/COOK-3389)** - Use `rsync` instead of `cp` (potentially a breaking change on some systems)
58
+
59
+ v1.1.0
60
+ ------
61
+ - [COOK-1847] - accept owner parameter for installing packages
62
+
63
+ v1.0.0
64
+ ------
65
+ - [COOK-852] - Support "pkg" in addition to "mpkg" package types
66
+
67
+ v0.7.0
68
+ ------
69
+ - [COOK-854] - use `cp -R` instead of `cp -r`
70
+ - [COOK-855] - specify a file or directory to check for prior install
71
+
72
+ v0.6.0
73
+ ------
74
+ - option to install software that is an .mpkg inside a .dmg
75
+ - ignore failure on chmod in case mode is already set, or is root owned
@@ -0,0 +1,143 @@
1
+ dmg Cookbook
2
+ ============
3
+ Lightweight resource and provider to install OS X applications (.app) from dmg files.
4
+
5
+
6
+ Requirements
7
+ ------------
8
+ ### Platform
9
+ - Mac OS X
10
+
11
+
12
+ Resources/Providers
13
+ -------------------
14
+ ### dmg_package
15
+
16
+ This 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:
17
+
18
+ ```bash
19
+ knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb
20
+ ```
21
+
22
+ Optionally, the LWRP can install an "mpkg" or "pkg" package using installer(8).
23
+
24
+ #### Actions
25
+ - :install - Installs the application.
26
+
27
+ #### Parameter attributes:
28
+ - `app` - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications.
29
+ - `source` - remote URL for the dmg to download if specified. Default is nil.
30
+ - `owner` - owner that should own the package installation.
31
+ - `destination` - directory to copy the .app into. Default is /Applications.
32
+ - `checksum` - sha256 checksum of the dmg to download. Default is nil.
33
+ - `type` - type of package, "app", "pkg" or "mpkg". Default is "app". When using "pkg" or "mpkg", the destination must be /Applications.
34
+ - `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.
35
+ - `package_id` - Package id registered with pkgutil when a pkg or mpkg is installed
36
+ - `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces.
37
+ - `dmg_passphrase` - Specify a passphrase to use to unencrypt the dmg while mounting.
38
+ - `accept_eula` - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false.
39
+
40
+ #### Examples
41
+ Install `/Applications/Tunnelblick.app` from the primary download site.
42
+
43
+ ```ruby
44
+ dmg_package 'Tunnelblick' do
45
+ source 'http://tunnelblick.googlecode.com/files/Tunnelblick_3.1.2.dmg'
46
+ checksum 'a3fae60b6833175f32df20c90cd3a3603a'
47
+ action :install
48
+ end
49
+ ```
50
+
51
+ Install Google Chrome. Uses the `dmg_name` because the application name has spaces. Installs in `/Applications/Google Chrome.app`.
52
+
53
+ ```ruby
54
+ dmg_package 'Google Chrome' do
55
+ dmg_name 'googlechrome'
56
+ source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'
57
+ checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'
58
+ action :install
59
+ end
60
+ ```
61
+
62
+ Install Dropbox. Uses `volumes_dir` because the mounted directory is different than the name of the application directory. Installs in `/Applications/Dropbox.app`.
63
+
64
+ ```ruby
65
+ dmg_package 'Dropbox' do
66
+ volumes_dir 'Dropbox Installer'
67
+ source 'http://www.dropbox.com/download?plat=mac'
68
+ checksum 'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13'
69
+ action :install
70
+ end
71
+ ```
72
+
73
+ Install 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.
74
+
75
+ ```ruby
76
+ directory "#{ENV['HOME']}/Applications"
77
+
78
+ dmg_package 'MacIrssi' do
79
+ destination "#{ENV['HOME']}/Applications"
80
+ action :install
81
+ end
82
+ ```
83
+
84
+ Install Virtualbox to `/Applications` from the .mpkg:
85
+
86
+ ```ruby
87
+ dmg_package 'Virtualbox' do
88
+ source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'
89
+ type 'mpkg'
90
+ end
91
+ ```
92
+
93
+ Install pgAdmin to `/Applications` and automatically accept the EULA:
94
+
95
+ ```ruby
96
+ dmg_package 'pgAdmin3' do
97
+ source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'
98
+ checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'
99
+ accept_eula true
100
+ end
101
+ ```
102
+
103
+ Install Pivotal Tracker to `/Applications` using a password-protected dmg:
104
+
105
+ ```ruby
106
+ dmg_package 'Pivotal Tracker' do
107
+ volumes_dir 'tracker'
108
+ source 'http://cheffiles.pivotallabs.com/fluid_tracker.dmg'
109
+ dmg_passphrase 'xyz'
110
+ end
111
+ ```
112
+
113
+ Install Silverlight, with idempotence check based on pkgutil:
114
+
115
+ ```ruby
116
+ dmg_package 'Silerlight' do
117
+ source 'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg'
118
+ type 'pkg'
119
+ checksum '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc'
120
+ package_id 'com.microsoft.installSilverlightPlugin'
121
+ end
122
+ ```
123
+
124
+
125
+ License & Authors
126
+ -----------------
127
+ - Author:: Joshua Timberman (joshua@opscode.com)
128
+
129
+ ```text
130
+ Copyright 2011, Joshua Timberman <cookbooks@housepub.org>
131
+
132
+ Licensed under the Apache License, Version 2.0 (the "License");
133
+ you may not use this file except in compliance with the License.
134
+ You may obtain a copy of the License at
135
+
136
+ http://www.apache.org/licenses/LICENSE-2.0
137
+
138
+ Unless required by applicable law or agreed to in writing, software
139
+ distributed under the License is distributed on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141
+ See the License for the specific language governing permissions and
142
+ limitations under the License.
143
+ ```
@@ -0,0 +1,20 @@
1
+ # Encoding: utf-8
2
+ # Cookbook Name:: dmg
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
+ default['dmg']['base_dir'] = '/Applications'
20
+ default['dmg']['cache_dir'] = Chef::Config[:file_cache_path]