Skip to content

Commit

Permalink
Use all-in-one ms_dotnet cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
Annih committed Nov 26, 2015
1 parent fbf4ad0 commit 0d5e2f8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 36 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ Not every version of Windows supports every version of Powershell. The following

PowerShell also requires the appropriate version of the Microsoft .NET Framework to be installed, if the operating system does not ship with that version. The following community cookbooks are used to install the correct version of the .NET Framework:

* ms_dotnet2
* ms_dotnet4
* ms_dotnet45
* ms_dotnet

Resource/Provider
-----------------
Expand Down
4 changes: 1 addition & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

supports 'windows'
depends 'windows', '>= 1.2.8'
depends 'ms_dotnet45'
depends 'ms_dotnet4'
depends 'ms_dotnet2'
depends 'ms_dotnet'
depends 'chef_handler'

source_url 'https://github.com/chef-cookbooks/powershell' if respond_to?(:source_url)
Expand Down
11 changes: 2 additions & 9 deletions recipes/powershell2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

if (windows_version.windows_server_2012? || windows_version.windows_8?) && windows_version.core?
# Windows Server 2012 Core does not come with Powershell 2.0 enabled

windows_feature 'MicrosoftWindowsPowerShellV2' do
action :install
end
Expand All @@ -40,14 +39,8 @@

elsif (windows_version.windows_server_2008_r2? || windows_version.windows_7?) && windows_version.core?
# Windows Server 2008 R2 Core does not come with .NET or Powershell 2.0 enabled
include_recipe 'ms_dotnet::ms_dotnet2'

windows_feature 'NetFx2-ServerCore' do
action :install
end
windows_feature 'NetFx2-ServerCore-WOW64' do
action :install
only_if { node['kernel']['machine'] == 'x86_64' }
end
windows_feature 'MicrosoftWindowsPowerShell' do
action :install
end
Expand All @@ -59,7 +52,7 @@
elsif windows_version.windows_server_2008? || windows_version.windows_server_2003_r2? ||
windows_version.windows_server_2003? || windows_version.windows_xp?

include_recipe 'ms_dotnet2'
include_recipe 'ms_dotnet::ms_dotnet2'

# Reboot if user specifies doesn't specify no_reboot
include_recipe 'powershell::windows_reboot' unless node['powershell']['installation_reboot_mode'] == 'no_reboot'
Expand Down
2 changes: 1 addition & 1 deletion recipes/powershell3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
end

# WMF 3.0 requires .NET 4.0
include_recipe 'ms_dotnet4'
include_recipe 'ms_dotnet::ms_dotnet4'

# Reboot if user specifies doesn't specify no_reboot
include_recipe 'powershell::windows_reboot' unless node['powershell']['installation_reboot_mode'] == 'no_reboot'
Expand Down
5 changes: 3 additions & 2 deletions recipes/powershell4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

if windows_version.windows_server_2008_r2? || windows_version.windows_7? || windows_version.windows_server_2012?

# Ensure .NET 4.5 is installed or installation will fail silently per Microsoft. Only necessary for Windows 2008R2 or 7.
include_recipe 'ms_dotnet45' if windows_version.windows_server_2008_r2? || windows_version.windows_7?
# Ensure .NET 4.5 is installed or installation will fail silently per Microsoft.
fail 'Attribute ms_dotnet.v4.version is not configured to install .NET4.5 as required for Powershell4' if node.default['ms_dotnet']['v4']['version'] < '4.5'
include_recipe 'ms_dotnet::ms_dotnet4'

# Reboot if user specifies doesn't specify no_reboot
include_recipe 'powershell::windows_reboot' unless node['powershell']['installation_reboot_mode'] == 'no_reboot'
Expand Down
4 changes: 2 additions & 2 deletions spec/recipes/powershell2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
end

it 'installs windows package when powershell2 doesnot exist' do
expect(chef_run).to include_recipe('ms_dotnet2')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet2')
expect(chef_run).to install_windows_package('Windows Management Framework Core').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom, options: '/quiet /norestart')
end
end
Expand All @@ -86,7 +86,7 @@
end

it 'only includes ms_dotnet2 when powershell2 exist' do
expect(chef_run).to include_recipe('ms_dotnet2')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet2')
end
end
end
8 changes: 4 additions & 4 deletions spec/recipes/powershell3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
end

it 'only include ms_dotnet4 when powershell 3 is installed' do
expect(chef_run).to include_recipe('ms_dotnet4')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -51,7 +51,7 @@
end

it 'installs windows package windows management framework core 3.0 when powershell 3 doesnot exist' do
expect(chef_run).to include_recipe('ms_dotnet4')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core 3.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom, options: '/quiet /norestart')
end
end
Expand All @@ -66,7 +66,7 @@
end

it 'only include ms_dotnet4 when powershell 3 is installed' do
expect(chef_run).to include_recipe('ms_dotnet4')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -80,7 +80,7 @@
end

it 'installs windows package windows management framework core 3.0 when powershell 3 doesnot exist' do
expect(chef_run).to include_recipe('ms_dotnet4')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core 3.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom, options: '/quiet /norestart')
end
end
Expand Down
27 changes: 15 additions & 12 deletions spec/recipes/powershell4_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end

it 'only includes ms_dotnet45 when powershell 4 is installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -35,7 +35,7 @@
end

it 'installs windows package windows managemet framework core 4.0 when powershell 4 is not installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -50,7 +50,7 @@
end

it 'only includes ms_dotnet45 when powershell 4 is installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -64,7 +64,7 @@
end

it 'installs windows package windows managemet framework core 4.0 when powershell 4 is not installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -79,6 +79,7 @@
end

it 'installs windows package windows managemet framework core 4.0' do
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -103,7 +104,7 @@
end

it 'only includes ms_dotnet45 when powershell 4 is installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -117,7 +118,7 @@
end

it 'installs windows package windows managemet framework core 4.0 when powershell 4 is not installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -132,7 +133,7 @@
end

it 'only includes ms_dotnet45 when powershell 4 is installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -146,7 +147,7 @@
end

it 'installs windows package windows managemet framework core 4.0 when powershell 4 is not installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -161,6 +162,7 @@
end

it 'installs windows package windows managemet framework core 4.0' do
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -185,7 +187,7 @@
end

it 'only includes ms_dotnet45 when powershell 4 is installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -199,7 +201,7 @@
end

it 'installs windows package windows managemet framework core 4.0 when powershell 4 is not installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -214,7 +216,7 @@
end

it 'only includes ms_dotnet45 when powershell 4 is installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
end
end

Expand All @@ -228,7 +230,7 @@
end

it 'installs windows package windows managemet framework core 4.0 when powershell 4 is not installed' do
expect(chef_run).to include_recipe('ms_dotnet45')
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand All @@ -243,6 +245,7 @@
end

it 'installs windows package windows managemet framework core 4.0' do
expect(chef_run).to include_recipe('ms_dotnet::ms_dotnet4')
expect(chef_run).to install_windows_package('Windows Management Framework Core4.0').with(source: 'https://powershelltest.com', checksum: '12345', installer_type: :custom)
end
end
Expand Down

0 comments on commit 0d5e2f8

Please sign in to comment.