Skip to content

Latest commit

 

History

History
77 lines (52 loc) · 2.16 KB

resources.md

File metadata and controls

77 lines (52 loc) · 2.16 KB

Resources

A resource is a statement of configuration policy that describes the desired state for an item.

Syntax

resource_type "name" {
   attribute = "value",
   action = "type_of_action",
}

For Example: a resource that is used to install a nginx package may look something like this:

software_package "nginx" {
    action = "install",
}

Resource Type

Common Attributes

All resource types have the following common attributes.

  • only_if (string): If only_if command exits with non-zero status, the resource will not be executed.

  • not_if (string): If not_if command exits with zero status, the resource will not be executed.

  • user (string): If you specified this, commands related with the resource will be executed as the user.

  • cwd (string): If you specified this, commands related with the resource will be executed on the working directory.

  • notifies: (table): If you specified this, Cofu runs other resources when the resource is updated. The syntax is like the following.

    restart httpd service:

    notifies = {"restart", "service[httpd]"}

    restart httpd service immediately:

    notifies = {"restart", "service[httpd]", "immediately"}

    restart httpd, nginx service. httpd service restarted immediately:

    notifies = {{"restart", "service[httpd]", "immediately"}, {"restart", "service[nginx]"}}
  • verify (string or table): If you specified this, runs the commands. If the result of the commands is non-zero status, Cofu exits with error.

  • description (string): If you specified this, Cofu show this description when the resource evaluates.

Common Actions

All resource types support the following common actions.

  • nothing: Nothing to do.