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
Create an
IPaddr2
resource namedVirtualIP
.pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24
# 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 Copied! Create an
apache
resource namedWebsite
.pcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status"
# 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 Copied! Configure a location constraint for the
Website
resource.pcs constraint location Website avoids node1
# pcs constraint location Website avoids node1
Copy to Clipboard Copied! Configure a colocation constraint for the
Website
andVirtualIP
resources.pcs constraint colocation add Website with VirtualIP
# pcs constraint colocation add Website with VirtualIP
Copy to Clipboard Copied! Configure an order constraint for the
Website
andVirtualIP
resources.pcs constraint order VirtualIP then Website
# pcs constraint order VirtualIP then Website Adding VirtualIP Website (kind: Mandatory) (Options: first-action=start then-action=start)
Copy to Clipboard Copied! Display the
pcs
commands you can use to re-create the constraints on a different system.pcs constraint --output-format=cmd
# 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 Copied!