RexOps / rexify-website

Website content and code for rexify.org
https://www.rexify.org
14 stars 31 forks source link

Clarify resource vs task? #159

Closed djzort closed 2 years ago

djzort commented 2 years ago

From this page https://github.com/RexOps/rexify-website/blame/master/content/docs/rex_book/writing_modules/writing_custom_resources.md#L86 it seems there is a different thing from 'task' called 'resource'

Rex::Resource doesnt have much by way of pod to help explain.

Could someone elaborate on the differences and the use cases?

krimdomu commented 2 years ago

A task is a description of what your server should look like. A collection of "things" rex should do. Like install a package, create a file, start a service.

A resource is the "thing" you put inside a task. like the package, the file, the service.

# task = a collection of resources that should be realized on the server
task mytask => sub {
   package "foo", ensure => "present";    # <<<-- package is a resource
   file "/tmp/foo", ensure => "present", content = "Hello World";    # <<<-- file is a resource
};

With the Rex::ResourceModule it is easy to create custom resources. This module creates an abstraction to select the right resource code for the operating system on which the code should be executed on. It also adds automatically reporting to that resource and common hooks like on_change.

ferki commented 2 years ago

Thanks for asking, @djzort!

As @krimdomu pointed out (thanks!):

For the sake of completeness, it might be helpful to also mention one more context around resources:

I'd like to take this chance to link our various support channels awaiting similar questions you might have later.

djzort commented 2 years ago

Thanks for the explanation. By creating a hg issue i was also hoping that the pod & docs could be improved.

ferki commented 2 years ago

Thanks for the explanation. By creating a hg issue i was also hoping that the pod & docs could be improved.

The Rex documentation itself lives in the RexOps/Rex repo, so related work will be tracked and carried out over there :)