From dcc89eb29cffc68cbb1bfcf33df90d54ac6cf92c Mon Sep 17 00:00:00 2001 From: Dan Iverson Date: Fri, 18 Feb 2022 17:57:45 -0600 Subject: [PATCH] 8.59 Windows Support Switch to a powershell file for Windows, use the relocatable puppet location for Ruby. --- scripts/loadcache.pp | 79 +++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/scripts/loadcache.pp b/scripts/loadcache.pp index 28132a3..1c82c9b 100644 --- a/scripts/loadcache.pp +++ b/scripts/loadcache.pp @@ -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 | { @@ -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}": @@ -76,4 +81,4 @@ } } -} \ No newline at end of file +}