madscience 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/Cheffile +3 -1
  3. data/Cheffile.lock +11 -11
  4. data/README.md +47 -31
  5. data/bin/madscience +85 -37
  6. data/cookbooks/apt/CHANGELOG.md +4 -1
  7. data/cookbooks/apt/README.md +1 -0
  8. data/cookbooks/apt/metadata.json +2 -2
  9. data/cookbooks/apt/providers/preference.rb +10 -1
  10. data/cookbooks/apt/recipes/unattended-upgrades.rb +4 -0
  11. data/cookbooks/vagrant/Berksfile +7 -1
  12. data/cookbooks/vagrant/CHANGELOG.md +4 -0
  13. data/cookbooks/vagrant/README.md +36 -27
  14. data/cookbooks/vagrant/attributes/default.rb +1 -0
  15. data/cookbooks/vagrant/libraries/helpers.rb +24 -1
  16. data/cookbooks/vagrant/metadata.rb +6 -4
  17. data/cookbooks/vagrant/providers/plugin.rb +38 -8
  18. data/cookbooks/vagrant/recipes/default.rb +1 -14
  19. data/cookbooks/vagrant/recipes/install_plugins.rb +35 -0
  20. data/cookbooks/vagrant/recipes/mac_os_x.rb +0 -16
  21. data/cookbooks/vagrant/resources/plugin.rb +2 -0
  22. data/cookbooks/vagrant/test/fixtures/cookbooks/test/README.md +4 -0
  23. data/cookbooks/vagrant/test/fixtures/cookbooks/test/metadata.rb +2 -0
  24. data/cookbooks/vagrant/test/fixtures/cookbooks/test/recipes/default.rb +18 -0
  25. data/cookbooks/virtualbox/recipes/default.rb +1 -1
  26. data/cookbooks/windows/CHANGELOG.md +45 -24
  27. data/cookbooks/windows/README.md +47 -8
  28. data/cookbooks/windows/attributes/default.rb +3 -3
  29. data/cookbooks/windows/files/default/handlers/windows_reboot_handler.rb +4 -4
  30. data/cookbooks/windows/libraries/feature_base.rb +1 -1
  31. data/cookbooks/windows/libraries/powershell_helper.rb +2 -2
  32. data/cookbooks/windows/libraries/registry_helper.rb +2 -2
  33. data/cookbooks/windows/libraries/version.rb +2 -2
  34. data/cookbooks/windows/libraries/windows_helper.rb +48 -2
  35. data/cookbooks/windows/libraries/windows_package.rb +0 -42
  36. data/cookbooks/windows/libraries/wmi_helper.rb +1 -1
  37. data/cookbooks/windows/metadata.json +5 -13
  38. data/cookbooks/windows/providers/auto_run.rb +1 -1
  39. data/cookbooks/windows/providers/batch.rb +2 -2
  40. data/cookbooks/windows/providers/feature_dism.rb +2 -2
  41. data/cookbooks/windows/providers/feature_servermanagercmd.rb +2 -2
  42. data/cookbooks/windows/providers/pagefile.rb +1 -1
  43. data/cookbooks/windows/providers/path.rb +1 -1
  44. data/cookbooks/windows/providers/reboot.rb +2 -2
  45. data/cookbooks/windows/providers/registry.rb +2 -2
  46. data/cookbooks/windows/providers/task.rb +2 -2
  47. data/cookbooks/windows/providers/zipfile.rb +3 -2
  48. data/cookbooks/windows/recipes/default.rb +2 -2
  49. data/cookbooks/windows/recipes/reboot_handler.rb +2 -2
  50. data/cookbooks/windows/resources/batch.rb +2 -2
  51. data/cookbooks/windows/resources/feature.rb +2 -2
  52. data/cookbooks/windows/resources/pagefile.rb +1 -1
  53. data/cookbooks/windows/resources/reboot.rb +2 -2
  54. data/cookbooks/windows/resources/registry.rb +2 -2
  55. data/cookbooks/windows/resources/task.rb +2 -2
  56. data/cookbooks/windows/resources/zipfile.rb +2 -2
  57. data/cookbooks/yum/CHANGELOG.md +8 -0
  58. data/cookbooks/yum/attributes/main.rb +3 -0
  59. data/cookbooks/yum/metadata.json +1 -1
  60. data/cookbooks/yum/templates/default/main.erb +4 -1
  61. data/lib/madscience/version.rb +1 -1
  62. data/site-cookbooks/madscience-vagrant-cookbook/recipes/default.rb +10 -3
  63. metadata +6 -11
  64. data/cookbooks/apt/metadata.rb +0 -34
  65. data/cookbooks/windows/Berksfile +0 -7
  66. data/cookbooks/windows/CONTRIBUTING +0 -46
  67. data/cookbooks/windows/Gemfile +0 -14
  68. data/cookbooks/windows/LICENSE +0 -201
  69. data/cookbooks/windows/TODO.md +0 -6
  70. data/cookbooks/windows/chefignore +0 -2
  71. data/cookbooks/windows/metadata.rb +0 -9
  72. data/cookbooks/yum/metadata.rb +0 -12
