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,665 @@
1
+ Windows Cookbook
2
+ ================
3
+ Provides a set of Windows-specific primitives (Chef resources) meant to aid in the creation of cookbooks/recipes targeting the Windows platform.
4
+
5
+
6
+ Requirements
7
+ -------------
8
+ Version 1.3.0+ of this cookbook requires Chef 0.10.10+.
9
+
10
+
11
+ ### Platforms
12
+ * Windows XP
13
+ * Windows Vista
14
+ * Windows Server 2003 R2
15
+ * Windows 7
16
+ * Windows Server 2008 (R1, R2)
17
+
18
+ The `windows_task` LWRP requires Windows Server 2008 due to its API usage.
19
+
20
+ ### Cookbooks
21
+ The following cookbooks provided by Opscode are required as noted:
22
+
23
+ * chef_handler (`windows::reboot_handler` leverages the chef_handler LWRP)
24
+
25
+ Attributes
26
+ ----------
27
+ * `node['windows']['allow_pending_reboots']` - used to configure the `WindowsRebootHandler` (via the `windows::reboot_handler` recipe) to act on pending reboots. default is true (ie act on pending reboots). The value of this attribute only has an effect if the `windows::reboot_handler` is in a node's run list.
28
+
29
+
30
+ Resource/Provider
31
+ -----------------
32
+ ### windows_auto_run
33
+ #### Actions
34
+ - :create: Create an item to be run at login
35
+ - :remove: Remove an item that was previously setup to run at login
36
+
37
+ #### Attribute Parameters
38
+ - :name: Name attribute. The name of the value to be stored in the registry
39
+ - :program: The program to be run at login
40
+ - :args: The arguments for the program
41
+
42
+ #### Examples
43
+ Run BGInfo at login
44
+
45
+ ```ruby
46
+ windows_auto_run 'BGINFO' do
47
+ program 'C:/Sysinternals/bginfo.exe'
48
+ args '\'C:/Sysinternals/Config.bgi\' /NOLICPROMPT /TIMER:0'
49
+ not_if { Registry.value_exists?(AUTO_RUN_KEY, 'BGINFO') }
50
+ action :create
51
+ end
52
+ ```
53
+
54
+ ### windows_batch
55
+ (Chef 11.6.0 includes a built-in [batch](http://docs.opscode.com/resource_batch.html) resource, so use that in preference to `windows_batch` if possible.)
56
+
57
+ Execute a batch script using the cmd.exe interpreter (much like the script resources for bash, csh, powershell, perl, python and ruby). A temporary file is created and executed like other script resources, rather than run inline. By their nature, Script resources are not idempotent, as they are completely up to the user's imagination. Use the `not_if` or `only_if` meta parameters to guard the resource for idempotence.
58
+
59
+ #### Actions
60
+ - :run: run the batch file
61
+
62
+ #### Attribute Parameters
63
+ - command: name attribute. Name of the command to execute.
64
+ - code: quoted string of code to execute.
65
+ - creates: a file this command creates - if the file exists, the command will not be run.
66
+ - cwd: current working directory to run the command from.
67
+ - flags: command line flags to pass to the interpreter when invoking.
68
+ - user: A user name or user ID that we should change to before running this command.
69
+ - group: A group name or group ID that we should change to before running this command.
70
+
71
+ #### Examples
72
+ ```ruby
73
+ windows_batch 'unzip_and_move_ruby' do
74
+ code <<-EOH
75
+ 7z.exe x #{Chef::Config[:file_cache_path]}/ruby-1.8.7-p352-i386-mingw32.7z -oC:\\source -r -y
76
+ xcopy C:\\source\\ruby-1.8.7-p352-i386-mingw32 C:\\ruby /e /y
77
+ EOH
78
+ end
79
+ ```
80
+
81
+ ```ruby
82
+ windows_batch 'echo some env vars' do
83
+ code <<-EOH
84
+ echo %TEMP%
85
+ echo %SYSTEMDRIVE%
86
+ echo %PATH%
87
+ echo %WINDIR%
88
+ EOH
89
+ end
90
+ ```
91
+
92
+ ### windows_feature
93
+ Windows Roles and Features can be thought of as built-in operating system packages that ship with the OS. A server role is a set of software programs that, when they are installed and properly configured, lets a computer perform a specific function for multiple users or other computers within a network. A Role can have multiple Role Services that provide functionality to the Role. Role services are software programs that provide the functionality of a role. Features are software programs that, although they are not directly parts of roles, can support or augment the functionality of one or more roles, or improve the functionality of the server, regardless of which roles are installed. Collectively we refer to all of these attributes as 'features'.
94
+
95
+ This resource allows you to manage these 'features' in an unattended, idempotent way.
96
+
97
+ There are two providers for the `windows_features` which map into Microsoft's two major tools for managing roles/features: [Deployment Image Servicing and Management (DISM)](http://msdn.microsoft.com/en-us/library/dd371719%28v=vs.85%29.aspx) and [Servermanagercmd](http://technet.microsoft.com/en-us/library/ee344834%28WS.10%29.aspx) (The CLI for Server Manager). As Servermanagercmd is deprecated, Chef will set the default provider to `Chef::Provider::WindowsFeature::DISM` if DISM is present on the system being configured. The default provider will fall back to `Chef::Provider::WindowsFeature::ServerManagerCmd`.
98
+
99
+ For more information on Roles, Role Services and Features see the [Microsoft TechNet article on the topic](http://technet.microsoft.com/en-us/library/cc754923.aspx). For a complete list of all features that are available on a node type either of the following commands at a command prompt:
100
+
101
+ ```text
102
+ dism /online /Get-Features
103
+ servermanagercmd -query
104
+ ```
105
+
106
+ #### Actions
107
+ - :install: install a Windows role/feature
108
+ - :remove: remove a Windows role/feature
109
+
110
+ #### Attribute Parameters
111
+ - feature_name: name of the feature/role to install. The same feature may have different names depending on the provider used (ie DHCPServer vs DHCP; DNS-Server-Full-Role vs DNS).
112
+ - all: Boolean. Optional. Default: false. DISM provider only. Forces all dependencies to be installed.
113
+ - source: String. Optional. DISM provider only. Uses local repository for feature install.
114
+
115
+ #### Providers
116
+ - **Chef::Provider::WindowsFeature::DISM**: Uses Deployment Image Servicing and Management (DISM) to manage roles/features.
117
+ - **Chef::Provider::WindowsFeature::ServerManagerCmd**: Uses Server Manager to manage roles/features.
118
+
119
+ #### Examples
120
+ Enable the node as a DHCP Server
121
+
122
+ ```ruby
123
+ windows_feature 'DHCPServer' do
124
+ action :install
125
+ end
126
+ ```
127
+
128
+ Enable TFTP
129
+
130
+ ```ruby
131
+ windows_feature 'TFTP' do
132
+ action :install
133
+ end
134
+ ```
135
+
136
+ Enable .Net 3.5.1 on Server 2012 using repository files on DVD and
137
+ install all dependencies
138
+
139
+ ```ruby
140
+ windows_feature "NetFx3" do
141
+ action :install
142
+ all true
143
+ source "d:\sources\sxs"
144
+ end
145
+ ```
146
+
147
+ Disable Telnet client/server
148
+
149
+ ```ruby
150
+ %w[TelnetServer TelnetClient].each do |feature|
151
+ windows_feature feature do
152
+ action :remove
153
+ end
154
+ end
155
+ ```
156
+
157
+ ### windows_package
158
+ Manage Windows application packages in an unattended, idempotent way.
159
+
160
+ The following application installers are currently supported:
161
+
162
+ * MSI packages
163
+ * InstallShield
164
+ * Wise InstallMaster
165
+ * Inno Setup
166
+ * Nullsoft Scriptable Install System
167
+
168
+ If the proper installer type is not passed into the resource's installer_type attribute, the provider will do it's best to identify the type by introspecting the installation package. If the installation type cannot be properly identified the `:custom` value can be passed into the installer_type attribute along with the proper flags for silent/quiet installation (using the `options` attribute..see example below).
169
+
170
+ __PLEASE NOTE__ - For proper idempotence the resource's `package_name` should be the same as the 'DisplayName' registry value in the uninstallation data that is created during package installation. The easiest way to definitively find the proper 'DisplayName' value is to install the package on a machine and search for the uninstall information under the following registry keys:
171
+
172
+ * `HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall`
173
+ * `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall`
174
+ * `HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall`
175
+
176
+ For maximum flexibility the `source` attribute supports both remote and local installation packages.
177
+
178
+ #### Actions
179
+ - :install: install a package
180
+ - :remove: remove a package. The remove action is completely hit or miss as many application uninstallers do not support a full silent/quiet mode.
181
+
182
+ #### Attribute Parameters
183
+ - package_name: name attribute. The 'DisplayName' of the application installation package.
184
+ - source: The source of the windows installer. This can either be a URI or a local path.
185
+ - installer_type: They type of windows installation package. valid values are: :msi, :inno, :nsis, :wise, :installshield, :custom. If this value is not provided, the provider will do it's best to identify the installer type through introspection of the file.
186
+ - checksum: useful if source is remote, the SHA-256 checksum of the file--if the local file matches the checksum, Chef will not download it
187
+ - options: Additional options to pass the underlying installation command
188
+ - timeout: set a timeout for the package download (default 600 seconds)
189
+ - version: The version number of this package, as indicated by the 'DisplayVersion' value in one of the 'Uninstall' registry keys. If the given version number does equal the 'DisplayVersion' in the registry, the package will be installed.
190
+ - success_codes: set an array of possible successful installation
191
+ return codes. Previously this was hardcoded, but certain MSIs may
192
+ have a different return code, e.g. 3010 for reboot required. Must be
193
+ an array, and defaults to `[0, 42, 127]`.
194
+
195
+ #### Examples
196
+
197
+ Install PuTTY (InnoSetup installer)
198
+ ```ruby
199
+ windows_package 'PuTTY version 0.60' do
200
+ source 'http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.60-installer.exe'
201
+ installer_type :inno
202
+ action :install
203
+ end
204
+ ```
205
+
206
+ Install 7-Zip (MSI installer)
207
+ ```ruby
208
+ windows_package '7-Zip 9.20 (x64 edition)' do
209
+ source 'http://downloads.sourceforge.net/sevenzip/7z920-x64.msi'
210
+ action :install
211
+ end
212
+ ```
213
+
214
+ Install Notepad++ (Y U No Emacs?) using a local installer
215
+ ```ruby
216
+ windows_package 'Notepad++' do
217
+ source 'c:/installation_files/npp.5.9.2.Installer.exe'
218
+ action :install
219
+ end
220
+ ```
221
+
222
+ Install VLC for that Xvid (NSIS installer)
223
+ ```ruby
224
+ windows_package 'VLC media player 1.1.10' do
225
+ source 'http://superb-sea2.dl.sourceforge.net/project/vlc/1.1.10/win32/vlc-1.1.10-win32.exe'
226
+ action :install
227
+ end
228
+ ```
229
+
230
+ Install Firefox as custom installer and manually set the silent install flags
231
+ ```ruby
232
+ windows_package 'Mozilla Firefox 5.0 (x86 en-US)' do
233
+ source 'http://archive.mozilla.org/pub/mozilla.org/mozilla.org/firefox/releases/5.0/win32/en-US/Firefox%20Setup%205.0.exe'
234
+ options '-ms'
235
+ installer_type :custom
236
+ action :install
237
+ end
238
+ ```
239
+
240
+ Google Chrome FTW (MSI installer)
241
+ ```ruby
242
+ windows_package 'Google Chrome' do
243
+ source 'https://dl-ssl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B806F36C0-CB54-4A84-A3F3-0CF8A86575E0%7D%26lang%3Den%26browser%3D3%26usagestats%3D0%26appname%3DGoogle%2520Chrome%26needsadmin%3Dfalse/edgedl/chrome/install/GoogleChromeStandaloneEnterprise.msi'
244
+ action :install
245
+ end
246
+ ```
247
+
248
+ Remove Google Chrome
249
+ ```ruby
250
+ windows_package 'Google Chrome' do
251
+ action :remove
252
+ end
253
+ ```
254
+
255
+ Remove 7-Zip
256
+ ```ruby
257
+ windows_package '7-Zip 9.20 (x64 edition)' do
258
+ action :remove
259
+ end
260
+ ```
261
+
262
+ ### windows_printer_port
263
+
264
+ Create and delete TCP/IPv4 printer ports.
265
+
266
+ #### Actions
267
+ - :create: Create a TCIP/IPv4 printer port. This is the default action.
268
+ - :delete: Delete a TCIP/IPv4 printer port
269
+
270
+ #### Attribute Parameters
271
+ - :ipv4_address: Name attribute. Required. IPv4 address, e.g. '10.0.24.34'
272
+ - :port_name: Port name. Optional. Defaults to 'IP_' + :ipv4_address
273
+ - :port_number: Port number. Optional. Defaults to 9100.
274
+ - :port_description: Port description. Optional.
275
+ - :snmp_enabled: Boolean. Optional. Defaults to false.
276
+ - :port_protocol: Port protocol, 1 (RAW), or 2 (LPR). Optional. Defaults to 1.
277
+
278
+ #### Examples
279
+
280
+ Create a TCP/IP printer port named 'IP_10.4.64.37' with all defaults
281
+ ```ruby
282
+ windows_printer_port '10.4.64.37' do
283
+ end
284
+ ```
285
+
286
+ Delete a printer port
287
+ ```ruby
288
+ windows_printer_port '10.4.64.37' do
289
+ action :delete
290
+ end
291
+ ```
292
+
293
+ Delete a port with a custom port_name
294
+ ```ruby
295
+ windows_printer_port '10.4.64.38' do
296
+ port_name 'My awesome port'
297
+ action :delete
298
+ end
299
+ ```
300
+
301
+ Create a port with more options
302
+ ```ruby
303
+ windows_printer_port '10.4.64.39' do
304
+ port_name 'My awesome port'
305
+ snmp_enabled true
306
+ port_protocol 2
307
+ end
308
+ ```
309
+
310
+ ### windows_printer
311
+
312
+ Create Windows printer. Note that this doesn't currently install a printer
313
+ driver. You must already have the driver installed on the system.
314
+
315
+ The Windows Printer LWRP will automatically create a TCP/IP printer port for you using the `ipv4_address` property. If you want more granular control over the printer port, just create it using the `windows_printer_port` LWRP before creating the printer.
316
+
317
+ #### Actions
318
+ - :create: Create a new printer
319
+ - :delete: Delete a new printer
320
+
321
+ #### Attribute Parameters
322
+ - :device_id: Name attribute. Required. Printer queue name, e.g. 'HP LJ 5200 in fifth floor copy room'
323
+ - :comment: Optional string describing the printer queue.
324
+ - :default: Boolean. Optional. Defaults to false. Note that Windows sets the first printer defined to the default printer regardless of this setting.
325
+ - :driver_name: String. Required. Exact name of printer driver. Note that the printer driver must already be installed on the node.
326
+ - :location: Printer location, e.g. 'Fifth floor copy room', or 'US/NYC/Floor42/Room4207'
327
+ - :shared: Boolean. Defaults to false.
328
+ - :share_name: Printer share name.
329
+ - :ipv4_address: Printer IPv4 address, e.g. '10.4.64.23'. You don't have to be able to ping the IP addresss to set it. Required.
330
+
331
+ An error of "Set-WmiInstance : Generic failure" is most likely due to the printer driver name not matching or not being installed.
332
+
333
+ #### Examples
334
+
335
+ Create a printer
336
+ ```ruby
337
+ windows_printer 'HP LaserJet 5th Floor' do
338
+ driver_name 'HP LaserJet 4100 Series PCL6'
339
+ ipv4_address '10.4.64.38'
340
+ end
341
+ ```
342
+
343
+ Delete a printer. Note: this doesn't delete the associated printer port. See `windows_printer_port` above for how to delete the port.
344
+ ```ruby
345
+ windows_printer 'HP LaserJet 5th Floor' do
346
+ action :delete
347
+ end
348
+ ```
349
+
350
+ ### windows_reboot
351
+ Sets required data in the node's run_state to notify `WindowsRebootHandler` a reboot is requested. If Chef run completes successfully a reboot will occur if the `WindowsRebootHandler` is properly registered as a report handler. As an action of `:request` will cause a node to reboot every Chef run, this resource is usually notified by other resources...ie restart node after a package is installed (see example below).
352
+
353
+ #### Actions
354
+ - :request: requests a reboot at completion of successful Cher run. requires `WindowsRebootHandler` to be registered as a report handler.
355
+ - :cancel: remove reboot request from node.run_state. this will cancel *ALL* previously requested reboots as this is a binary state.
356
+
357
+ #### Attribute Parameters
358
+ - :timeout: Name attribute. timeout delay in seconds to wait before proceeding with the requested reboot. default is 60 seconds
359
+ - :reason: comment on the reason for the reboot. default is 'Opscode Chef initiated reboot'
360
+
361
+ #### Examples
362
+ If the package installs, schedule a reboot at end of chef run
363
+ ```ruby
364
+ windows_reboot 60 do
365
+ reason 'cause chef said so'
366
+ action :nothing
367
+ end
368
+
369
+ windows_package 'some_package' do
370
+ action :install
371
+ notifies :request, 'windows_reboot[60]'
372
+ end
373
+ ```
374
+
375
+ Cancel the previously requested reboot
376
+ ```ruby
377
+ windows_reboot 60 do
378
+ action :cancel
379
+ end
380
+ ```
381
+
382
+ ### windows_registry
383
+ (Chef 11.6.0 includes a built-in [registry_key](http://docs.opscode.com/resource_registry_key.html) resource, so use that in preference to `windows_registry` if possible.)
384
+
385
+ Creates and modifies Windows registry keys.
386
+
387
+ *Change in v1.3.0: The Win32 classes use `::Win32` to avoid namespace conflict with `Chef::Win32` (introduced in Chef 0.10.10).*
388
+
389
+ #### Actions
390
+ - :create: create a new registry key with the provided values.
391
+ - :modify: modify an existing registry key with the provided values.
392
+ - :force_modify: modify an existing registry key with the provided values. ensures the value is actually set by checking multiple times. useful for fighting race conditions where two processes are trying to set the same registry key. This will be updated in the near future to use 'RegNotifyChangeKeyValue' which is exposed by the WinAPI and allows a process to register for notification on a registry key change.
393
+ - :remove: removes a value from an existing registry key
394
+
395
+ #### Attribute Parameters
396
+ - key_name: name attribute. The registry key to create/modify.
397
+ - values: hash of the values to set under the registry key. The individual hash items will become respective 'Value name' => 'Value data' items in the registry key.
398
+ - type: Type of key to create, defaults to REG_SZ. Must be a symbol, see the overview below for valid values.
399
+
400
+ #### Registry key types
401
+ - :binary: REG_BINARY
402
+ - :string: REG_SZ
403
+ - :multi_string: REG_MULTI_SZ
404
+ - :expand_string: REG_EXPAND_SZ
405
+ - :dword: REG_DWORD
406
+ - :dword_big_endian: REG_DWORD_BIG_ENDIAN
407
+ - :qword: REG_QWORD
408
+
409
+ #### Examples
410
+
411
+ Make the local windows proxy match the one set for Chef
412
+ ```ruby
413
+ proxy = URI.parse(Chef::Config[:http_proxy])
414
+ windows_registry 'HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings' do
415
+ values 'ProxyEnable' => 1, 'ProxyServer' => "#{proxy.host}:#{proxy.port}", 'ProxyOverride' => '<local>'
416
+ end
417
+ ```
418
+
419
+ Enable Remote Desktop and poke the firewall hole
420
+ ```ruby
421
+ windows_registry 'HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server' do
422
+ values 'FdenyTSConnections' => 0
423
+ end
424
+ ```
425
+
426
+ Delete an item from the registry
427
+ ```ruby
428
+ windows_registry 'HKCU\Software\Test' do
429
+ #Key is the name of the value that you want to delete the value is always empty
430
+ values 'ValueToDelete' => ''
431
+ action :remove
432
+ end
433
+ ```
434
+
435
+ Add a REG_MULTI_SZ value to the registry
436
+ ```ruby
437
+ windows_registry 'HKCU\Software\Test' do
438
+ values 'MultiString' => ['line 1', 'line 2', 'line 3']
439
+ type :multi_string
440
+ end
441
+ ```
442
+
443
+ #### Library Methods
444
+
445
+ ```ruby
446
+ Registry.value_exists?('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run','BGINFO')
447
+ Registry.key_exists?('HKLM\SOFTWARE\Microsoft')
448
+ BgInfo = Registry.get_value('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run','BGINFO')
449
+ ```
450
+
451
+ ### windows_path
452
+ #### Actions
453
+ - :add: Add an item to the system path
454
+ - :remove: Remove an item from the system path
455
+
456
+ #### Attribute Parameters
457
+ - :path: Name attribute. The name of the value to add to the system path
458
+
459
+ #### Examples
460
+
461
+ Add Sysinternals to the system path
462
+ ```ruby
463
+ windows_path 'C:\Sysinternals' do
464
+ action :add
465
+ end
466
+ ```
467
+
468
+ Remove 7-Zip from the system path
469
+ ```ruby
470
+ windows_path 'C:\7-Zip' do
471
+ action :remove
472
+ end
473
+ ```
474
+
475
+ ### windows_task
476
+ Creates, deletes or runs a Windows scheduled task. Requires Windows
477
+ Server 2008 due to API usage.
478
+
479
+ #### Actions
480
+ - :create: creates a task
481
+ - :delete: deletes a task
482
+ - :run: runs a task
483
+ - :change: changes the un/pw or command of a task
484
+
485
+ #### Attribute Parameters
486
+ - name: name attribute, The task name.
487
+ - command: The command the task will run.
488
+ - cwd: The directory the task will be run from.
489
+ - user: The user to run the task as. (requires password)
490
+ - password: The user's password. (requires user)
491
+ - run_level: Run with limited or highest privileges.
492
+ - frequency: Frequency with which to run the task. (hourly, daily, ect.)
493
+ - frequency_modifier: Multiple for frequency. (15 minutes, 2 days)
494
+ - start_day: Specifies the first date on which the task runs. Optional string (MM/DD/YYYY)
495
+ - start_time: Specifies the start time to run the task. Optional string (HH:mm)
496
+
497
+ #### Examples
498
+
499
+ Run Chef every 15 minutes
500
+ ```ruby
501
+ windows_task 'Chef client' do
502
+ user 'Administrator'
503
+ password '$ecR3t'
504
+ cwd 'C:\chef\bin'
505
+ command 'chef-client -L C:\tmp\'
506
+ run_level :highest
507
+ frequency :minute
508
+ frequency_modifier 15
509
+ end
510
+ ```
511
+
512
+ Update Chef Client task with new password and log location
513
+ ```ruby
514
+ windows_task 'Chef client' do
515
+ user 'Administrator'
516
+ password 'N3wPassW0Rd'
517
+ cwd 'C:\chef\bin'
518
+ command 'chef-client -L C:\chef\logs\'
519
+ action :change
520
+ end
521
+ ```
522
+
523
+ Delete a taks named 'old task'
524
+ ```ruby
525
+ windows_task 'old task' do
526
+ action :delete
527
+ end
528
+ ```
529
+
530
+ ### windows_zipfile
531
+ Most version of Windows do not ship with native cli utility for managing compressed files. This resource provides a pure-ruby implementation for managing zip files. Be sure to use the `not_if` or `only_if` meta parameters to guard the resource for idempotence or action will be taken on the zip file every Chef run.
532
+
533
+ #### Actions
534
+ - :unzip: unzip a compressed file
535
+
536
+ #### Attribute Parameters
537
+ - path: name attribute. The path where files will be unzipped to.
538
+ - source: The source of the zip file. This can either be a URI or a local path.
539
+ - overwrite: force an overwrite of the files if the already exists.
540
+ - checksum: useful if source is remote, the SHA-256 checksum of the file--if the local file matches the checksum, Chef will not download it
541
+
542
+ #### Examples
543
+
544
+ Unzip a remote zip file locally
545
+ ```ruby
546
+ windows_zipfile 'c:/bin' do
547
+ source 'http://download.sysinternals.com/Files/SysinternalsSuite.zip'
548
+ action :unzip
549
+ not_if {::File.exists?('c:/bin/PsExec.exe')}
550
+ end
551
+ ```
552
+
553
+ Unzip a local zipfile
554
+ ```ruby
555
+ windows_zipfile 'c:/the_codez' do
556
+ source 'c:/foo/baz/the_codez.zip'
557
+ action :unzip
558
+ end
559
+ ```
560
+
561
+
562
+ Exception/Report Handlers
563
+ -------------------------
564
+ ### WindowsRebootHandler
565
+ Required reboots are a necessary evil of configuring and managing Windows nodes. This report handler (ie fires at the end of successful Chef runs) acts on requested (Chef initiated) or pending (as determined by the OS per configuration action we performed) reboots. The `allow_pending_reboots` initialization argument should be set to false if you do not want the handler to automatically reboot a node if it has been determined a reboot is pending. Reboots can still be requested explicitly via the `windows_reboot` LWRP.
566
+
567
+ ### Initialization Arguments
568
+ - `allow_pending_reboots`: indicator on whether the handler should act on a the Window's 'pending reboot' state. default is true
569
+ - `timeout`: timeout delay in seconds to wait before proceeding with the reboot. default is 60 seconds
570
+ - `reason`: comment on the reason for the reboot. default is 'Opscode Chef initiated reboot'
571
+
572
+
573
+ Windows ChefSpec Matchers
574
+ -------------------------
575
+ The Windows cookbook includes custom [ChefSpec](https://github.com/sethvargo/chefspec) matchers you can use to test your own cookbooks that consume Windows cookbook LWRPs.
576
+
577
+ ###Example Matcher Usage
578
+ ```ruby
579
+ expect(chef_run).to install_windows_package('Node.js').with(
580
+ source: 'http://nodejs.org/dist/v0.10.26/x64/node-v0.10.26-x64.msi')
581
+ ```
582
+
583
+ ###Windows Cookbook Matchers
584
+ * install_windows_package
585
+ * remove_windows_package
586
+ * install_windows_feature
587
+ * remove_windows_feature
588
+ * delete_windows_feature
589
+ * create_windows_task
590
+ * delete_windows_task
591
+ * run_windows_task
592
+ * change_windows_task
593
+ * add_windows_path
594
+ * remove_windows_path
595
+ * run_windows_batch
596
+ * set_windows_pagefile
597
+ * unzip_windows_zipfile_to
598
+ * zip_windows_zipfile_to
599
+ * create_windows_shortcut
600
+ * create_windows_auto_run
601
+ * remove_windows_auto_run
602
+ * create_windows_printer
603
+ * delete_windows_printer
604
+ * create_windows_printer_port
605
+ * delete_windows_printer_port
606
+ * request_windows_reboot
607
+ * cancel_windows_reboot
608
+ * create_windows_shortcut
609
+
610
+
611
+ Usage
612
+ -----
613
+
614
+ Place an explicit dependency on this cookbook (using depends in the cookbook's metadata.rb) from any cookbook where you would like to use the Windows-specific resources/providers that ship with this cookbook.
615
+
616
+ ```ruby
617
+ depends 'windows'
618
+ ```
619
+
620
+ ### default
621
+ Convenience recipe that installs supporting gems for many of the resources/providers that ship with this cookbook.
622
+
623
+ *Change in v1.3.0: Uses chef_gem instead of gem_package to ensure gem installation in Chef 0.10.10.*
624
+
625
+ ### reboot_handler
626
+ Leverages the `chef_handler` LWRP to register the `WindowsRebootHandler` report handler that ships as part of this cookbook. By default this handler is set to automatically act on pending reboots. If you would like to change this behavior override `node['windows']['allow_pending_reboots']` and set the value to false. For example:
627
+
628
+ ```ruby
629
+ name 'base'
630
+ description 'base role'
631
+ override_attributes(
632
+ 'windows' => {
633
+ 'allow_pending_reboots' => false
634
+ }
635
+ )
636
+ ```
637
+
638
+ This will still allow a reboot to be explicitly requested via the `windows_reboot` LWRP.
639
+
640
+
641
+ License & Authors
642
+ -----------------
643
+ - Author:: Seth Chisamore (<schisamo@opscode.com>)
644
+ - Author:: Doug MacEachern (<dougm@vmware.com>)
645
+ - Author:: Paul Morton (<pmorton@biaprotect.com>)
646
+ - Author:: Doug Ireton (<doug.ireton@nordstrom.com>)
647
+
648
+ ```text
649
+ Copyright 2011-2013, Opscode, Inc.
650
+ Copyright 2010, VMware, Inc.
651
+ Copyright 2011, Business Intelligence Associates, Inc
652
+ Copyright 2012, Nordstrom, Inc.
653
+
654
+ Licensed under the Apache License, Version 2.0 (the "License");
655
+ you may not use this file except in compliance with the License.
656
+ You may obtain a copy of the License at
657
+
658
+ http://www.apache.org/licenses/LICENSE-2.0
659
+
660
+ Unless required by applicable law or agreed to in writing, software
661
+ distributed under the License is distributed on an "AS IS" BASIS,
662
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
663
+ See the License for the specific language governing permissions and
664
+ limitations under the License.
665
+ ```
@@ -0,0 +1,23 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Cookbook Name:: windows
4
+ # Attribute:: 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
+ default['windows']['allow_pending_reboots'] = true
22
+ default['windows']['rubyzipversion'] = nil
23
+ default['windows']['reboot_timeout'] = 60