Skip to content

Instantly share code, notes, and snippets.

@Jnchi
Last active June 4, 2019 15:50
Show Gist options
  • Save Jnchi/ddfdcb654bd23ff48ecf264a932ef685 to your computer and use it in GitHub Desktop.
Save Jnchi/ddfdcb654bd23ff48ecf264a932ef685 to your computer and use it in GitHub Desktop.
Install Puppet Agent on Windows 10
# Installs Puppet Agent on Windows 10
# https://puppet.com/docs/puppet/6.4/install_agents.html#install-unattended-from-the-command-line
# SPDX-License-Identifier: GPL-3.0-or-later
$arch = "x64"
$puppet_version = "puppet6"
$version = "latest"
$installer = "puppet-agent-$($arch)-$($version).msi"
$server = "puppet.localdomain"
$port = "8140"
if (-Not (Test-Path .\$installer -PathType Leaf)) {
echo "Fetching installer..."
Invoke-WebRequest "https://downloads.puppetlabs.com/windows/$($puppet_version)/$($installer)" -OutFile $installer
}
echo "Installing Puppet Agent..."
$ret = (Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /norestart /i $installer PUPPET_MASTER_SERVER=$server" -Wait -Passthru).ExitCode
if ($ret -eq 0) {
echo "OK"
} else {
echo "Error: $ret"
}
echo "Configuring Puppet Agent..."
$ret = (Start-Process -FilePath "C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat" -ArgumentList "config set masterport $port" -Wait -Passthru).ExitCode
if ($ret -eq 0) {
echo "OK"
} else {
echo "Error: $ret"
}
@Jnchi
Copy link
Author

Jnchi commented Apr 16, 2019

The file is not digitally signed.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\bootstrap_puppet_agent.ps1

@Jnchi
Copy link
Author

Jnchi commented Apr 16, 2019

Warning: getaddrinfo: No such host is known.

Append the following to C:\Windows\System32\Drivers\etc\hosts:

{{ip_address}} puppet puppet.localdomain

@Jnchi
Copy link
Author

Jnchi commented May 31, 2019

The system cannot find the file specified.

PS C:\Users\LucasRamage\Downloads> .\bootstrap_puppet_agent.ps1
Fetching installer...
Installing Puppet Agent...
OK
Configuring Puppet Agent...
Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At C:\Users\LucasRamage\Downloads\bootstrap_puppet_agent.ps1:25 char:9
+ $ret = (Start-Process -FilePath "puppet.bat" -ArgumentList "config se ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

OK

Even though puppet agent was installed, the following directory was not in the PATH:

C:\Program Files\Puppet Labs\Puppet\bin\

@Jnchi
Copy link
Author

Jnchi commented May 31, 2019

Warning: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get issuer certificate for /CN=Puppet CA: puppet.localdomain]

puppet agent --server puppet.localdomain --waitforcert 60 -t --verbose --debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment