Created
October 8, 2018 08:47
-
-
Save accasey/8acd77d3001bab52e126e2123dc1f438 to your computer and use it in GitHub Desktop.
Bootstrap code for the DPK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Network filesystem variables | |
| $network_software_base = "\\MSFSSHARED\BIS\Software\ServerSoftware\PeopleSoft CMA" | |
| $network_peopletools_base = Join-Path $network_software_base "PeopleTools_8.56" | |
| $network_puppet_base = Join-Path $network_peopletools_base "utils\puppet" | |
| $network_archive_base = Join-Path $network_peopletools_base "archives" | |
| # Local filesystem variables. | |
| $local_dpk_base = "d:\psoft" | |
| $local_software_base = "d:\software" | |
| $local_temp_base = "d:\temp" | |
| $local_puppet_install_dir = Join-Path $local_software_base "puppet" | |
| $local_eyaml_install_dir = Join-Path $local_puppet_install_dir "eyaml" | |
| $puppet_msi_path = Join-Path $local_puppet_install_dir "puppet-agent-1.5.2-x64.msi" | |
| $puppet_location = "C:\Program Files\Puppet Labs\Puppet\bin" | |
| # $eyaml_gem_path = Join-Path $local_eyaml_install_dir "hiera-eyaml-2.1.0.gem" | |
| # $highline_gem_path = Join-Path $local_eyaml_install_dir "highline-1.6.21.gem" | |
| # $trollop_gem_path = Join-Path $local_eyaml_install_dir "trollop-2.1.2.gem" | |
| # Build the local filesystem | |
| function create_directory_structures { | |
| Write-Host " **** Setting up the PeopleSoft folders on Server ****" | |
| # Create d:\software | |
| if (-Not (Test-Path -Path $local_software_base -PathType Container)) { | |
| New-Item -ItemType Directory -Path $local_software_base | Out-Null | |
| } | |
| # Create DPK base folder, d:\psoft, and structure | |
| if (-Not (Test-Path -Path $local_dpk_base -PathType Container)) { | |
| # Create DPK structure | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path $local_dpk_base "dpk") "archives") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "CMAUAT90") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "CMAUAT01") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "CMAUAT02") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "CMAUAT03") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "secure") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "ssl") | Out-Null | |
| # Create PS_APP_HOME (although not really [currently] used) | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path $local_dpk_base "app") "fscm9") | Out-Null | |
| # Create PS_CUST_HOME, PS_FILEDIR and TEMP locations | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT90") "files") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT90") "temp") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT01") "files") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT01") "temp") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT02") "files") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT02") "temp") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT03") "files") | Out-Null | |
| New-Item -ItemType Directory -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "cust") "CMAUAT03") "temp") | Out-Null | |
| } | |
| # Create temp folder, d:\temp and logs d:\temp\logs | |
| if (-Not (Test-Path -Path $local_temp_base -PathType Container)) { | |
| New-Item -ItemType Directory -Path (Join-Path $local_temp_base "logs") | Out-Null | |
| } | |
| } | |
| function copy_software_utilities { | |
| # Copy the puppet installation files to the local filesystem | |
| Copy-Item -Path $network_puppet_base -Destination $local_software_base -Recurse -Force | |
| } | |
| # Install Puppet | |
| function install_puppet { | |
| if (Test-Path -Path $puppet_location -PathType Container) { | |
| Write-Host " **** Puppet already installed on Server ****" | |
| } | |
| else { | |
| if (Test-Path -Path $puppet_msi_path -PathType Leaf) { | |
| Write-Host " **** Installing Puppet on Server - Started - $(Get-Date) ****" | |
| $puppet_msi_file = Get-Item -Path $puppet_msi_path | |
| $datestamp = Get-Date -Format yyyyMMddTHHmmss | |
| $logfile = '{0}-{1}.log' -f $puppet_msi_file.FullName, $datestamp | |
| $msi_args = @( | |
| "/i" | |
| ('"{0}"' -f $puppet_msi_file.FullName) | |
| "/qn" | |
| "/L*v" | |
| ('"{0}"' -f $logfile) | |
| ) | |
| Start-Process "msiexec.exe" -ArgumentList $msi_args -Wait -NoNewWindow | |
| Write-Host " **** Installing Puppet on Server - Finished - $(Get-Date) ****" | |
| } | |
| } | |
| } | |
| function install_hiera_eyaml { | |
| # gem install --local hiera-eyaml | |
| $current_directory = Get-Location | |
| if (Test-Path -Path $puppet_location -PathType Container) { | |
| Write-Host " **** Installing support for Hiera eYaml (and dependent gems) ****" | |
| Write-Host " Switching directory from ${current_directory} to to ${local_eyaml_install_dir}" | |
| Set-Location -Path $local_eyaml_install_dir | |
| $gem_args = @( | |
| "install" | |
| "--local" | |
| "hiera-eyaml" | |
| ) | |
| Start-Process "gem" -ArgumentList $gem_args -Wait -NoNewWindow | Out-Null | |
| Write-Host " Switching directory from ${local_eyaml_install_dir} to to ${current_directory}" | |
| Set-Location $current_directory | |
| } | |
| } | |
| function pull_down_repos { | |
| $current_directory = Get-Location | |
| # rem The first time git clone is run, it will ask for credentials to the TFS site | |
| Set-Location -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") | |
| $env:Path += ";C:\Program Files\Git\bin" | |
| # Ensure that if credentials are needed, that git prompts you with the modal and not from the | |
| # command line. The modal will store them in the Windows Credential Manager (Control Panel applet) | |
| $git_clone_args = @( | |
| "config" | |
| "--global" | |
| "credential.modalprompt" | |
| "true" | |
| ) | |
| # git config --global credential.modalprompt true | |
| Start-Process "git" -ArgumentList $git_clone_args -Wait -NoNewWindow | |
| # Pull down the data (yaml files) | |
| $git_clone_args = @( | |
| "clone" | |
| "https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/data" | |
| ) | |
| # git clone https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/data | |
| Start-Process "git" -ArgumentList $git_clone_args -Wait -NoNewWindow | |
| # Pull down the modules (puppet/ruby files) | |
| $git_clone_args = @( | |
| "clone" | |
| "-b" | |
| "8.56_bis" | |
| "https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/modules" | |
| ) | |
| # git clone -b 8.56_bis https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/modules | |
| Start-Process "git" -ArgumentList $git_clone_args -Wait -NoNewWindow | |
| # Pull down the manifests, e.g. site.pp | |
| $git_clone_args = @( | |
| "clone" | |
| "https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/manifests" | |
| ) | |
| # git clone https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/manifests | |
| Start-Process "git" -ArgumentList $git_clone_args -Wait -NoNewWindow | |
| # Set the ssl keys | |
| Set-Location -Path (Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "secure") | |
| $git_clone_args = @( | |
| "clone" | |
| "https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/keys" | |
| ) | |
| # git clone https://imstfs.bisinfo.org/tfs/ProdBIS/PeoplesoftCMA/_git/keys | |
| Start-Process "git" -ArgumentList $git_clone_args -Wait -NoNewWindow | |
| # cd /d d:\psoft\dpk\puppet | |
| Set-Location -Path (Join-Path(Join-Path $local_dpk_base "dpk") "puppet") | |
| # move /Y D:\psoft\dpk\puppet\production\data\environment.conf | |
| Move-Item -Path (Join-Path(Join-Path(Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") "data") "environment.conf") | |
| # move /Y D:\psoft\dpk\puppet\production\data\puppet.conf . | |
| Move-Item -Path (Join-Path(Join-Path(Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") "data") "puppet.conf") | |
| # move /Y D:\psoft\dpk\puppet\production\data\eyaml.yaml . | |
| Move-Item -Path (Join-Path(Join-Path(Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") "data") "eyaml.yaml") | |
| # move /Y D:\psoft\dpk\puppet\production\data\hiera.yaml . | |
| Move-Item -Path (Join-Path(Join-Path(Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") "data") "hiera.yaml") | |
| # move /Y D:\psoft\dpk\puppet\production\data\facts_test.yaml C:\ProgramData\PuppetLabs\facter\facts.d\facts.yaml | |
| Move-Item ` | |
| -Path (Join-Path(Join-Path(Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") "data") "facts_test.yaml") ` | |
| -Destination "C:\ProgramData\PuppetLabs\facter\facts.d\facts.yaml" ` | |
| -Force | |
| # del D:\psoft\dpk\puppet\production\data\facts.yaml | |
| Remove-Item ` | |
| -Path (Join-Path(Join-Path(Join-Path(Join-Path(Join-Path $local_dpk_base "dpk") "puppet") "production") "data") "facts.yaml") | |
| # Return to the original directory | |
| Set-Location $current_directory | |
| } | |
| function copy_archive_files { | |
| # Copy the archive files from the network to the local drive | |
| Write-Host " **** Copying the archive files - Started - $(Get-Date) ****" | |
| Get-ChildItem $network_archive_base -Filter *.tgz | Copy-Item -Destination (Join-Path(Join-Path $local_dpk_base "dpk") "archives") | |
| Write-Host " **** Copying the archive files - Ended - $(Get-Date) ****" | |
| } | |
| . create_directory_structures | |
| . copy_software_utilities | |
| . install_puppet | |
| . install_hiera_eyaml | |
| . pull_down_repos | |
| . copy_archive_files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment