A resource is the basic unit that is managed by Puppet. Each resource has a set of attributes describing its state. Some attributes can be changed throughout the lifetime of the resource, whereas others are only reported back but cannot be changed, and some can only be set one time during initial creation.
A custom resource allows you to interact with something external. Three common use cases for this are:
Parsing a file
Running a command line tool
Communicating with an API
To gather information about a resource and to enact changes on it, Puppet requires a provider to implement interactions. The provider can have parameters that
influence its operation. To describe all these parts to the infrastructure and the
consumers, the resource type defines all the
metadata, including the list of the attributes. The provider contains the code
set the system state.
If you are starting from scratch, or want a simple method for writing types and providers, use the Resource API. Built on top of Puppet core, the Resource API makes the type and provider development easier, cheaper, safer, faster, and better. If you need to maintain existing code, need multiple providers, or need access to the catalog, use the old low-level types and providers method.