Ask Your Question
0

Error with file resource type on windows

asked 2015-07-07 17:46:12 -0500

R gravatar image

updated 2015-07-07 19:14:58 -0500

I am having a issue with the spaces in the file path

  file { 'ldap':
    path => "C:\\Program Files\(x86\)\\stunnel\\stunnel.conf",
    owner =>'ldapadmin',
    group => 'Administrators',
    mode => '0755',
    ensure => file,
    source => "puppet:///modules/ldapconfig/stunnel.conf",
}

Even after I remove the escape characters before/after the paranthesis like this

  path => "C:\\Program Files(x86)\\stunnel\\stunnel.conf",

When I run the puppet agent -t I get the following error:

Error: Could not set 'file' on ensure: No such file or directory - C:/Program Files/(x86/)/stunnel/stunnel.conf20150707-11892-1r07aqx.lock at 55:/etc/puppetlabs/puppet/r10kenvironments/dev/modules/ldapconfig/manifests/init.ppError: Could not set 'file' on ensure: No such file or directory - C:/Program Files/(x86/)/stunnel/stunnel.conf20150707-11892-1r07aqx.lock at 55:/etc/puppetlabs/puppet/r10kenvironments/dev/modules/ldapconfig/manifests/init.pp Wrapped exception: No such file or directory - C:/Program Files/(x86/)/stunnel/stunnel.conf20150707 -11892-1r07aqx.lock Error: /Stage[main]/ldapconfig/File[ldap]/ensure: change from abse nt to file failed: Could not set 'file' on ensure: No such file or directory - C :/Program Files/(x86/)/stunnel/stunnel.conf20150707-11892-1r07aqx.lock at 55:/et c/puppetlabs/puppet/r10k_environments/dev/modules/ldapconfig/manifests/i nit.pp

Please let me know what am I missing.

Thanks a lot

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2015-07-09 06:38:10 -0500

sinned gravatar image

I would try two things:

first:

path => "C:\\Program Files (x86)\\stunnel\\stunnel.conf",

(different escaping)

second:

path => 'C:\Program Files (x86)\stunnel\stunnel.conf',

(single quotes)

My guess is that both of these work, because you might have gotten the escape sequences wrong.

edit flag offensive delete link more
0

answered 2015-07-11 05:37:26 -0500

helge gravatar image

updated 2015-07-11 06:05:24 -0500

Have a look at your output: No such file or directory - C:/Program Files/(x86/)/stunnel/stunnel.conf20150707-11892-1r07aqx.lock

Please especially note the part: ...Files/(x86/)/stunnel...

I figure such a target directory does not exist.

I highly recommend writing your path like:

path => 'C:/Program Files (x86)/stunnel/stunnel.conf',

Hint: Even on Windows, do use the forward slash / as separator most of the times. It works through ruby and WIndows does support these paths nowadays with most its binary (= non cmd-shell) commands also, and completely in PowerShell (AFAIK ;).

There are notable exceptions, Puppet Docs:

Forward-Slashes Only Forward slashes MUST be used in: Template paths (e.g. template('my_module/content.erb')) puppet:/// URLs

Forward- and Backslashes Both Allowed You can choose which kind of slash to use in: The path attribute or title of a file resource The source attribute of a package resource Local paths in a file resource’s source attribute The command of an exec resource, unless the executable requires backslashes, e.g. cmd.exe

Backslashes Only Backslashes MUST be used in: Any file paths included in the command of a scheduledtask resource. Any file paths included in the installoptions of a package resource.

If I run in one of the cases where must use backslaches, I rather use regsubst(), a standard puppet function:

$path = 'C:/Windows/temp/test'
$winpath = regsubst($path, '/', '\\\\\\', 'G') # $winpath: "C:\\Windows\\temp\\test"
exec {'mkdir': command => "${::system32}/cmd.exe /c md ${winpath}"}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-07 17:46:12 -0500

Seen: 732 times

Last updated: Jul 11 '15