Closed djzort closed 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::Resource
Module 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
.
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:
unlink($path)
to delete $path
on the managed target)file $file, ensure => 'absent'
makes sure $path
doesn't exist on the managed target, and figures out how to do that (if $path
exists, then rex deletes it, and it might take different actions whether it's a file, directory, etc.; if $path
doesn't exist, then rex does nothing, and so on)I'd like to take this chance to link our various support channels awaiting similar questions you might have later.
Thanks for the explanation. By creating a hg issue i was also hoping that the pod & docs could be improved.
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 :)
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?