Ask Your Question

what is the diff btw puppet apply and puppet apply -e

asked 2018-07-14 15:08:54 -0600

robinhood gravatar image

puppet apply puppet apply -e The manual just says -e execute a piece of puppet code. I wish there was more explanation on this.

Use case when applying a motd_erb.pp file, I could not do it with the -e So I realized I do not understand the diff between using the option and not using it.

puppet apply -e motd_erb.pp Error: Evaluation Error: Unknown function: 'pp'. (line: 1, column: 9) on node


puppet apply motd_erb.pp <<- no -e used here Notice: Compiled catalog for in environment test in 0.04 seconds Notice: /Stage[main]/Main/File[/etc/motd]/content: content changed '{md5}d41d8cd98f00b204e9800998ecf8427e' to '{md5}383a13fbbb6d2e4c0c61c7a0d232b5eb' Notice: Applied catalog in 0.33 seconds

The reason I used the -e is because it was required for commands like: puppet apply -e 'include ntp' When I searched online information seemed very sparse. Thx

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-07-15 20:04:17 -0600

DarylW gravatar image

updated 2018-07-15 20:09:36 -0600

The -e argument for puppet apply is similar to ruby and perl, (which means 'expression' for those languages, though the long form from puppet is --execute). it is expected to take a snippet of syntactically correct puppet code as an argument. When you run puppet apply somefile.pp, it is expected that you are passing a file containing syntactically valid puppet code.

If you wish to include complete modules (which conform to standard module layout) and use them with your puppet apply -e command, be sure to use the --modulepath parameter (which is shown in an example, but not described by puppet apply -h)

$ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server"
edit flag offensive delete link more

answered 2018-07-15 15:53:25 -0600

robinhood gravatar image

updated 2018-07-15 15:54:53 -0600

One thing I've found so far beyond the general 'executes puppet code' which maybe means 'to the manifest', and without -e, maybe it just applies the code to the local node, like content is written to a conf file, is:

The one exception is the main manifest. Puppet apply always requires a single command line argument, which acts as its main manifest. It ignores the main manifest from its environment.

(Alternately, you can write a tiny main manifest directly on the command line, with the -e option.

This might take me further in my speculation as to why I could use -e with 'include <class> or <resource>', but not with 'include <template>' located in the template directory???

Still not fully answered.

edit flag offensive delete link more


if you are going to include something, you can only include the class. a template needs to be called by some valid puppet code (a class or a define), and the value for the template with be evaluated and written out to a string, which can be passed as a parameter to a resource (typically a file)

DarylW gravatar imageDarylW ( 2018-07-15 20:05:58 -0600 )edit

Also, if you wish you use some puppet code not in the 'standard location' with puppet apply (with our without a -e), you would need to set the `--modulepath` parameter, as shown in the `puppet apply -h` output

DarylW gravatar imageDarylW ( 2018-07-15 20:08:04 -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: 2018-07-14 15:08:54 -0600

Seen: 103 times

Last updated: Jul 15