Chapter 15. Exporting resource constraints as pcs commands


You can display the pcs commands that can be used to re-create configured resource constraints on a different system using the --output-format=cmd option of the pcs constraint command.

The following example procecures creates two resources, configures three resource constraints, and displays the xi`pcs` commands you can use to re-create the constraints on a different system.

Procedure

  1. Create an IPaddr2 resource named VirtualIP.

    # pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24
    Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPaddr2')
  2. Create an apache resource named Website.

    # pcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status"
    Assumed agent name 'ocf:heartbeat:apache' (deduced from 'apache')
  3. Configure a location constraint for the Website resource.

    # pcs constraint location Website avoids node1
  4. Configure a colocation constraint for the Website and VirtualIP resources.

    # pcs constraint colocation add Website with VirtualIP
  5. Configure an order constraint for the Website and VirtualIP resources.

    # pcs constraint order VirtualIP then Website
    Adding VirtualIP Website (kind: Mandatory) (Options: first-action=start then-action=start)
  6. Display the pcs commands you can use to re-create the constraints on a different system.

    # pcs constraint --output-format=cmd
    pcs -- constraint location add location-Website-node1--INFINITY resource%Website node1 -INFINITY;
    pcs -- constraint colocation add Website with VirtualIP INFINITY \
      id=colocation-Website-VirtualIP-INFINITY;
    pcs -- constraint order start VirtualIP then start Website \
      id=order-VirtualIP-Website-mandatory
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top