Ask Your Question
1

Are conditionals parsed by the puppet master for catalog compilation purposes?

asked 2017-01-13 14:00:14 -0500

jimethn gravatar image

Let's say I have a conditional like:

exec { "run this command":
  unless => "test -f /var/run/somefile",
  ...
}

When the puppet master compiles the catalog for the agent, is the conditional evaluated by the master or the agent?

That is -- does the master tell the agent "run this command unless this value is true", or does the master say "hey agent, is the value true?" and the agent says "yes" so the master doesn't tell it about the command.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-01-14 22:15:00 -0500

DarylW gravatar image

updated 2017-01-14 22:15:42 -0500

An exec has creates and only_if and unless parameters. The creates case is checked first when applying the catalog to the agent after it was compiled by the master, and if the file creates points to doesn't exist, the unless and only_if checks are run and evaluated. This can be seen in your agent/apply output in debug mode.

If the file that creates references doesn't exist, and if any only_if statements return 1, or if any unless statements return 0, then the exec is executed.

edit flag offensive delete link more
0

answered 2017-01-14 23:41:27 -0500

lavaman gravatar image

updated 2017-01-14 23:42:50 -0500

A compiled puppet catalog has all of the resources defined in the classes that are applied to the node for which the catalog was compiled. All variables are filled in and all templates generated and the results appear in the compiled catalog. The compiled catalog does include any commands used in only_if and unless parameters to exec resources. The application of the compiled catalog causes those commands to be run locally without any interaction with the master. Agent runs only contact the master to do SSL cert negotiation, perform pluginsync provide facter values, ask for a catalog, possibly download files, and possibly report back to the master with the results of the run. The master does not generally contact the agent nodes unless you are running something like MCollective commands or Puppet jobs from the PE Console.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-01-13 14:00:14 -0500

Seen: 13 times

Last updated: Jan 14