Chapter 14. 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')
    Copy to Clipboard
  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')
    Copy to Clipboard
  3. Configure a location constraint for the Website resource.

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

    # pcs constraint colocation add Website with VirtualIP
    Copy to Clipboard
  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)
    Copy to Clipboard
  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
    Copy to Clipboard
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

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

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

Theme

© 2025 Red Hat