Which attribute would you include in an exec resource to ensure it runs only when notified?

Prepare for the Puppet Certified Professional Test with flashcards and multiple choice questions, each with hints and explanations. Gear up for your exam!

In Puppet, the attribute that should be included in an exec resource to ensure it runs only when notified is "refreshonly." This attribute allows the exec resource to be triggered to run only in response to a notification, which is generally from another resource that has changed. When "refreshonly" is set to true, the exec does not run during the initial Puppet agent run unless it receives a notification indicating that it should.

For example, if you have a service that, when restarted, should also execute a command defined in an exec resource, you can notify that exec resource on the service's restart. This avoids unnecessary execution of the command, ensuring that it runs only when a specific event occurs, conserving system resources and reducing potential errors.

The other available options do not facilitate the same functionality as "refreshonly." For instance, "onlyif" is used to determine whether an exec resource should be executed based on the success or failure of a command, while "creates" checks for the existence of a file or directory before running the exec. "Unless" is similar to "onlyif" but acts inversely, running the exec resource unless a certain condition is met. These attributes are useful in different contexts but do not specifically confine execution to situations

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy