Resources

Resources describe the desired state of your infrastructure. Each resource represents something to manage and is backed by a provider that implements platform-specific management logic.

Every resource has a type, a unique name, and resource-specific properties.

Resource types

  • Apply: Compose manifests from smaller reusable manifests
  • Archive: Download, extract and copy files from tar.gz and zip archives
  • Exec: Execute commands idempotently
  • File: Manage files content, ownership and more
  • Package: Install, upgrade, downgrade and remove packages using OS native packagers
  • Scaffold: Render template directories into target directories with synchronization and purge support
  • Service: Enable, disable, start, stop and restart services using OS native service managers

Common properties

All resources support the following common properties:

PropertyDescription
nameUnique identifier for the resource
ensureDesired state (values vary by resource type)
aliasAlternative name for use in subscribe, require, and logging
providerForce a specific provider
requireList of resources (type#name or type#alias) that must succeed first
health_checksHealth checks to run after applying (see Monitoring)
controlConditional execution rules (see below)

Conditional resource execution

Resources can be conditionally executed using a control section and expressions that should resolve to boolean values.

package:
  name: zsh
  ensure: 5.9
  control:
    if: lookup("facts.host.info.os") == "linux"
    unless: lookup("facts.host.info.virtualizationSystem") == "docker"
ccm ensure package zsh 5.9 \
    --if "lookup('facts.host.info.os') == 'linux'"
    --unless "lookup('facts.host.info.virtualizationSystem') == 'docker'"
{
  "protocol": "io.choria.ccm.v1.resource.ensure.request",
  "type": "package",
  "properties": {
    "name": "zsh",
    "ensure": "5.9",
    "control": {
      "if": "lookup(\"facts.host.info.os\") == \"linux\"",
      "unless": "lookup(\"facts.host.info.virtualizationSystem\") == \"docker\""
    }
  }
}

This installs zsh on all linux machines unless they are running inside a docker container.

The following table shows how the two conditions interact:

ifunlessResource Managed?
(not set)(not set)Yes
true(not set)Yes
false(not set)No
(not set)trueNo
(not set)falseYes
truetrueNo
truefalseYes
falsetrueNo
falsefalseNo