Skip to content

Commit

Permalink
Bugfix: corrected quotes escaping around App pool names, fixed capita…
Browse files Browse the repository at this point in the history
…lisation for required resources
  • Loading branch information
Drew Wilson committed Nov 13, 2013
1 parent d523d54 commit e5b1922
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
20 changes: 10 additions & 10 deletions manifests/manage_app_pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@

if ($ensure in ['present','installed']) {
exec { "Create-${app_pool_name}" :
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; New-Item \"IIS:\\AppPools\\${app_pool_name}\"\"",
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\${app_pool_name}\\\"\"",
path => "${iis::param::powershell::path};${::path}",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\AppPools\\${app_pool_name}\")) { exit 1 } else {exit 0}\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\AppPools\\${app_pool_name}\\\")) { exit 1 } else {exit 0}\"",
logoutput => true,
}

exec { "Framework-${app_pool_name}" :
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\${app_pool_name}\" managedRuntimeVersion ${managed_runtime_version}\"",
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\${app_pool_name}\\\" managedRuntimeVersion ${managed_runtime_version}\"",
path => "${iis::param::powershell::path};${::path}",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\${app_pool_name}\" managedRuntimeVersion).Value.CompareTo('${managed_runtime_version}') -eq 0) { exit 1 } else { exit 0 }\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\${app_pool_name}\\\" managedRuntimeVersion).Value.CompareTo('${managed_runtime_version}') -eq 0) { exit 1 } else { exit 0 }\"",
require => Exec["Create-${app_pool_name}"],
logoutput => true,
}

exec { "32bit-${app_pool_name}" :
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\${app_pool_name}\" enable32BitAppOnWin64 ${enable_32_bit}\"",
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\${app_pool_name}\\\" enable32BitAppOnWin64 ${enable_32_bit}\"",
path => "${iis::param::powershell::path};${::path}",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\${app_pool_name}\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean('${enable_32_bit}')) { exit 1 } else { exit 0 }\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\${app_pool_name}\\\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean('${enable_32_bit}')) { exit 1 } else { exit 0 }\"",
require => Exec["Create-${app_pool_name}"],
logoutput => true,
}

exec { "ManagedPipelineMode-${app_pool_name}" :
path => "${iis::param::powershell::path};${::path}",
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\${app_pool_name}\" managedPipelineMode ${managed_pipeline_mode}\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\${app_pool_name}\" managedPipelineMode).Value.CompareTo('${managed_pipeline_mode}') -eq 0) { exit 1 } else { exit 0 }\"",
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\${app_pool_name}\\\" managedPipelineMode ${managed_pipeline_mode}\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\${app_pool_name}\\\" managedPipelineMode).Value.CompareTo('${managed_pipeline_mode}') -eq 0) { exit 1 } else { exit 0 }\"",
require => Exec["Create-${app_pool_name}"],
logoutput => true,
}
} else {
exec { "Delete-${app_pool_name}" :
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Remove-Item \"IIS:\\AppPools\\${app_pool_name}\" -Recurse\"",
command => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; Remove-Item \\\"IIS:\\AppPools\\${app_pool_name}\\\" -Recurse\"",
path => "${iis::param::powershell::path};${::path}",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if(!(Test-Path \"IIS:\\AppPools\\${app_pool_name}\")) { exit 1 } else {exit 0}\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\AppPools\\${app_pool_name}\\\")) { exit 1 } else {exit 0}\"",
logoutput => true,
}
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/manage_virtual_application.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
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 }\"",
require => [ iis::createpath["${site_name}-${virtual_application_name}-${site_path}"], iis::manage_site[$site_name] ],
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\Sites\\${site_name}\\${virtual_application_name}\\\")) { exit 1 } else { exit 0 }\"",
require => [ Iis::Createpath["${site_name}-${virtual_application_name}-${site_path}"], Iis::Manage_site[$site_name] ],
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 }\"",
onlyif => "${iis::param::powershell::command} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\Sites\\${site_name}\\${virtual_application_name}\\\")) { exit 1 } else { exit 0 }\"",
logoutput => true,
}
}
Expand Down
56 changes: 28 additions & 28 deletions spec/defines/manage_app_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
it { should include_class('iis::param::powershell') }

it { should contain_exec('Create-myAppPool.example.com').with( {
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \"IIS:\\AppPools\\myAppPool.example.com\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\AppPools\\myAppPool.example.com\")) { exit 1 } else {exit 0}\"",
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\AppPools\\myAppPool.example.com\\\")) { exit 1 } else {exit 0}\"",
}) }

it { should contain_exec('Framework-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}

it { should contain_exec('32bit-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64 true\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'true\')) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64 true\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'true\')) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}
end
Expand All @@ -33,19 +33,19 @@
it { should include_class('iis::param::powershell') }

it { should contain_exec('Create-myAppPool.example.com').with( {
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \"IIS:\\AppPools\\myAppPool.example.com\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\AppPools\\myAppPool.example.com\")) { exit 1 } else {exit 0}\"",
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\AppPools\\myAppPool.example.com\\\")) { exit 1 } else {exit 0}\"",
}) }

it { should contain_exec('Framework-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}

it { should contain_exec('32bit-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64 false\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'false\')) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64 false\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'false\')) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}
end
Expand Down Expand Up @@ -90,19 +90,19 @@
let(:params) {{ :ensure => 'present' }}

it { should contain_exec('Create-myAppPool.example.com').with( {
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \"IIS:\\AppPools\\myAppPool.example.com\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\AppPools\\myAppPool.example.com\")) { exit 1 } else {exit 0}\"",
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\AppPools\\myAppPool.example.com\\\")) { exit 1 } else {exit 0}\"",
}) }

it { should contain_exec('Framework-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}

it { should contain_exec('32bit-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64 false\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'false\')) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64 false\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'false\')) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}
end
Expand All @@ -112,19 +112,19 @@
let(:params) {{ :ensure => 'installed' }}

it { should contain_exec('Create-myAppPool.example.com').with( {
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \"IIS:\\AppPools\\myAppPool.example.com\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\AppPools\\myAppPool.example.com\")) { exit 1 } else {exit 0}\"",
:command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\"\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \\\"IIS:\\AppPools\\myAppPool.example.com\\\")) { exit 1 } else {exit 0}\"",
}) }

it { should contain_exec('Framework-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion v4.0\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" managedRuntimeVersion).Value.CompareTo(\'v4.0\') -eq 0) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}

it { should contain_exec('32bit-myAppPool.example.com').with({
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64 false\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \"IIS:\\AppPools\\myAppPool.example.com\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'false\')) { exit 1 } else { exit 0 }\"",
'command' => "#{powershell} -Command \"Import-Module WebAdministration; Set-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64 false\"",
'onlyif' => "#{powershell} -Command \"Import-Module WebAdministration; if((Get-ItemProperty \\\"IIS:\\AppPools\\myAppPool.example.com\\\" enable32BitAppOnWin64).Value -eq [System.Convert]::ToBoolean(\'false\')) { exit 1 } else { exit 0 }\"",
'require' => 'Exec[Create-myAppPool.example.com]',
})}
end
Expand All @@ -134,8 +134,8 @@
let(:params) {{ :ensure => 'absent' }}

it { should contain_exec('Delete-myAppPool.example.com').with( {
:command => "#{powershell} -Command \"Import-Module WebAdministration; Remove-Item \"IIS:\\AppPools\\myAppPool.example.com\" -Recurse\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if(!(Test-Path \"IIS:\\AppPools\\myAppPool.example.com\")) { exit 1 } else {exit 0}\"",
:command => "#{powershell} -Command \"Import-Module WebAdministration; Remove-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\" -Recurse\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\AppPools\\myAppPool.example.com\\\")) { exit 1 } else {exit 0}\"",
}) }

it { should_not contain_exec('Framework-myAppPool.example.com') }
Expand All @@ -148,8 +148,8 @@
let(:params) {{ :ensure => 'purged' }}

it { should contain_exec('Delete-myAppPool.example.com').with( {
:command => "#{powershell} -Command \"Import-Module WebAdministration; Remove-Item \"IIS:\\AppPools\\myAppPool.example.com\" -Recurse\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if(!(Test-Path \"IIS:\\AppPools\\myAppPool.example.com\")) { exit 1 } else {exit 0}\"",
:command => "#{powershell} -Command \"Import-Module WebAdministration; Remove-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\" -Recurse\"",
:onlyif => "#{powershell} -Command \"Import-Module WebAdministration; if(!(Test-Path \\\"IIS:\\AppPools\\myAppPool.example.com\\\")) { exit 1 } else {exit 0}\"",
}) }

it { should_not contain_exec('Framework-myAppPool.example.com') }
Expand Down
Loading

0 comments on commit e5b1922

Please sign in to comment.