Discussion:
[Puppet Users] Failed to execute a command using the exec resource on Windows
b***@gmail.com
2013-10-02 14:41:35 UTC
Permalink
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
--
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
2013-10-02 17:50:21 UTC
Permalink
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?
Post by b***@gmail.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]
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
--
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
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 2014, September 23-24 in San Francisco
--
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.
Fernando Torres
2013-10-02 19:26:56 UTC
Permalink
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.
Post by b***@gmail.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]
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
--
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
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.
--
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.
b***@gmail.com
2013-10-02 21:13:10 UTC
Permalink
It's the path, you are right. After I set it, it ran successfully.

Thanks!
Post by Fernando Torres
Did you provide the path attribute in your exec resource?
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.
Post by b***@gmail.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]
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
--
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
.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.
--
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.
Loading...