Condition


condition_from_command

Execute a command and create outcome classes depending on its exit code

Compatible with nodes running Rudder 3.1 or higher.

Usage

This bundle will define a class condition_from_command_${condition_prefix}_{kept,not_ok,ok,reached} depending on the exit codes given in parameters.

If the exit code is in the true_codes list, this will produce a kept outcome class and a ${condition_prefix}_true condition If the exit code is in the false_codes list, this will produce a repaired outcome class and a ${condition_prefix}_false condition If the exit code is not in the list, this will produce an error outcome class and no classes with ${condition_prefix}

The created condition (class in cfengine speaking) is global to the agent. To make the condition specific to current technique instance (or directive), add ${class_prefix} within the condition prefix, this variable is automatically defined in your technique and is available if you use Rudder agent >= 4.0 or CFEngine >= 3.8

Parameters

  • condition_prefix: The condition name, use ${class_prefix} to create a local condition
  • command: The command to run
  • true_codes: List of codes that produce a true status separated with commas (ex: 1,2,5)
  • false_codes: List of codes that produce a false status separated with commas (ex: 3,4,6)

Classes defined

condition_from_command_${condition_prefix}_{kept, repaired, not_ok, reached}


condition_from_expression

Create a new condition class

Compatible with nodes running Rudder 3.1 or higher.

Usage

This bundle will define a class condition_from_expression_${condition_prefix}_{kept,ok,reached}

This bundle will additionnaly produce a ${condition_prefix}_true or a ${condition_prefix}_false condition depending on the result on the expression

Calling this method with a condition expression transforms a complex expression into a single class condition.

The created condition (class in cfengine speaking) is global to the agent. To make the condition specific to current technique instance (or directive), add ${class_prefix} within the condition prefix, this variable is automatically defined in your technique and is available if you use Rudder agent >= 4.0 or CFEngine >= 3.8

Parameters

  • condition_prefix: The condition prefix, use ${class_prefix}_name to create a local condition
  • condition_expression: The expression evaluated to create the condition (use any to alwaus evaluate to true)

Classes defined

condition_from_expression_${condition_prefix}_{kept, repaired, not_ok, reached}


condition_from_expression_persistent

Create a new condition class that persists accross runs

Compatible with nodes running Rudder 3.1 or higher.

Usage

This bundle will define a class condition_from_expression_persistent_${condition_prefix}_{kept,ok,reached}

This bundle will additionnaly produce a ${condition_prefix}_true or a ${condition_prefix}_false condition depending on the result on the expression

The created condition (class in cfengine speaking) is global to the agent and is persisted accross runs. The persistence duration is controlled using ${duration}. There is no way to persist indefinitly. To make the condition specific to current technique instance (or directive), add ${class_prefix} within the condition prefix, this variable is automatically defined in your technique and is available if you use Rudder agent >= 4.0 or CFEngine >= 3.8

Parameters

  • condition_prefix: The condition prefix, use ${class_prefix}_name to create a local condition
  • condition_expression: The expression evaluated to create the condition (use any to alwaus evaluate to true)
  • duration: The persistence suffix in minutes

Classes defined

condition_from_expression_persistent_${condition_prefix}_{kept, repaired, not_ok, reached}