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,72 @@
1
+ #
2
+ # Author:: Doug MacEachern (<dougm@vmware.com>)
3
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
4
+ # Author:: Paul Morton (<pmorton@biaprotect.com>)
5
+ # Cookbook Name:: windows
6
+ # Provider:: registry
7
+ #
8
+ # Copyright:: 2010, VMware, Inc.
9
+ # Copyright:: 2011, Opscode, Inc.
10
+ # Copyright:: 2011, Business Intelligence Associates, Inc
11
+ #
12
+ # Licensed under the Apache License, Version 2.0 (the "License");
13
+ # you may not use this file except in compliance with the License.
14
+ # You may obtain a copy of the License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the License is distributed on an "AS IS" BASIS,
20
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ # See the License for the specific language governing permissions and
22
+ # limitations under the License.
23
+ #
24
+
25
+ include Windows::RegistryHelper
26
+
27
+ action :create do
28
+ registry_update(:create)
29
+ end
30
+
31
+ action :modify do
32
+ registry_update(:open)
33
+ end
34
+
35
+ action :force_modify do
36
+ require 'timeout'
37
+ Timeout.timeout(120) do
38
+ @new_resource.values.each do |value_name, value_data|
39
+ i = 1
40
+ until i > 5 do
41
+ desired_value_data = value_data
42
+ current_value_data = get_value(@new_resource.key_name.dup, value_name.dup)
43
+ if current_value_data.to_s == desired_value_data.to_s
44
+ Chef::Log.debug("#{@new_resource} value [#{value_name}] desired [#{desired_value_data}] data already set. Check #{i}/5.")
45
+ i+=1
46
+ else
47
+ Chef::Log.debug("#{@new_resource} value [#{value_name}] current [#{current_value_data}] data not equal to desired [#{desired_value_data}] data. Setting value and restarting check loop.")
48
+ begin
49
+ registry_update(:open)
50
+ rescue Exception
51
+ registry_update(:create)
52
+ end
53
+ i=0 # start count loop over
54
+ end
55
+ end
56
+ end
57
+ break
58
+ end
59
+ end
60
+
61
+ action :remove do
62
+ delete_value(@new_resource.key_name,@new_resource.values)
63
+ end
64
+
65
+ private
66
+ def registry_update(mode)
67
+
68
+ Chef::Log.debug("Registry Mode (#{mode})")
69
+ updated = set_value(mode,@new_resource.key_name,@new_resource.values,@new_resource.type)
70
+ @new_resource.updated_by_last_action(updated)
71
+
72
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Author:: Doug MacEachern <dougm@vmware.com>
3
+ # Cookbook Name:: windows
4
+ # Provider:: shortcut
5
+ #
6
+ # Copyright:: 2010, VMware, 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
+ def load_current_resource
22
+ require 'win32ole'
23
+
24
+ @link = WIN32OLE.new("WScript.Shell").CreateShortcut(@new_resource.name)
25
+
26
+ @current_resource = Chef::Resource::WindowsShortcut.new(@new_resource.name)
27
+ @current_resource.name(@new_resource.name)
28
+ @current_resource.target(@link.TargetPath)
29
+ @current_resource.arguments(@link.Arguments)
30
+ @current_resource.description(@link.Description)
31
+ @current_resource.cwd(@link.WorkingDirectory)
32
+ end
33
+
34
+ # Check to see if the shorcut needs any changes
35
+ #
36
+ # === Returns
37
+ # <true>:: If a change is required
38
+ # <false>:: If the shorcuts are identical
39
+ def compare_shortcut
40
+ [:target, :arguments, :description, :cwd].any? do |attr|
41
+ !@new_resource.send(attr).nil? && @current_resource.send(attr) != @new_resource.send(attr)
42
+ end
43
+ end
44
+
45
+ def action_create
46
+ if compare_shortcut
47
+ @link.TargetPath = @new_resource.target if @new_resource.target != nil
48
+ @link.Arguments = @new_resource.arguments if @new_resource.arguments != nil
49
+ @link.Description = @new_resource.description if @new_resource.description != nil
50
+ @link.WorkingDirectory = @new_resource.cwd if @new_resource.cwd != nil
51
+ #ignoring: WindowStyle, Hotkey, IconLocation
52
+ @link.Save
53
+ Chef::Log.info("Added #{@new_resource} shortcut")
54
+ new_resource.updated_by_last_action(true)
55
+ end
56
+ end
@@ -0,0 +1,128 @@
1
+ #
2
+ # Author:: Paul Mooring (<paul@opscode.com>)
3
+ # Cookbook Name:: windows
4
+ # Provider:: task
5
+ #
6
+ # Copyright:: 2012, 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
+ require 'chef/mixin/shell_out'
22
+ include Chef::Mixin::ShellOut
23
+
24
+ action :create do
25
+ if @current_resource.exists
26
+ Chef::Log.info "#{@new_resource} task already exists - nothing to do"
27
+ else
28
+ if @new_resource.user and @new_resource.password.nil? then Chef::Log.debug "#{@new_resource} did not specify a password, creating task without a password" end
29
+ use_force = @new_resource.force ? '/F' : ''
30
+ cmd = "schtasks /Create #{use_force} /TN \"#{@new_resource.name}\" "
31
+ schedule = @new_resource.frequency == :on_logon ? "ONLOGON" : @new_resource.frequency
32
+ cmd += "/SC #{schedule} "
33
+ cmd += "/MO #{@new_resource.frequency_modifier} " if [:minute, :hourly, :daily, :weekly, :monthly].include?(@new_resource.frequency)
34
+ cmd += "/SD \"#{@new_resource.start_day}\" " unless @new_resource.start_day.nil?
35
+ cmd += "/ST \"#{@new_resource.start_time}\" " unless @new_resource.start_time.nil?
36
+ cmd += "/TR \"#{@new_resource.command}\" "
37
+ cmd += "/RU \"#{@new_resource.user}\" " if @new_resource.user
38
+ cmd += "/RP \"#{@new_resource.password}\" " if @new_resource.user and @new_resource.password
39
+ cmd += "/RL HIGHEST " if @new_resource.run_level == :highest
40
+ shell_out!(cmd, {:returns => [0]})
41
+ @new_resource.updated_by_last_action true
42
+ Chef::Log.info "#{@new_resource} task created"
43
+ end
44
+ end
45
+
46
+ action :run do
47
+ if @current_resource.exists
48
+ if @current_resource.status == :running
49
+ Chef::Log.info "#{@new_resource} task is currently running, skipping run"
50
+ else
51
+ cmd = "schtasks /Run /TN \"#{@current_resource.name}\""
52
+ shell_out!(cmd, {:returns => [0]})
53
+ @new_resource.updated_by_last_action true
54
+ Chef::Log.info "#{@new_resource} task ran"
55
+ end
56
+ else
57
+ Chef::Log.debug "#{@new_resource} task doesn't exists - nothing to do"
58
+ end
59
+ end
60
+
61
+ action :change do
62
+ if @current_resource.exists
63
+ cmd = "schtasks /Change /TN \"#{@current_resource.name}\" "
64
+ cmd += "/TR \"#{@new_resource.command}\" " if @new_resource.command
65
+ if @new_resource.user && @new_resource.password
66
+ cmd += "/RU \"#{@new_resource.user}\" /RP \"#{@new_resource.password}\" "
67
+ elsif (@new_resource.user and !@new_resource.password) || (@new_resource.password and !@new_resource.user)
68
+ Chef::Log.fatal "#{@new_resource.name}: Can't specify user or password without both!"
69
+ end
70
+ shell_out!(cmd, {:returns => [0]})
71
+ @new_resource.updated_by_last_action true
72
+ Chef::Log.info "Change #{@new_resource} task ran"
73
+ else
74
+ Chef::Log.debug "#{@new_resource} task doesn't exists - nothing to do"
75
+ end
76
+ end
77
+
78
+ action :delete do
79
+ if @current_resource.exists
80
+ use_force = @new_resource.force ? '/F' : ''
81
+ cmd = "schtasks /Delete #{use_force} /TN \"#{@current_resource.name}\""
82
+ shell_out!(cmd, {:returns => [0]})
83
+ @new_resource.updated_by_last_action true
84
+ Chef::Log.info "#{@new_resource} task deleted"
85
+ else
86
+ Chef::Log.debug "#{@new_resource} task doesn't exists - nothing to do"
87
+ end
88
+ end
89
+
90
+ def load_current_resource
91
+ @current_resource = Chef::Resource::WindowsTask.new(@new_resource.name)
92
+ @current_resource.name(@new_resource.name)
93
+
94
+ task_hash = load_task_hash(@current_resource.name)
95
+ if task_hash[:TaskName] == '\\' + @new_resource.name
96
+ @current_resource.exists = true
97
+ if task_hash[:Status] == "Running"
98
+ @current_resource.status = :running
99
+ end
100
+ @current_resource.cwd(task_hash[:Folder])
101
+ @current_resource.command(task_hash[:TaskToRun])
102
+ @current_resource.user(task_hash[:RunAsUser])
103
+ end if task_hash.respond_to? :[]
104
+ end
105
+
106
+ private
107
+
108
+ def load_task_hash(task_name)
109
+ Chef::Log.debug "looking for existing tasks"
110
+ output = `schtasks /Query /FO LIST /V /TN \"#{task_name}\" 2> NUL`
111
+ if output.empty?
112
+ task = false
113
+ else
114
+ task = Hash.new
115
+
116
+ output.split("\n").map! do |line|
117
+ line.split(":", 2).map! do |field|
118
+ field.strip
119
+ end
120
+ end.each do |field|
121
+ if field.kind_of? Array and field[0].respond_to? :to_sym
122
+ task[field[0].gsub(/\s+/,"").to_sym] = field[1]
123
+ end
124
+ end
125
+ end
126
+
127
+ task
128
+ end
@@ -0,0 +1,91 @@
1
+ #
2
+ # Author:: Doug MacEachern (<dougm@vmware.com>)
3
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
4
+ # Cookbook Name:: windows
5
+ # Provider:: unzip
6
+ #
7
+ # Copyright:: 2010, VMware, Inc.
8
+ # Copyright:: 2011, Opscode, Inc.
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ #
22
+
23
+ include Windows::Helper
24
+
25
+ require 'find'
26
+
27
+ action :unzip do
28
+ ensure_rubyzip_gem_installed
29
+ Chef::Log.debug("unzip #{@new_resource.source} => #{@new_resource.path} (overwrite=#{@new_resource.overwrite})")
30
+
31
+ Zip::File.open(cached_file(@new_resource.source, @new_resource.checksum)) do |zip|
32
+ zip.each do |entry|
33
+ path = ::File.join(@new_resource.path, entry.name)
34
+ FileUtils.mkdir_p(::File.dirname(path))
35
+ if @new_resource.overwrite && ::File.exists?(path) && !::File.directory?(path)
36
+ FileUtils.rm(path)
37
+ end
38
+ zip.extract(entry, path)
39
+ end
40
+ end
41
+ @new_resource.updated_by_last_action(true)
42
+ end
43
+
44
+ action :zip do
45
+ ensure_rubyzip_gem_installed
46
+ # sanitize paths for windows.
47
+ @new_resource.source.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR)
48
+ @new_resource.path.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR)
49
+ Chef::Log.debug("zip #{@new_resource.source} => #{@new_resource.path} (overwrite=#{@new_resource.overwrite})")
50
+
51
+ if @new_resource.overwrite == false && ::File.exists?(@new_resource.path)
52
+ Chef::Log.info("file #{@new_resource.path} already exists and overwrite is set to false, exiting")
53
+ else
54
+ # delete the archive if it already exists, because we are recreating it.
55
+ if ::File.exists?(@new_resource.path)
56
+ ::File.unlink(@new_resource.path)
57
+ end
58
+ # only supporting compression of a single directory (recursively).
59
+ if ::File.directory?(@new_resource.source)
60
+ z = Zip::File.new(@new_resource.path, true)
61
+ unless @new_resource.source =~ /::File::ALT_SEPARATOR$/
62
+ @new_resource.source << ::File::ALT_SEPARATOR
63
+ end
64
+ Find.find(@new_resource.source) do |f|
65
+ f.downcase.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR)
66
+ # don't add root directory to the zipfile.
67
+ next if f == @new_resource.source
68
+ # strip the root directory from the filename before adding it to the zipfile.
69
+ zip_fname = f.sub(@new_resource.source, '')
70
+ Chef::Log.debug("adding #{zip_fname} to archive, sourcefile is: #{f}")
71
+ z.add(zip_fname, f)
72
+ end
73
+ z.close
74
+ else
75
+ Chef::Log.info("Single directory must be specified for compression, and #{@new_resource.source} does not meet that criteria.")
76
+ end
77
+ end
78
+ end
79
+
80
+ private
81
+ def ensure_rubyzip_gem_installed
82
+ begin
83
+ require 'zip'
84
+ rescue LoadError
85
+ Chef::Log.info("Missing gem 'rubyzip'...installing now.")
86
+ chef_gem "rubyzip" do
87
+ version node['windows']['rubyzipversion']
88
+ end
89
+ require 'zip'
90
+ end
91
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: windows
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
+ # gems with precompiled binaries
22
+ %w{ win32-api win32-service }.each do |win_gem|
23
+ chef_gem win_gem do
24
+ options '--platform=mswin32'
25
+ action :install
26
+ end
27
+ end
28
+
29
+ # the rest
30
+ %w{ windows-api windows-pr win32-dir win32-event win32-mutex }.each do |win_gem|
31
+ chef_gem win_gem do
32
+ action :install
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: windows
4
+ # Recipe:: restart_handler
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
+ remote_directory node['chef_handler']['handler_path'] do
22
+ source 'handlers'
23
+ recursive true
24
+ action :create
25
+ end
26
+
27
+ chef_handler 'WindowsRebootHandler' do
28
+ source "#{node['chef_handler']['handler_path']}/windows_reboot_handler.rb"
29
+ arguments node['windows']['allow_pending_reboots']
30
+ supports :report => true, :exception => false
31
+ action :enable
32
+ end
@@ -0,0 +1,30 @@
1
+ #
2
+ # Author:: Paul Morotn (<pmorton@biaprotect.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: auto_run
5
+ #
6
+ # Copyright:: 2011, Business Intelligence Associates, 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
+ def initialize(name,run_context=nil)
22
+ super
23
+ @action = :create
24
+ end
25
+
26
+ actions :create, :remove
27
+
28
+ attribute :program, :kind_of => String
29
+ attribute :name, :kind_of => String, :name_attribute => true
30
+ attribute :args, :kind_of => String, :default => ''
@@ -0,0 +1,36 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: batch
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
+ actions :run
22
+
23
+ attribute :command, :kind_of => String, :name_attribute => true
24
+ attribute :cwd, :kind_of => String, :default => nil
25
+ attribute :code, :kind_of => String, :default => nil
26
+ attribute :user, :kind_of => [ String, Integer ], :default => nil
27
+ attribute :group, :kind_of => [ String, Integer ], :default => nil
28
+ attribute :creates, :kind_of => [ String ], :default => nil
29
+ attribute :flags, :kind_of => [ String ], :default => nil
30
+ attribute :returns, :kind_of => [Integer, Array], :default => 0
31
+
32
+ def initialize(name, run_context=nil)
33
+ super
34
+ @action = :run
35
+ @command = name
36
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: feature
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
+ include Windows::Helper
22
+
23
+ actions :install, :remove, :delete
24
+
25
+ attribute :feature_name, :kind_of => String, :name_attribute => true
26
+ attribute :source, :kind_of => String
27
+ attribute :all, :kind_of => [ TrueClass, FalseClass ], :default => false
28
+
29
+ def initialize(name, run_context=nil)
30
+ super
31
+ @action = :install
32
+ @provider = lookup_provider_constant(locate_default_provider)
33
+ end
34
+
35
+ private
36
+ def locate_default_provider
37
+ if node['windows'].attribute?(:feature_provider)
38
+ "windows_feature_#{node['windows']['feature_provider']}"
39
+ elsif ::File.exists?(locate_sysnative_cmd('dism.exe'))
40
+ :windows_feature_dism
41
+ elsif ::File.exists?(locate_sysnative_cmd('servermanagercmd.exe'))
42
+ :windows_feature_servermanagercmd
43
+ end
44
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: package
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
+ actions :install, :remove
22
+
23
+ default_action :install
24
+
25
+ attribute :package_name, :kind_of => String, :name_attribute => true
26
+ attribute :source, :kind_of => String, :required => true
27
+ attribute :version, :kind_of => String
28
+ attribute :options, :kind_of => String
29
+ attribute :installer_type, :kind_of => Symbol, :default => nil, :equal_to => [:msi, :inno, :nsis, :wise, :installshield, :custom]
30
+ attribute :checksum, :kind_of => String
31
+ attribute :timeout, :kind_of => Integer, :default => 600
32
+ attribute :success_codes, :kind_of => Array, :default => [0, 42, 127]
33
+
34
+ # TODO
35
+
36
+ # add preseeding support
37
+ #attribute :response_file
38
+
39
+ # allow target dirtory of installation to be set
40
+ #attribute :target_dir
41
+
42
+ # Covers 0.10.8 and earlier
43
+ def initialize(*args)
44
+ super
45
+ @action = :install
46
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # Author:: Kevin Moser (<kevin.moser@nordstrom.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: pagefile
5
+ #
6
+ # Copyright:: 2012, Nordstrom, 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
+ actions :set, :delete
22
+
23
+ attribute :name, :kind_of => String, :name_attribute => true
24
+ attribute :system_managed, :kind_of => [TrueClass, FalseClass]
25
+ attribute :automatic_managed, :kind_of => [TrueClass, FalseClass], :default => false
26
+ attribute :initial_size, :kind_of => Integer
27
+ attribute :maximum_size, :kind_of => Integer
28
+
29
+ default_action :set
@@ -0,0 +1,28 @@
1
+ #
2
+ # Author:: Paul Morotn (<pmorton@biaprotect.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: path
5
+ #
6
+ # Copyright:: 2011, Business Intelligence Associates, 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
+ def initialize(name,run_context=nil)
22
+ super
23
+ @action = :add
24
+ end
25
+
26
+ actions :add, :remove
27
+
28
+ attribute :path, :kind_of => String, :name_attribute => true
@@ -0,0 +1,41 @@
1
+ #
2
+ # Author:: Doug Ireton (<doug.ireton@nordstrom.com>)
3
+ # Cookbook Name:: windows
4
+ # Resource:: printer
5
+ #
6
+ # Copyright:: 2012, Nordstrom, 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
+ # See here for more info:
21
+ # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394492(v=vs.85).aspx
22
+
23
+ require 'resolv'
24
+
25
+ actions :create, :delete
26
+
27
+ default_action :create
28
+
29
+ attribute :device_id, :kind_of => String, :name_attribute => true,
30
+ :required => true
31
+ attribute :comment, :kind_of => String
32
+
33
+ attribute :default, :kind_of => [ TrueClass, FalseClass ], :default => false
34
+ attribute :driver_name, :kind_of => String, :required => true
35
+ attribute :location, :kind_of => String
36
+ attribute :shared, :kind_of => [ TrueClass, FalseClass ], :default => false
37
+ attribute :share_name, :kind_of => String
38
+
39
+ attribute :ipv4_address, :kind_of => String, :regex => Resolv::IPv4::Regex
40
+
41
+ attr_accessor :exists