Using the create and destroy methods

The existence state of a resource is modified with reference to the declaration of the resource with the ensure property by the user in the Puppet DSL by using the create and destroy methods.

The create method is called when both of the following criteria have been met:

  • The ensure property has been set to present in the resource declaration
  • The false value is returned by the exists? method (to indicate that the resource doesn't already exist)

The destroy method is called when both of the following criteria have been met:

  • The ensure property has been set as absent in the resource declaration
  • The true value is returned by the exists? method (to indicate that the resource already exists)

The following ...

Get Mastering Puppet 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.