@@ -32,7 +32,7 @@ def vagrant_platform_package(vers = nil)
32
32
  case node['platform_family']
33
33
  when 'debian'
34
34
  "vagrant_#{vers}_x86_64.deb"
35
- when 'redhat', 'fedora'
35
+ when 'fedora', 'rhel'
36
36
  "vagrant_#{vers}_x86_64.rpm"
37
37
  end
38
38
  end
@@ -48,3 +48,26 @@ end
48
48
  def vagrant_package_uri(vers = nil)
49
49
  URI.join(vagrant_base_uri, vagrant_platform_package(vers)).to_s
50
50
  end
51
+
52
+ def vagrant_get_home(user)
53
+ begin
54
+ # Attempting to get the $HOME of `user`
55
+ Chef::Log.debug("Attempting to get $HOME of #{user}")
56
+ home = Etc.getpwnam(user).dir
57
+ rescue ArgumentError
58
+ begin
59
+ # Could not look up `user`, seeing if Chef knows about a
60
+ # user[`user`] resource
61
+ Chef::Log.debug("Couldn't find `#{user}`, looking for a resource")
62
+ home = resources("user[#{user}]").home
63
+ rescue Chef::Exceptions::ResourceNotFound
64
+ # Chef does not know about a user[`user`] resource, and that
65
+ # user does not exist on the system, try using the $HOME of the
66
+ # user running Chef
67
+ Chef::Log.debug("No user found, using running process uid, `#{Process.uid}`")
68
+ home = Etc.getpwuid(Process.uid).dir
69
+ end
70
+ end
71
+
72
+ home
73
+ end
@@ -3,12 +3,14 @@ maintainer 'Joshua Timberman'
3
3
  maintainer_email 'cookbooks@housepub.org'
4
4
  license 'Apache 2.0'
5
5
  description 'Installs/Configures vagrant'
6
- long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
- version '0.2.1'
6
+ version '0.2.2'
8
7
 
9
8
  supports 'debian', '>= 6.0'
10
9
  supports 'ubuntu', '>= 12.04'
11
10
  supports 'redhat', '>= 6.3'
11
+ supports 'centos', '>= 6.4'
12
+ supports 'windows'
13
+ supports 'mac_os_x'
12
14
 
13
- depends "dmg"
14
- depends "windows"
15
+ depends 'dmg'
16
+ depends 'windows'
@@ -1,12 +1,22 @@
1
+ require 'etc'
1
2
  require 'chef/mixin/shell_out'
2
3
  include Chef::Mixin::ShellOut
3
4
 
5
+ use_inline_resources if defined?(:use_inline_resources)
6
+
4
7
  def load_current_resource
5
8
  @current_resource = Chef::Resource::VagrantPlugin.new(new_resource)
6
- vp = shell_out("vagrant plugin list")
9
+ vp = shell_out('vagrant plugin list', {
10
+ :user => run_as_user,
11
+ :env => {
12
+ 'VAGRANT_HOME' => vagrant_home
13
+ }
14
+ })
7
15
  if vp.stdout.include?(new_resource.plugin_name)
8
16
  @current_resource.installed(true)
9
- @current_resource.installed_version(vp.stdout.split[1].gsub(/[\(\)]/, ''))
17
+ installed_line = vp.stdout.split("\n").detect { |line| line.include? new_resource.plugin_name }
18
+ installed_version = installed_line.split('(')[1].split(')')[0]
19
+ @current_resource.installed_version(installed_line.gsub(/[\(\)]/, ''))
10
20
  end
11
21
  @current_resource
12
22
  end
@@ -15,23 +25,43 @@ action :install do
15
25
  unless installed?
16
26
  plugin_args = ""
17
27
  plugin_args += "--plugin-version #{new_resource.version}" if new_resource.version
18
- shell_out("vagrant plugin install #{new_resource.plugin_name} #{plugin_args}")
19
- new_resource.updated_by_last_action(true)
28
+
29
+ unless new_resource.sources.empty?
30
+ sources = Array(new_resource.sources)
31
+ sources.each do |source|
32
+ plugin_args += " --plugin-source #{source}"
33
+ end
34
+ end
35
+
36
+ execute "installing vagrant plugin #{new_resource.plugin_name}" do
37
+ command "vagrant plugin install #{new_resource.plugin_name} #{plugin_args}"
38
+ user new_resource.user
39
+ environment 'VAGRANT_HOME' => vagrant_home
40
+ end
20
41
  end
21
42
  end
22
43
 
23
44
  action :remove do
24
45
  uninstall if @current_resource.installed
25
- new_resource.updated_by_last_action(true)
26
46
  end
27
47
 
28
48
  action :uninstall do
29
49
  uninstall if @current_resource.installed
30
- new_resource.updated_by_last_action(true)
31
50
  end
32
51
 
33
52
  def uninstall
34
- shell_out("vagrant plugin uninstall #{new_resource.plugin_name}")
53
+ execute "vagrant plugin uninstall #{new_resource.plugin_name}" do
54
+ user new_resource.user
55
+ environment 'VAGRANT_HOME' => vagrant_home
56
+ end
57
+ end
58
+
59
+ def run_as_user
60
+ new_resource.user || Etc.getpwuid(Process.uid).name
61
+ end
62
+
63
+ def vagrant_home
64
+ ::File.join(vagrant_get_home(run_as_user), '.vagrant.d')
35
65
  end
36
66
 
37
67
  def installed?
@@ -42,7 +72,7 @@ def version_match
42
72
  # if the version is specified, we need to check if it matches what
43
73
  # is installed already
44
74
  if new_resource.version
45
- @current_resource.installed_version == new_resource.version
75
+ @current_resource.installed_version == "#{new_resource.plugin_name} #{new_resource.version}"
46
76
  else
47
77
  # the version matches otherwise because it's installed
48
78
  true
@@ -18,17 +18,4 @@
18
18
  #
19
19
 
20
20
  include_recipe "vagrant::#{node['platform_family']}"
21
-
22
- node['vagrant']['plugins'].each do |plugin|
23
- if plugin.respond_to?(:keys)
24
-
25
- vagrant_plugin plugin['name'] do
26
- version plugin['version']
27
- end
28
-
29
- else
30
-
31
- vagrant_plugin plugin
32
-
33
- end
34
- end
21
+ include_recipe 'vagrant::install_plugins' if node['vagrant']['plugins'].length > 0
@@ -0,0 +1,35 @@
1
+ #
2
+ # Cookbook Name:: vagrant
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2013, Joshua Timberman
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ node['vagrant']['plugins'].each do |plugin|
21
+ if plugin.respond_to?(:keys)
22
+
23
+ vagrant_plugin plugin['name'] do
24
+ user node['vagrant']['user']
25
+ version plugin['version']
26
+ end
27
+
28
+ else
29
+
30
+ vagrant_plugin plugin do
31
+ user node['vagrant']['user']
32
+ end
33
+
34
+ end
35
+ end
@@ -1,19 +1,3 @@
1
- execute "uninstall Vagrant" do
2
- # This is the recommended way to uninstall Vagrant on Mac OS X:
3
- # https://docs.vagrantup.com/v2/installation/uninstallation.html
4
- command <<-CMD
5
- rm -rf /Applications/Vagrant /usr/bin/vagrant &&
6
- pkgutil --forget com.vagrant.vagrant
7
- CMD
8
- not_if {
9
- # Do not uninstall if Vagrant isn't installed.
10
- # Do not uninstall if there is no specified version,
11
- # or if the version requested matches the one installed.
12
- ver = node['vagrant']['version']
13
- !File.exists?('/usr/bin/vagrant') || !ver || `vagrant --version`[ver]
14
- }
15
- end
16
-
17
1
  dmg_package "Vagrant" do
18
2
  source node['vagrant']['url']
19
3
  checksum node['vagrant']['checksum']
@@ -6,3 +6,5 @@ attribute :plugin_name, :name_attribute => true
6
6
  attribute :version, :kind_of => [String]
7
7
  attribute :installed, :kind_of => [TrueClass, FalseClass]
8
8
  attribute :installed_version, :kind_of => [String]
9
+ attribute :user, :kind_of => [String], :default => nil
10
+ attribute :sources, :kind_of => [String, Array], :default => ''
@@ -0,0 +1,4 @@
1
+ # test
2
+
3
+ This cookbook is used for testing the `vagrant` cookbook.
4
+
@@ -0,0 +1,2 @@
1
+ name 'test'
2
+ version '0.1.0'
@@ -0,0 +1,18 @@
1
+ # How meta...
2
+ vagrant_plugin 'vagrant-aws' do
3
+ user 'vagrant'
4
+ end
5
+
6
+ # A user that doesn't exist...
7
+ user 'donuts' do
8
+ shell '/bin/bash'
9
+ home '/home/donuts'
10
+ supports :manage_home => true
11
+ end
12
+
13
+ # And a version of vagrant-aws not used previously in this run, just
14
+ # to be sure.
15
+ vagrant_plugin 'vagrant-aws' do
16
+ version '0.4.1'
17
+ user 'donuts'
18
+ end
@@ -25,7 +25,7 @@ when 'mac_os_x'
25
25
  dmg_package 'VirtualBox' do
26
26
  source node['virtualbox']['url']
27
27
  checksum sha256sum
28
- type 'mpkg'
28
+ type 'pkg'
29
29
  end
30
30
 
31
31
  when 'windows'
@@ -2,36 +2,57 @@ windows Cookbook CHANGELOG
2
2
  =======================
3
3
  This file is used to list changes made in each version of the windows cookbook.
4
4
 
5
+ v1.36.6 (2014-12-18)
6
+ --------------------
7
+ - reverting all chef_gem compile_time work
8
+
9
+ v1.36.5 (2014-12-18)
10
+ --------------------
11
+ - Fix zipfile provider
12
+
13
+ v1.36.4 (2014-12-18)
14
+ --------------------
15
+ - Fix Chef chef_gem with Chef::Resource::ChefGem.method_defined?(:compile_time)
16
+
17
+ v1.36.3 (2014-12-18)
18
+ --------------------
19
+ - Fix Chef chef_gem below 12.1.0
20
+
21
+ v1.36.2 (2014-12-17)
22
+ --------------------
23
+ - Being explicit about usage of the chef_gem's compile_time property.
24
+ - Eliminating future deprecation warnings in Chef 12.1.0
25
+
5
26
  v1.36.1 (2014-12-17)
6
27
  --------------------
7
- - [PR 160](https://github.com/opscode-cookbooks/windows/pull/160) - Fix Chef 11.10 / versions without windows_package in core
28
+ - [PR 160](https://github.com/chef-cookbooks/windows/pull/160) - Fix Chef 11.10 / versions without windows_package in core
8
29
 
9
30
  v1.36.0 (2014-12-16)
10
31
  --------------------
11
- - [PR 145](https://github.com/opscode-cookbooks/windows/pull/145) - do not fail on non-existant task
12
- - [PR 144](https://github.com/opscode-cookbooks/windows/pull/144) - Add a zip example to the README
13
- - [PR 110](https://github.com/opscode-cookbooks/windows/pull/110) - More zip documentation
14
- - [PR 148](https://github.com/opscode-cookbooks/windows/pull/148) - Add an LWRP for font installation
15
- - [PR 151](https://github.com/opscode-cookbooks/windows/pull/151) - Fix windows_package on Chef 12, add integration tests
16
- - [PR 129](https://github.com/opscode-cookbooks/windows/pull/129) - Add enable/disable actions to task LWRP
17
- - [PR 115](https://github.com/opscode-cookbooks/windows/pull/115) - require Chef::Mixin::PowershellOut before using it
18
- - [PR 88](https://github.com/opscode-cookbooks/windows/pull/88) - Code 1003 from servermanagercmd.exe is valid
32
+ - [PR 145](https://github.com/chef-cookbooks/windows/pull/145) - do not fail on non-existant task
33
+ - [PR 144](https://github.com/chef-cookbooks/windows/pull/144) - Add a zip example to the README
34
+ - [PR 110](https://github.com/chef-cookbooks/windows/pull/110) - More zip documentation
35
+ - [PR 148](https://github.com/chef-cookbooks/windows/pull/148) - Add an LWRP for font installation
36
+ - [PR 151](https://github.com/chef-cookbooks/windows/pull/151) - Fix windows_package on Chef 12, add integration tests
37
+ - [PR 129](https://github.com/chef-cookbooks/windows/pull/129) - Add enable/disable actions to task LWRP
38
+ - [PR 115](https://github.com/chef-cookbooks/windows/pull/115) - require Chef::Mixin::PowershellOut before using it
39
+ - [PR 88](https://github.com/chef-cookbooks/windows/pull/88) - Code 1003 from servermanagercmd.exe is valid
19
40
 
20
41
  v1.34.8 (2014-10-31)
21
42
  --------------------
22
- - [Issue 137](https://github.com/opscode-cookbooks/windows/issues/137) - windows_path resource breaks with ruby 2.x
43
+ - [Issue 137](https://github.com/chef-cookbooks/windows/issues/137) - windows_path resource breaks with ruby 2.x
23
44
 
24
45
  v1.34.6 (2014-09-22)
25
46
  --------------------
26
- - [Chef-2009](https://github.com/opscode/chef/issues/2009) - Patch to work around a regression in [Chef](https://github.com/opscode/chef)
47
+ - [Chef-2009](https://github.com/chef/chef/issues/2009) - Patch to work around a regression in [Chef](https://github.com/chef/chef)
27
48
 
28
49
  v1.34.2 (2014-08-12)
29
50
  --------------------
30
- - [Issue 99](https://github.com/opscode-cookbooks/windows/issues/99) - Remove rubygems / Internet wmi-lite dependency (PR #108)
51
+ - [Issue 99](https://github.com/chef-cookbooks/windows/issues/99) - Remove rubygems / Internet wmi-lite dependency (PR #108)
31
52
 
32
53
  v1.34.0 (2014-08-04)
33
54
  --------------------
34
- - [Issue 99](https://github.com/opscode-cookbooks/windows/issues/99) - Use wmi-lite to fix Chef 11.14.2 break in rdp-ruby-wmi dependency
55
+ - [Issue 99](https://github.com/chef-cookbooks/windows/issues/99) - Use wmi-lite to fix Chef 11.14.2 break in rdp-ruby-wmi dependency
35
56
 
36
57
  v1.32.1 (2014-07-15)
37
58
  --------------------
@@ -73,33 +94,33 @@ Fixing depend/depends typo in metadata.rb
73
94
  v1.12.2
74
95
  -------
75
96
  ### Bug
76
- - **[COOK-4110](https://tickets.opscode.com/browse/COOK-4110)** - feature_servermanager installed? method regex bug
97
+ - **[COOK-4110](https://tickets.chef.io/browse/COOK-4110)** - feature_servermanager installed? method regex bug
77
98
 
78
99
 
79
100
  v1.12.0
80
101
  -------
81
102
  ### Bug
82
- - **[COOK-3793](https://tickets.opscode.com/browse/COOK-3793)** - parens inside parens of README.md don't render
103
+ - **[COOK-3793](https://tickets.chef.io/browse/COOK-3793)** - parens inside parens of README.md don't render
83
104
 
84
105
  ### New Feature
85
- - **[COOK-3714](https://tickets.opscode.com/browse/COOK-3714)** - Powershell features provider and delete support.
106
+ - **[COOK-3714](https://tickets.chef.io/browse/COOK-3714)** - Powershell features provider and delete support.
86
107
 
87
108
 
88
109
  v1.11.0
89
110
  -------
90
111
  ### Improvement
91
- - **[COOK-3724](https://tickets.opscode.com/browse/COOK-3724)** - Rrecommend built-in resources over cookbook resources
92
- - **[COOK-3515](https://tickets.opscode.com/browse/COOK-3515)** - Remove unprofessional comment from library
93
- - **[COOK-3455](https://tickets.opscode.com/browse/COOK-3455)** - Add Windows Server 2012R2 to windows cookbook version helper
112
+ - **[COOK-3724](https://tickets.chef.io/browse/COOK-3724)** - Rrecommend built-in resources over cookbook resources
113
+ - **[COOK-3515](https://tickets.chef.io/browse/COOK-3515)** - Remove unprofessional comment from library
114
+ - **[COOK-3455](https://tickets.chef.io/browse/COOK-3455)** - Add Windows Server 2012R2 to windows cookbook version helper
94
115
 
95
116
  ### Bug
96
- - **[COOK-3542](https://tickets.opscode.com/browse/COOK-3542)** - Fix an issue where `windows_zipfile` fails with LoadError
97
- - **[COOK-3447](https://tickets.opscode.com/browse/COOK-3447)** - Allow Overriding Of The Default Reboot Timeout In windows_reboot_handler
98
- - **[COOK-3382](https://tickets.opscode.com/browse/COOK-3382)** - Allow windows_task to create `on_logon` tasks
99
- - **[COOK-2098](https://tickets.opscode.com/browse/COOK-2098)** - Fix and issue where the `windows_reboot` handler is ignoring the reboot time
117
+ - **[COOK-3542](https://tickets.chef.io/browse/COOK-3542)** - Fix an issue where `windows_zipfile` fails with LoadError
118
+ - **[COOK-3447](https://tickets.chef.io/browse/COOK-3447)** - Allow Overriding Of The Default Reboot Timeout In windows_reboot_handler
119
+ - **[COOK-3382](https://tickets.chef.io/browse/COOK-3382)** - Allow windows_task to create `on_logon` tasks
120
+ - **[COOK-2098](https://tickets.chef.io/browse/COOK-2098)** - Fix and issue where the `windows_reboot` handler is ignoring the reboot time
100
121
 
101
122
  ### New Feature
102
- - **[COOK-3458](https://tickets.opscode.com/browse/COOK-3458)** - Add support for `start_date` and `start_time` in `windows_task`
123
+ - **[COOK-3458](https://tickets.chef.io/browse/COOK-3458)** - Add support for `start_date` and `start_time` in `windows_task`
103
124
 
104
125
 
105
126
  v1.10.0
@@ -18,7 +18,7 @@ Version 1.3.0+ of this cookbook requires Chef 0.10.10+.
18
18
  The `windows_task` LWRP requires Windows Server 2008 due to its API usage.
19
19
 
20
20
  ### Cookbooks
21
- The following cookbooks provided by Opscode are required as noted:
21
+ The following cookbooks provided by Chef Software are required as noted:
22
22
 
23
23
  * chef_handler (`windows::reboot_handler` leverages the chef_handler LWRP)
24
24
 
@@ -53,7 +53,7 @@ end
53
53
  ```
54
54
 
55
55
  ### windows_batch
56
- (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
+ (Chef 11.6.0 includes a built-in [batch](http://docs.chef.io/resource_batch.html) resource, so use that in preference to `windows_batch` if possible.)
57
57
 
58
58
  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.
59
59
 
@@ -116,7 +116,7 @@ servermanagercmd -query
116
116
  #### Providers
117
117
  - **Chef::Provider::WindowsFeature::DISM**: Uses Deployment Image Servicing and Management (DISM) to manage roles/features.
118
118
  - **Chef::Provider::WindowsFeature::ServerManagerCmd**: Uses Server Manager to manage roles/features.
119
- - **Chef::Provider::WindowsFeaturePowershell**: Uses Powershell to manage roles/features. (see [COOK-3714](https://tickets.opscode.com/browse/COOK-3714)
119
+ - **Chef::Provider::WindowsFeaturePowershell**: Uses Powershell to manage roles/features. (see [COOK-3714](https://tickets.chef.io/browse/COOK-3714)
120
120
 
121
121
  #### Examples
122
122
  Enable the node as a DHCP Server
@@ -375,7 +375,7 @@ Sets required data in the node's run_state to notify `WindowsRebootHandler` a re
375
375
 
376
376
  #### Attribute Parameters
377
377
  - :timeout: Name attribute. timeout delay in seconds to wait before proceeding with the requested reboot. default is 60 seconds
378
- - :reason: comment on the reason for the reboot. default is 'Opscode Chef initiated reboot'
378
+ - :reason: comment on the reason for the reboot. default is 'Chef Software Chef initiated reboot'
379
379
 
380
380
  #### Examples
381
381
  If the package installs, schedule a reboot at end of chef run
@@ -399,7 +399,7 @@ end
399
399
  ```
400
400
 
401
401
  ### windows_registry
402
- (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.)
402
+ (Chef 11.6.0 includes a built-in [registry_key](http://docs.chef.io/resource_registry_key.html) resource, so use that in preference to `windows_registry` if possible.)
403
403
 
404
404
  Creates and modifies Windows registry keys.
405
405
 
@@ -602,6 +602,45 @@ windows_zipfile 'c:/foo/baz/the_codez.zip' do
602
602
  end
603
603
  ```
604
604
 
605
+ Libraries
606
+ -------------------------
607
+ ### WindowsHelper
608
+
609
+ Helper that allows you to use helpful functions in windows
610
+
611
+ #### installed_packages
612
+ Returns a hash of all DisplayNames installed
613
+ ```ruby
614
+ # usage in a recipe
615
+ ::Chef::Recipe.send(:include, Windows::Helper)
616
+ hash_of_installed_packages = installed_packages
617
+ ```
618
+
619
+ #### is_package_installed?
620
+ - `package_name`: The name of the package you want to query to see if it is installed
621
+ - `returns`: true if the package is installed, false if it the package is not installed
622
+
623
+ Download a file if a package isn't installed
624
+ ```ruby
625
+ # usage in a recipe to not download a file if package is already installed
626
+ ::Chef::Recipe.send(:include, Windows::Helper)
627
+ is_win_sdk_installed = is_package_installed?('Windows Software Development Kit')
628
+
629
+ remote_file 'C:\windows\temp\windows_sdk.zip' do
630
+ source 'http://url_to_download/windows_sdk.zip'
631
+ action :create_if_missing
632
+ not_if {is_win_sdk_installed}
633
+ end
634
+ ```
635
+ Do something if a package is installed
636
+ ```ruby
637
+ # usage in a provider
638
+ include Windows::Helper
639
+ if is_package_installed?('Windows Software Development Kit')
640
+ # do something if package is installed
641
+ end
642
+ ```
643
+
605
644
  Exception/Report Handlers
606
645
  -------------------------
607
646
  ### WindowsRebootHandler
@@ -610,7 +649,7 @@ Required reboots are a necessary evil of configuring and managing Windows nodes.
610
649
  ### Initialization Arguments
611
650
  - `allow_pending_reboots`: indicator on whether the handler should act on a the Window's 'pending reboot' state. default is true
612
651
  - `timeout`: timeout delay in seconds to wait before proceeding with the reboot. default is 60 seconds
613
- - `reason`: comment on the reason for the reboot. default is 'Opscode Chef initiated reboot'
652
+ - `reason`: comment on the reason for the reboot. default is 'Chef Software Chef initiated reboot'
614
653
 
615
654
 
616
655
  Windows ChefSpec Matchers
@@ -685,13 +724,13 @@ By default, the handler will only be registered as a report handler, meaning tha
685
724
 
686
725
  License & Authors
687
726
  -----------------
688
- - Author:: Seth Chisamore (<schisamo@opscode.com>)
727
+ - Author:: Seth Chisamore (<schisamo@chef.io>)
689
728
  - Author:: Doug MacEachern (<dougm@vmware.com>)
690
729
  - Author:: Paul Morton (<pmorton@biaprotect.com>)
691
730
  - Author:: Doug Ireton (<doug.ireton@nordstrom.com>)
692
731
 
693
732
  ```text
694
- Copyright 2011-2013, Opscode, Inc.
733
+ Copyright 2011-2013, Chef Software, Inc.
695
734
  Copyright 2010, VMware, Inc.
696
735
  Copyright 2011, Business Intelligence Associates, Inc
697
736
  Copyright 2012, Nordstrom, Inc.
@@ -1,9 +1,9 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
3
  # Cookbook Name:: windows
4
4
  # Attribute:: default
5
5
  #
6
- # Copyright 2011, Opscode, Inc
6
+ # Copyright 2011, Chef Software, Inc
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -21,4 +21,4 @@
21
21
  default['windows']['allow_pending_reboots'] = true
22
22
  default['windows']['allow_reboot_on_failure'] = false
23
23
  default['windows']['rubyzipversion'] = nil
24
- default['windows']['reboot_timeout'] = 60
24
+ default['windows']['reboot_timeout'] = 60
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2011 Opscode, Inc
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Copyright:: Copyright (c) 2011 Chef Software, Inc
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,7 @@
19
19
  class WindowsRebootHandler < Chef::Handler
20
20
  include Chef::Mixin::ShellOut
21
21
 
22
- def initialize(allow_pending_reboots = true, timeout = 60, reason = "Opscode Chef initiated reboot")
22
+ def initialize(allow_pending_reboots = true, timeout = 60, reason = "Chef Software Chef initiated reboot")
23
23
  @allow_pending_reboots = allow_pending_reboots
24
24
  @timeout = timeout
25
25
  @reason = reason
@@ -73,4 +73,4 @@ class WindowsRebootHandler < Chef::Handler
73
73
  def reason
74
74
  node.run_state[:reboot_reason] || @reason
75
75
  end
76
- end
76
+ end
@@ -56,4 +56,4 @@ class Chef
56
56
  end
57
57
  end
58
58
  end
59
-
59
+
@@ -1,9 +1,9 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
3
  # Cookbook Name:: windows
4
4
  # Library:: helper
5
5
  #
6
- # Copyright:: 2011, Opscode, Inc.
6
+ # Copyright:: 2011, Chef Software, Inc.
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -1,12 +1,12 @@
1
1
  #
2
2
  # Author:: Doug MacEachern (<dougm@vmware.com>)
3
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
4
4
  # Author:: Paul Morton (<pmorton@biaprotect.com>)
5
5
  # Cookbook Name:: windows
6
6
  # Provider:: registry
7
7
  #
8
8
  # Copyright:: 2010, VMware, Inc.
9
- # Copyright:: 2011, Opscode, Inc.
9
+ # Copyright:: 2011, Chef Software, Inc.
10
10
  # Copyright:: 2011, Business Intelligence Associates, Inc
11
11
  #
12
12
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,9 +1,9 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
3
  # Cookbook Name:: windows
4
4
  # Library:: version
5
5
  #
6
- # Copyright:: 2011, Opscode, Inc.
6
+ # Copyright:: 2011, Chef Software, Inc.
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -1,9 +1,9 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
3
  # Cookbook Name:: windows
4
4
  # Library:: helper
5
5
  #
6
- # Copyright:: 2011, Opscode, Inc.
6
+ # Copyright:: 2011, Chef Software, Inc.
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -96,6 +96,52 @@ module Windows
96
96
  buf.strip
97
97
  end
98
98
 
99
+ def is_package_installed?(package_name)
100
+ installed_packages.include?(package_name)
101
+ end
102
+
103
+ def installed_packages
104
+ @installed_packages || begin
105
+ installed_packages = {}
106
+ # Computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
107
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE)) #rescue nil
108
+ # 64-bit registry view
109
+ # Computer\HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall
110
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0100))) #rescue nil
111
+ # 32-bit registry view
112
+ # Computer\HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
113
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0200))) #rescue nil
114
+ # Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
115
+ installed_packages.merge!(extract_installed_packages_from_key(::Win32::Registry::HKEY_CURRENT_USER)) #rescue nil
116
+ installed_packages
117
+ end
118
+ end
119
+
120
+ private
121
+ def extract_installed_packages_from_key(hkey = ::Win32::Registry::HKEY_LOCAL_MACHINE, desired = ::Win32::Registry::Constants::KEY_READ)
122
+ uninstall_subkey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'
123
+ packages = {}
124
+ begin
125
+ ::Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg|
126
+ reg.each_key do |key, wtime|
127
+ begin
128
+ k = reg.open(key, desired)
129
+ display_name = k["DisplayName"] rescue nil
130
+ version = k["DisplayVersion"] rescue "NO VERSION"
131
+ uninstall_string = k["UninstallString"] rescue nil
132
+ if display_name
133
+ packages[display_name] = {:name => display_name,
134
+ :version => version,
135
+ :uninstall_string => uninstall_string}
136
+ end
137
+ rescue ::Win32::Registry::Error
138
+ end
139
+ end
140
+ end
141
+ rescue ::Win32::Registry::Error
142
+ end
143
+ packages
144
+ end
99
145
  end
100
146
  end
101
147