Resources
A resource is how you describe the desired state of your infrastructure. They represent a thing you want to manage and they are backed by providers which implement the actual management for your Operating System.
Each resource has a type and a unique name followed by some resource-specific properties.
Common Properties
Resources can all have additional monitoring / health checks associated with them. See the Monitoring page for more information.
All resources can have an alias set which will be used in logging and to find resources for subscribe, require etc
All resources can have a require property that is a list of type#name or type#alias that must have succeeded before this resource can be applied.
Exec
When you manage an exec resource, you describe a command that should be executed to bring the system into the desired state. The exec resource is idempotent when used with the creates property or refreshonly mode.
Warning
Commands should be specified with their full path, or use the path property to specify the search path
In a manifest:
On the CLI:
This will run the command only if /tmp/hello does not exist.
Ensure Values
The ensure property does not have meaning for the exec resource.
Properties
| Property | |
|---|---|
name | The command to execute |
ensure | The desired state |
cwd | The working directory from which to run the command |
environment (array) | Additional environment variables in KEY=VALUE format |
path | The search path for executables, as a colon-separated list (e.g., /usr/bin:/bin) |
returns (array) | Expected exit codes indicating success; defaults to 0 |
timeout | Maximum time the command is allowed to run (e.g., 30s, 5m); command is killed if exceeded |
creates | A file that the command creates; if this file exists the command will not run |
refreshonly (boolean) | Only run the command when notified by a subscribed resource |
subscribe (array) | Resources to subscribe to for refresh notifications in the format type#name or type#alias |
logoutput (boolean) | Whether to log the command’s output |
provider | Force a specific provider to be used, only posix supported |
File
When managing a file you have to state the content, owner, group and mode the file should be.
Warning
You should use absolute file names and primary group names
The file type is very minimal at the moment, most important TODO items:
- Source file contents from elsewhere
- Support creating symlinks
- More complete templating for contents
In a manifest:
On the CLI:
This will copy the contents of /tmp/ccm/motd to /etc/motd verbatim and set the ownership.
If you specify --contents or --contents-file instead then the result will be parsed by a template and rendered as the contents.
Ensure Values
| Ensure Values | |
|---|---|
present | The file must be nonexisting |
absent | The file must exist |
directory | The file must be a directory |
Properties
| Ensure Values | |
|---|---|
name | The resource name match the file name exactly |
ensure | The desired state |
content | The contents of the file, parsed through expr |
source | Copy another file, in future will support remote sources |
owner | The file owner |
group | The file group |
mode | The file mode, a string like 0700 |
provider | Force a specific provider to be used, only postix supported |
Package
When you manage a package, you describe the stable state you desire. Should the package merely be present, or the latest version, or a specific version?
Warning
You should use real package names, not virtual names, aliases or group names
In a manifest:
On the CLI:
Ensure Values
| Ensure Values | |
|---|---|
present | The package must be installed. |
latest | The package must be installed and the latest version. |
absent | The package must be not be installed. |
5.9 | The package must be installed and version 5.9. |
Properties
| Ensure Values | |
|---|---|
name | The resource name match the package name exactly |
ensure | The desired state |
provider | Force a specific provider to be used, only dnf supported |
Service
When you manage a service, you describe the stable state you desire. Unlike packages services have 2 properties that can very - are they enabled to start at boot or should they be running.
Warning
You should use real service names, not virtual names, aliases etc
Additionally, a service can listen to the state changes of another resource, and, should that resource change it can force a restart of the service.
In a manifest:
On the CLI:
Ensure Values
| Ensure Values | |
|---|---|
running | The service must be running. |
stopped | The service must be stopped. |
Properties
| Ensure Values | |
|---|---|
name | The resource name match the service name exactly |
ensure | The desired state |
enable (boolean) | Enables the service to start at boot time |
subscribe (array) | When the service is set to be running, and it’s already running, restart it when the referenced resource changes. In the format type#name or type#alias |
provider | Force a specific provider to be used, only systemd supported |