Last active
March 2, 2018 11:16
-
-
Save dandoingdev/4395edbe9ac7e0f6bca2d8b07a427aef to your computer and use it in GitHub Desktop.
This file contains 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
# This script can be run from puppet using puppetlabs/powershell: | |
# exec { 'setup-ansible-remoting': | |
# command => file("${module_name}/ansible-setup-windows.ps1"), | |
# provider => powershell, | |
# logoutput => true, | |
# } | |
# To make sure that we can run local scripts. You may need to run this line manually before you can run this script | |
Set-ExecutionPolicy unrestricted | |
# Doing this the hard way for old versions of powershell that don't interpolate and don't support Invoke-WebRequest | |
$t = [Environment]::ExpandEnvironmentVariables('%TEMP%') | |
# Sometimes the temp dir for the user executing this doesn't exit (yet) | |
if ((Test-Path $t) -eq $false) { | |
md $t | |
} | |
$WebClient = New-Object System.Net.WebClient | |
# Check and upgrade powershell to 3.0 if necessary (reboots machine) | |
if ($PSVersionTable.PSVersion.Major -lt 3) { | |
$WebClient.DownloadFile("https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/upgrade_to_ps3.ps1","$t\ps3upgrade.ps1") | |
& "$t\ps3upgrade.ps1" | |
Write-Host "Initiated PowerShell upgrade which will require a reboot, exiting this script" | |
exit | |
} | |
# Run ansible windows remoting setup script (does nothing if already configured) | |
$WebClient.DownloadFile("https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1", "$t\ansible-setup-remoting.ps1") | |
& "$t\ansible-setup-remoting.ps1" Enable-GlobalHttpFirewallAccess -CertValidityDays 3650 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment