Failed to execute a command using the exec resource on Windows

859 views
Skip to first unread message

beyonddc...@gmail.com

unread,
Oct 2, 2013, 10:41:35 AM10/2/13
to puppet...@googlegroups.com
I am having a difficult time to determine the cause of why my exec resource failed to execute a command on Windows.

Here's the error message reproduced by the Puppet on the windows machine when I ran 'puppet agent --test'.

Error: cmd.exe /c ruby -e "File.open('c:\replace_me', 'w') { |f| f.write(File.read('C:/Documents and Settings/All Users/Application Data/PuppetLabs/puppet/var/replace_me')) }" returned 1 instead of one of [0]

Error: /Stage[main]/Windows_95d7fd26_b0e4_4642_9eb0_a06de0ea2fc7_1380724354040/Exec[rem_a8159a47_5507_4731_9d5f_1587fa8d5803_824177284125062]/returns: change from notrun to 0 failed: cmd.exe /c ruby -e "File.open('c:\replace_me', 'w') { |f| f.write(File.read('C:/Documents and Settings/All Users/Application Data/PuppetLabs/puppet/var/replace_me')) }" returned 1 instead of one of [0]

Notice: Finished catalog run in 2.06 seconds

If I copied and pasted the command manual to a command prompt on Windows then the command would run successfully.  It's just that it when running it with Puppet then it would failed.  Please let know if you see any issue with my command or if there's any debug technique that I should try.

Thanks!

David

Rob Reynolds

unread,
Oct 2, 2013, 1:50:21 PM10/2/13
to puppet...@googlegroups.com
Can you verify the user running the service has access to the folder?

Also, can you please post your manifest?  And if you wouldn't mind, please run 'puppet agent --test --trace --debug --verbose' and attach that output as well?


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Rob Reynolds
Developer, Puppet Labs

Join us at PuppetConf 2014September 23-24 in San Francisco

Fernando Torres

unread,
Oct 2, 2013, 3:26:56 PM10/2/13
to puppet...@googlegroups.com
Did you provide the path attribute in your exec resource?

Some like that:

exe {'execute pretty command':
   command => 'cmd.exe /c echo 'hello world',
   path => $::path
}

$::path is a variable that contains all paths contained in this user profile. you can also define it hardcoded. Note: you must have c:\windows\system32 (for cmd.exe) and your ruby bin directory in your path in order your command run well.


--

beyonddc...@gmail.com

unread,
Oct 2, 2013, 5:13:10 PM10/2/13
to puppet...@googlegroups.com
It's the path, you are right.  After I set it, it ran successfully.

Thanks!
Reply all
Reply to author
Forward
0 new messages