Sean Kamath
2012-Dec-05 00:07 UTC
[Puppet Users] Strange issue with create_resources and exec ''command'' parameter
Hi. I''ve done some googling, and did find something sort of similar in a bug report (see http://projects.puppetlabs.com/issues/16082 and the second to last update -- but as I created this post, I realize it''s almost certainly not related at all). In a bunch of narrowing, I''ve found that apparently when you create the resources using "create_resources" for the built-in type ''exec'', it completely ignores that ''command'' argument. Here''s that test: foo.pp: -------- $other = { ''/bin/false'' => { command => ''/bin/echo hello'', }, } create_resources(''exec'', $other) -------- And the output from puppet apply foo.pp: err: /Stage[main]//Exec[/bin/false]/returns: change from notrun to 0 failed: /bin/false returned 1 instead of one of [0] notice: Finished catalog run in 0.29 seconds Note that though the resource is created with a title of ''/bin/false'' (according to the docs on puppetlabs.com), with the parameter "command" set to ''/bin/echo hello''. However, /bin/false is executed. The command is NOT ignored if the resource is instantiated outside of the create_resources() function: foo.pp: -------- exec { ''/bin/false'': command => ''/bin/echo hello'' } -------- And the output from puppet apply foo.pp: notice: /Stage[main]//Exec[/bin/false]/returns: executed successfully notice: Finished catalog run in 0.32 seconds In this case, the title is /bin/false, but the echo is called (or true, or whatever you want to run). Am I missing something, or is this a bug? It''s an odd one as well, because I *really* want to create titles that are arbitrary names, and specify a command. Fortunately, the ''name'' parameter, which is used instead of ''command'' if ''command'' is not found, works. Thanks for any help. Sean -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Gary Larizza
2012-Dec-05 00:17 UTC
Re: [Puppet Users] Strange issue with create_resources and exec ''command'' parameter
I know this sounds odd, but what if you put command in quotes in your hash, like this: $stuff = { ''/bin/false'' => { ''command'' => "/bin/echo ''hello there''" } } create_resources(''exec'', $stuff) This seems to work for me - does it work for you? On Tue, Dec 4, 2012 at 4:07 PM, Sean Kamath <sean.kamath@pdi.dreamworks.com>wrote:> Hi. > > I''ve done some googling, and did find something sort of similar in a > bug report (see http://projects.puppetlabs.com/issues/16082 and the > second to last update -- but as I created this post, I realize it''s > almost certainly not related at all). > > In a bunch of narrowing, I''ve found that apparently when you create > the resources using "create_resources" for the built-in type ''exec'', > it completely ignores that ''command'' argument. Here''s that test: > > foo.pp: > -------- > $other = { > ''/bin/false'' => { command => ''/bin/echo hello'', }, > } > create_resources(''exec'', $other) > -------- > > And the output from puppet apply foo.pp: > > err: /Stage[main]//Exec[/bin/false]/returns: change from notrun to 0 > failed: /bin/false returned 1 instead of one of [0] > notice: Finished catalog run in 0.29 seconds > > Note that though the resource is created with a title of ''/bin/false'' > (according to the docs on puppetlabs.com), with the parameter > "command" set to ''/bin/echo hello''. However, /bin/false is executed. > > The command is NOT ignored if the resource is instantiated outside of > the create_resources() function: > > foo.pp: > -------- > exec { ''/bin/false'': > command => ''/bin/echo hello'' > } > -------- > > And the output from puppet apply foo.pp: > > notice: /Stage[main]//Exec[/bin/false]/returns: executed successfully > notice: Finished catalog run in 0.32 seconds > > In this case, the title is /bin/false, but the echo is called (or > true, or whatever you want to run). > > Am I missing something, or is this a bug? It''s an odd one as well, > because I *really* want to create titles that are arbitrary names, and > specify a command. Fortunately, the ''name'' parameter, which is used > instead of ''command'' if ''command'' is not found, works. > > Thanks for any help. > > Sean > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- Gary Larizza Professional Services Engineer Puppet Labs -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Jakov Sosic
2012-Dec-16 00:30 UTC
Re: [Puppet Users] Strange issue with create_resources and exec ''command'' parameter
On 12/05/2012 01:17 AM, Gary Larizza wrote:> > $stuff = { ''/bin/false'' => { ''command'' => "/bin/echo ''hello there''" } } > create_resources(''exec'', $stuff)Doesn''t work here, puppet 3.0.1, rhel6... # puppet apply test.pp Error: /bin/false returned 1 instead of one of [0] Error: /Stage[main]//Exec[/bin/false]/returns: change from notrun to 0 failed: /bin/false returned 1 instead of one of [0] Finished catalog run in 0.16 seconds -- Jakov Sosic www.srce.unizg.hr -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.