Errors when applying a manifest or doing a Puppet agent run
If your manifests aren't applied, or are applied incorrectly, on Windows nodes, check for these issues.
Path or file separators are incorrect
For Windows nodes, path separators must use a
semi-colon (;
).
File separators must use forward slashes or backslashes, depending on the attribute. In most resource attributes, the Puppet language accepts either forward slashes or backslashes as the file separator. However, some attributes absolutely require forward slashes, and some attributes absolutely require backslashes.
You must escape backslashes that are double-quoted("
). When single-quoted ('
), escaping is
optional. For example, these are all valid file
resources:
file { 'c:\path\to\file.txt': } file { 'c:\\path\\to\\file.txt': } file { "c:\\path\\to\\file.txt": }
However file { "c:\path\to\file.txt": }
is an invalid
path, because \p
, \t
, and \f
are
interpreted as escape sequences.
For more information:
- Learn about Files and paths in the Puppet language on Windows in the Puppet documentation.
- Learn about Windows modifications when Using example commands that you find in the PE documentation.
Cases are inconsistent
Several resources are case-insensitive on Windows, like files, users, groups. However, these resources can be case sensitive in Puppet.
When establishing dependencies among resources, make sure to specify the case
consistently. Otherwise, Puppet can't resolve the
dependencies correctly. For example, Puppet fails to
apply the following manifest because it doesn't recognize that ALEX
and alex
are the same
user:
file { 'c:\foo\bar': ensure => directory, owner => 'ALEX' } user { 'alex': ensure => present } ... err: /Stage[main]//File[c:\foo\bar]: Could not evaluate: Could not find user ALEX
Shell built-ins are not executed
Puppet doesn't support a shell provider on Windows, so executing shell built-ins directly fails.
To troubleshoot this, use cmd.exe
to wrap the
built-in:
exec { 'cmd.exe /c echo foo': path => 'c:\windows\system32;c:\windows' }
PowerShell scripts are not executed
By default, PowerShell enforces a restricted execution policy that prevents executing scripts.
To avoid this, use the Puppet-supported PowerShell or specify the appropriate execution policy in the PowerShell command, for example:
exec { 'test': command => 'powershell.exe -executionpolicy remotesigned -file C:\test.ps1', path => $::path }
Services are referenced by display names instead of short names
Windows services support a short name and a display name, but Puppet uses only short names.
Verify that your Puppet manifests use the short names,
such as wuauserv
instead of Automatic Updates
.