Skip to content

Commit

Permalink
8.59 Windows Support
Browse files Browse the repository at this point in the history
Switch to a powershell file for Windows, use the relocatable puppet location for Ruby.
  • Loading branch information
iversond authored Feb 18, 2022
1 parent 69ddaee commit dcc89eb
Showing 1 changed file with 42 additions and 37 deletions.
79 changes: 42 additions & 37 deletions scripts/loadcache.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
$peoplesoft_base = hiera('peoplesoft_base')
$ps_home_dir = hiera('ps_home_location')
$oracle_home_location = hiera('oracle_server_location')
$tns_dir = hiera('tns_dir')
$gem_home = "${peoplesoft_base}/psft_puppet_agent/bin"

case $::osfamily {
'windows': {
$gem_home = 'c:/program files/puppet labs/puppet/bin'
exec { 'install-psadmin_plus':
command => "${gem_home}/gem install psadmin_plus",
provider => 'powershell'
}
}
'RedHat', 'linux': {
$gem_home = '/opt/puppetlabs/puppet/bin'
exec { 'install-psadmin_plus':
command => "${gem_home}/gem install psadmin_plus",
}
}
$prcs_domain_name = hiera('prcs_domain_name')
$db_name = hiera('db_name')

$preload_script_win = @(END)
if (! ( Test-Path <%= $gem_home %>/gem.bat )) {
Write-Output "Installing psadmin_plus"
Invoke-WebRequest https://rubygems.org/downloads/psadmin_plus-2.0.5.gem -outFile psadmin_plus.gem
<%= $gem_home %>/gem.bat install psadmin_plus --local
}

$prcs_domain_name = hiera('prcs_domain_name')
Write-Output "Stopping app server"
<%= $gem_home %>/psa.bat stop app <%= $domain_name %>

$env:PS_HOME="<%= $ps_home_dir %>";
$env:ORACLE_HOME="<%= $oracle_home_location %>";
$env:TNS_ADMIN="<%= $tns_dir %>";
$env:PATH="${env:PS_HOME}\bin\client\winx86;${env:ORACLE_HOME}\bin;${env:PATH}";

Write-Output "Running LOADCACHE"
& ${env:PS_HOME}/bin/client/winx86/psae.exe -CT <%= $db_settings[db_type] %> -CD <%= $db_settings[db_name] %> -CI <%= $db_settings[db_connect_id] %> -CW <%= $db_settings[db_connect_pwd] %> -CO <%= $db_settings[db_opr_id] %> -CP <%= $db_settings[db_opr_pwd] %> -R BUILD -AI LOADCACHE

Write-Output "Copy CACHE files to app server"
remove-item -recurse -force <%= $ps_cfg_home_dir %>/appserv/<%= $domain_name %>/CACHE/*;
mkdir -force <%= $ps_cfg_home_dir %>/appserv/<%= $domain_name %>/CACHE/SHARE/
copy-item -recurse <%= $ps_cfg_home_dir %>/CLIENT/CACHE/<%= $db_name %>/stage/stage/* <%= $ps_cfg_home_dir %>/appserv/<%= $domain_name %>/CACHE/SHARE/

Write-Output "Configure app server for Shared Cache"
(gc <%= $ps_cfg_home_dir %>/appserv/<%= $domain_name %>/psappsrv.cfg) | %{ $_ -replace ";ServerCacheMode=0","ServerCacheMode=1" } | set-content <%= $ps_cfg_home_dir %>/appserv/<%= $domain_name %>/psappsrv.cfg

Write-Output "Starting app server"
<%= $gem_home %>/psa.bat bounce app <%= $domain_name %>
END

$appserver_domain_list = hiera('appserver_domain_list')
$appserver_domain_list.each | $domain_name, $app_domain_info | {
Expand All @@ -29,28 +46,16 @@

case $::osfamily {
'windows': {
exec {"LOADCACHE-${domain_name}":
command => "\$env:PS_HOME=\"${ps_home_dir}\";\
\$env:ORACLE_HOME=\"${oracle_home_location}\";\
\$env:TNS_ADMIN=\"${tns_dir}\";\
\$env:PATH=\"\${env:PS_HOME}\\bin\\client\\winx86;\${env:ORACLE_HOME}\\bin;\${env:PATH}\";\
psae -CT ${db_settings[db_type]} -CD ${db_settings[db_name]} -CI ${db_settings[db_connect_id]} -CW ${db_settings[db_connect_pwd]} -CO ${db_settings[db_opr_id]} -CP ${db_settings[db_opr_pwd]} -R BUILD -AI LOADCACHE",
provider => 'powershell'
}
-> exec {'copy-cache-folder':
command => "remove-item ${ps_cfg_home_dir}/appserv/${domain_name}/CACHE/*; \
copy-item -recurse ${ps_cfg_home_dir}/CLIENT/CACHE/${prcs_domain_name}/stage/stage/ ${ps_cfg_home_dir}/appserv/${domain_name}/CACHE/SHARE/",
provider => 'powershell',
}
-> exec { "Set-Cache-Mode-${domain_name}":
command => "(gc ${ps_cfg_home_dir}/appserv/${domain_name}/psappsrv.cfg) | %{ \$_ -replace \";ServerCacheMode=0\",\"ServerCacheMode=1\" } | set-content ${ps_cfg_home_dir}/appserv/${domain_name}/psappsrv.cfg",
provider => 'powershell',
}
-> exec { "Bounce ${domain_name} App Domain":
command => "psa bounce app ${domain_name}",
provider => 'powershell',
require => Exec['install-psadmin_plus'],

notify { 'Creating and running preloaccache.ps1 ': }
file { "${peoplesoft_base}/preloadcache.ps1":
ensure => file,
content => inline_epp($preload_script_win),
} ->
exec {'Load-Cache':
command => "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -File ${peoplesoft_base}/preloadcache.ps1"
}

}
'RedHat', 'linux': {
pt_psae {"LOADCACHE-${domain_name}":
Expand All @@ -76,4 +81,4 @@
}
}

}
}

0 comments on commit dcc89eb

Please sign in to comment.