Created
November 6, 2017 22:07
-
-
Save GeoffWilliams/a2d47704f017a759039b8cea1a7c7cf9 to your computer and use it in GitHub Desktop.
Install puppet agent and hosts file on windows
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
| $puppet_master_host="MY.PUPPET.MASTER.COM" | |
| $puppet_master_ip="6.6.6.6" | |
| $hostname = $env:computerName | |
| # fix /etc/hosts if required | |
| $puppet_master_resolved = $false | |
| try { | |
| $puppet_master_resolved = ([system.net.dns]::gethostbyName($puppet_master_host) ) | |
| } catch {} | |
| if ($puppet_master_resolved -and $puppet_master_resolved.AddressList[0].IPAddressToString -eq $puppet_master_ip ) { | |
| "puppet host already resolves OK" | |
| } else { | |
| # add a hosts entry for puppetmaster | |
| ac -Path "C:\WINDOWS\system32\drivers\etc\hosts" -Value ("`r`n" + $puppet_master_ip + " " + $puppet_master_host + "`r`n") | |
| } | |
| "Proceeding to install puppet..." | |
| [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; $webClient = New-Object System.Net.WebClient; $webClient.DownloadFile('https://' + $puppet_master_ip + ':8140/packages/current/install.ps1', 'install.ps1'); .\install.ps1 custom_attributes:challengePassword=$shared_secret extension_requests:pp_role=$puppet_role -WarningAction SilentlyContinue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment