Skip to content

Commit

Permalink
Merge pull request voxpupuli#35 from amwilson/virtualapp-names
Browse files Browse the repository at this point in the history
Fixes for issues voxpupuli#31 & voxpupuli#32. Site names containing spaces were rendered i...
  • Loading branch information
stack72 committed Aug 14, 2014
2 parents 28f83b0 + f7c25df commit eaa19d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
12 changes: 6 additions & 6 deletions manifests/manage_virtual_application.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
}

exec { "CreateVirtualApplication-${site_name}-${virtual_application_name}" :
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; New-WebApplication -Name ${virtual_application_name} -Site ${site_name} -PhysicalPath ${site_path} -ApplicationPool ${app_pool}\"",
path => "${iis::param::powershell::path};${::path}",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\Sites\\${site_name}\\${virtual_application_name}\\\")) { exit 1 } else { exit 0 }\"",
command => "Import-Module WebAdministration; New-WebApplication -Name ${virtual_application_name} -Site \"${site_name}\" -PhysicalPath \"${site_path}\" -ApplicationPool \"${app_pool}\"",
onlyif => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\${site_name}\") -and (Get-ChildItem \"IIS:\\Sites\\${site_name}\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq '${virtual_application_name}'})) { exit 1 } else { exit 0 }",
require => [ Iis::Createpath["${site_name}-${virtual_application_name}-${site_path}"], Iis::Manage_site[$site_name] ],
provider => powershell,
logoutput => true,
}
} else {
exec { "DeleteVirtualApplication-${site_name}-${virtual_application_name}" :
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Remove-WebApplication -Name ${virtual_application_name} -Site ${site_name}\"",
path => "${iis::param::powershell::path};${::path}",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\Sites\\${site_name}\\${virtual_application_name}\\\")) { exit 1 } else { exit 0 }\"",
command => "Import-Module WebAdministration; Remove-WebApplication -Name ${virtual_application_name} -Site \"${site_name}\"",
onlyif => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\${site_name}\") -and (Get-ChildItem \"IIS:\\Sites\\${site_name}\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq '${virtual_application_name}'})) { exit 0 } else { exit 1 }",
provider => powershell,
logoutput => true,
}
}
Expand Down
39 changes: 26 additions & 13 deletions spec/defines/manage_virtual_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
:app_pool => 'myAppPool.example.com',
}}

it { should contain_class('iis::param::powershell') }

it { should contain_exec('CreateVirtualApplication-myWebSite-mySite').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebApplication -Name mySite -Site myWebSite -PhysicalPath C:\\inetpub\\wwwroot\\myHost -ApplicationPool myAppPool.example.com\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\Sites\\myWebSite\\mySite\\\")) { exit 1 } else { exit 0 }\"",
'command' => "Import-Module WebAdministration; New-WebApplication -Name mySite -Site \"myWebSite\" -PhysicalPath \"C:\\inetpub\\wwwroot\\myHost\" -ApplicationPool \"myAppPool.example.com\"",
'onlyif' => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\") -and (Get-ChildItem \"IIS:\\Sites\\myWebSite\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq 'mySite'})) { exit 1 } else { exit 0 }",
})}
end

Expand All @@ -29,11 +27,26 @@
}}

it { should contain_exec('CreateVirtualApplication-myWebSite-mySite').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebApplication -Name mySite -Site myWebSite -PhysicalPath C:\\inetpub\\wwwroot\\myHost -ApplicationPool myAppPool.example.com\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\Sites\\myWebSite\\mySite\\\")) { exit 1 } else { exit 0 }\"",
'command' => "Import-Module WebAdministration; New-WebApplication -Name mySite -Site \"myWebSite\" -PhysicalPath \"C:\\inetpub\\wwwroot\\myHost\" -ApplicationPool \"myAppPool.example.com\"",
'onlyif' => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\") -and (Get-ChildItem \"IIS:\\Sites\\myWebSite\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq 'mySite'})) { exit 1 } else { exit 0 }",
})}
end

describe 'when I create a virtual application in IIS on a site with spaces in the name' do
let(:title) { 'myVirtualApp' }
let(:params) {{
:site_name => 'My Web Site',
:site_path => 'C:\inetpub\wwwroot\myHost',
:app_pool => 'myAppPool.example.com',
:ensure => 'present',
}}

it { should contain_exec('CreateVirtualApplication-My Web Site-myVirtualApp').with({
'command' => "Import-Module WebAdministration; New-WebApplication -Name myVirtualApp -Site \"My Web Site\" -PhysicalPath \"C:\\inetpub\\wwwroot\\myHost\" -ApplicationPool \"myAppPool.example.com\"",
'onlyif' => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\My Web Site\") -and (Get-ChildItem \"IIS:\\Sites\\My Web Site\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq 'myVirtualApp'})) { exit 1 } else { exit 0 }",
})}
end

describe 'when I create a virtual application in IIS and set ensure to installed' do
let(:title) { 'mySite' }
let(:params) {{
Expand All @@ -44,8 +57,8 @@
}}

it { should contain_exec('CreateVirtualApplication-myWebSite-mySite').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebApplication -Name mySite -Site myWebSite -PhysicalPath C:\\inetpub\\wwwroot\\myHost -ApplicationPool myAppPool.example.com\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\Sites\\myWebSite\\mySite\\\")) { exit 1 } else { exit 0 }\"",
'command' => "Import-Module WebAdministration; New-WebApplication -Name mySite -Site \"myWebSite\" -PhysicalPath \"C:\\inetpub\\wwwroot\\myHost\" -ApplicationPool \"myAppPool.example.com\"",
'onlyif' => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\") -and (Get-ChildItem \"IIS:\\Sites\\myWebSite\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq 'mySite'})) { exit 1 } else { exit 0 }",
})}
end

Expand All @@ -59,8 +72,8 @@
}}

it { should contain_exec('DeleteVirtualApplication-myWebSite-mySite').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Remove-WebApplication -Name mySite -Site myWebSite\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\Sites\\myWebSite\\mySite\\\")) { exit 1 } else { exit 0 }\"",
'command' => "Import-Module WebAdministration; Remove-WebApplication -Name mySite -Site \"myWebSite\"",
'onlyif' => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\") -and (Get-ChildItem \"IIS:\\Sites\\myWebSite\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq 'mySite'})) { exit 0 } else { exit 1 }",
})}
end

Expand All @@ -74,8 +87,8 @@
}}

it { should contain_exec('DeleteVirtualApplication-myWebSite-mySite').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Remove-WebApplication -Name mySite -Site myWebSite\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\Sites\\myWebSite\\mySite\\\")) { exit 1 } else { exit 0 }\"",
'command' => "Import-Module WebAdministration; Remove-WebApplication -Name mySite -Site \"myWebSite\"",
'onlyif' => "Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\") -and (Get-ChildItem \"IIS:\\Sites\\myWebSite\" | where {\$_.Schema.Name -eq 'Application' -and \$_.Name -eq 'mySite'})) { exit 0 } else { exit 1 }",
})}
end
end
end

0 comments on commit eaa19d7

Please sign in to comment.