Ask Your Question

generate executes inside exec regardless of onlyif or unless exit code

asked 2017-10-05 17:59:15 -0600

thedude gravatar image

The generate function inside this exec runs without regard for the exit status in onlyif. I have tried the same thing with unless and generate always executes, regardless of exit code.

exec { "execute_command_on_master":
  path => [ "/bin/", "/usr/bin/", ],
  onlyif => "/bin/false",
  command => generate("/tmp/"),

Here is the test script:

cat /tmp/

/bin/echo `date` >> /tmp/testfile

Is this expected behavior?


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-10-06 07:41:22 -0600

DarylW gravatar image

updated 2017-10-06 07:43:28 -0600

The exec will not run, but the generate method is still run to create the output passed into the exec's command parameter

As far as I know, the generate method is always invoked where the catalog is complied, which is on the puppet master in a typical set up, or locally if you are running a puppet apply (either directly, or through a 'masterless' configuration)

Generate Documentation


Calls an external command on the Puppet master and returns the results of the command. Any arguments are passed to the external command as arguments. If the generator does not exit with return code of 0, the generator is considered to have failed and a parse error is thrown. Generators can only have file separators, alphanumerics, dashes, and periods in them. This function will attempt to protect you from malicious generator calls (e.g., those with ‘..’ in them), but it can never be entirely safe. No subshell is used to execute generators, so all shell metacharacters are passed directly to the generator. •Type: rvalue

edit flag offensive delete link more


Thanks DarylW!

thedude gravatar imagethedude ( 2017-10-06 14:02:01 -0600 )edit

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


Asked: 2017-10-05 17:59:15 -0600

Seen: 119 times

Last updated: Oct 06 '17