Pacemaker location constraint rules

Configure location constraints with rules to determine resource placement based on complex conditions, such as time, date, or node attributes. You can combine multiple expressions to create sophisticated placement logic.

# pcs constraint location rsc rule[resource-discovery=option] [role=promoted|unpromoted] [score=score | score-attribute=attribute] expression
  • If score is omitted, it defaults to INFINITY.
  • When using rules to configure location constraints, the value of score can be positive or negative, with a positive value indicating "prefers" and a negative value indicating "avoids".
  • If resource-discovery is omitted, it defaults to always. For information about the resource-discovery option, see Limiting resource discovery to a subset of nodes.
  • As with basic location constraints, you can use regular expressions for resources with these constraints as well.

The expression option in Pacemaker rules

The expression option can be one of the following where duration_options and date_spec_options are: hours, months, weeks, and years as described in the "Properties of a Date Specification" table in Pacemaker rules.

  • defined|not_defined attribute
  • attribute lt|gt|lte|gte|eq|ne [string|integer|number|version] value
  • date gt|lt date
  • date in_range date to date
  • date in_range date to duration duration_options …​
  • date-spec date_spec_options
  • expression and|or expression
  • (expression)

Durations in Pacemaker rules

Note that durations are an alternative way to specify an end for in_range operations by means of calculations. For example, you can specify a duration of 19 months. The supported values for duration options are seconds, minutes, hours, days, weeks, months, and years.

The following location constraint configures an expression that is true if now is any time in the year 2018.

# pcs constraint location Webserver rule score=INFINITY date-spec years=2018

The following command configures an expression that is true from 9 am to 5 pm, Monday through Friday. Note that the hours value of 16 matches up to 16:59:59, as the numeric value (hour) still matches.

# pcs constraint location Webserver rule score=INFINITY date-spec hours="9-16" weekdays="1-5"

The following command configures an expression that is true on Friday the thirteenth.

# pcs constraint location Webserver rule date-spec weekdays=5 monthdays=13