Skip to content

Instantly share code, notes, and snippets.

Created May 6, 2020 14:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
.conf 2020 user provisioning script
# Escape any variables that are not passed by Terraform ($$)
$hostname = "${hostname}"
# Set NODENAME Env Var
[Environment]::SetEnvironmentVariable("NODENAME", $hostname)
[Environment]::SetEnvironmentVariable("NODENAME", $hostname, [System.EnvironmentVariableTarget]::Machine)
# Add hosts Entry
# This is needed so the pt_pia status checking works
# The cloned instance does not update hosts, so we do it ourselves
$fqdn="$(facter fqdn)"
$ipaddr="$(facter ipaddress)"
add-content -path c:\windows\system32\drivers\etc\hosts -value "`n127.0.0.1 $${fqdn}"
add-content -path c:\windows\system32\drivers\etc\hosts -value "$${ipaddr} $${fqdn}"
add-content -path c:\windows\system32\drivers\etc\hosts -value "$${ipaddr} ps-terraform"
# Add java to PATH
# This also fixes the pt_pia status checking script
$jdk_home="$(hiera jdk_location -c C:\psft\dpk\puppet\hiera.yaml)"
[Environment]::SetEnvironmentVariable("PATH", "$${env:PATH};$${jdk_home}\bin")
[Environment]::SetEnvironmentVariable("PATH", "$${env:PATH};$${jdk_home}\bin", [System.EnvironmentVariableTarget]::Machine)
# JMeter
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13, [Net.SecurityProtocolType]::Tls12
iwr -outfile $env:TEMP\
expand-archive $env:TEMP\ -destination c:\app\
[Environment]::SetEnvironmentVariable("PATH", "$${env:PATH};$${jmeter}\bin", [System.EnvironmentVariableTarget]::Machine)
remove-item $env:TEMP\
# Elasticsearch
$find=" localhost"
(Get-Content $file).replace($find, $replace) | Set-Content $file
restart-service elasticsearch-service-x64
# Start PIA
start-service psftpia*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment