Using example commands
These guidelines can help you understand and customize the example commands you'll find in the Puppet Enterprise (PE) docs.
Ports, paths, and other input
Some examples in the PE docs use puppet
commands to populate variables and curl
arguments. This can take the guesswork out of providing those values. In the
following example, the puppet config print server
command supplies the DNS name for a curl
command:
url="http://$(puppet config print server):4433" curl "$url"
In these examples, puppet
commands generate cert
paths:
--cert $(puppet config print --section main hostcert) \ --key $(puppet config print --section main hostprivkey) \ --cacert $(puppet config print --section main localcacert) \
puppet
commands can return different values depending
on various conditions. Make sure you run the entire example (including commands
setting environment variables and the curl
command)
as the root, administrator, or with equivalent elevated privileges.
To run such commands on a machine without elevated privileges, you must replace the
puppet
commands with hard-coded values. If
you’re unsure about the correct values, run the puppet
commands to get reasonable default values.
Authentication tokens in curl commands
If a curl
command requires token-based
authentication, the example might contain this line:
auth_header="X-Authentication: $(puppet-access show)"
If you have an actual authentication token available, you can use that in the command instead, such as:
auth_header="X-Authentication: <TOKEN>"
For instructions on generating, configuring, revoking, and deleting authentication tokens in PE, go to Token-based authentication.
Modifications for Windows
While the commands in the PE docs are primarily *nix-based, Windows-specific commands are provided in topics focusing exclusively on Windows systems.
\
) as line-continuation characters.
In Windows, the equivalent characters are carets
(^
) and, for PowerShell specifically, backticks (`
).Additionally, *nix commands use forward slashes (/
) as
directory separator characters. You might use either backslashes or forward
slashes as directory separator characters in your Windows commands; however some modules and
commands require you to use one or the other. For modules, check the
module's Forge page for information about Windows modifications or
requirements.
Furthermore, Windows commands might require wrapping strings or arguments in double quotes rather than single quotes.
There are various options for running curl
commands
directly in Windows, such as:
- Installing the curl executable for Windows.
- Using built-in curl functionality included with Git for Windows.
- Using the GNU Bash shell.
If you're using PowerShell, you can use these
equivalent commands to modify *nix curl
commands for use in Windows:
Native curl |
PowerShell equivalent |
---|---|
curl
|
Invoke-WebRequest
|
-k or --insecure |
[System.Net.ServicePointManager]::ServerCertificateValidationCallback
= $true
|
-H
|
-Headers
|
-X
|
-Method
|
-d
|
-Body
|
\ (as a line-continuation
character) |
`
|
You can learn more about Invoke-WebRequest
and the arguments it accepts in the Microsoft PowerShell documentation. You can also
learn about running Puppet language commands
on Windows in the Puppet
documentation.