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:

exec:
  name: /usr/bin/touch /tmp/hello
  ensure: present
  creates: /tmp/hello
  timeout: 30s
  cwd: /tmp
  require:
    - file#/usr/bin/touch

On the CLI:

$ ccm ensure exec "/usr/bin/touch /tmp/hello" --creates /tmp/hello --timeout 30s

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
nameThe command to execute
ensureThe desired state
cwdThe working directory from which to run the command
environment (array)Additional environment variables in KEY=VALUE format
pathThe search path for executables, as a colon-separated list (e.g., /usr/bin:/bin)
returns (array)Expected exit codes indicating success; defaults to 0
timeoutMaximum time the command is allowed to run (e.g., 30s, 5m); command is killed if exceeded
createsA 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
providerForce 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:

file:
  name: /etc/motd
  ensure: present
  content: |
    Managed by CCM {{ now() }}
  owner: root
  group: root
  mode: "0644"

On the CLI:

$ ccm ensure file /etc/motd --source /tmp/ccm/motd --owner root --group root --mode 0644

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
presentThe file must be nonexisting
absentThe file must exist
directoryThe file must be a directory

Properties

Ensure Values
nameThe resource name match the file name exactly
ensureThe desired state
contentThe contents of the file, parsed through expr
sourceCopy another file, in future will support remote sources
ownerThe file owner
groupThe file group
modeThe file mode, a string like 0700
providerForce 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:

package:
  name: zsh
  ensure: 5.9

On the CLI:

$ ccm ensure package zsh 5.9

Ensure Values

Ensure Values
presentThe package must be installed.
latestThe package must be installed and the latest version.
absentThe package must be not be installed.
5.9The package must be installed and version 5.9.

Properties

Ensure Values
nameThe resource name match the package name exactly
ensureThe desired state
providerForce 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:

service:
  name: httpd
  ensure: running
  enable: true
  subscribe: package#httpd

On the CLI:

$ ccm ensure service httpd running --enable --subscribe package#httpd

Ensure Values

Ensure Values
runningThe service must be running.
stoppedThe service must be stopped.

Properties

Ensure Values
nameThe resource name match the service name exactly
ensureThe 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
providerForce a specific provider to be used, only systemd supported