Export cluster resources as pcs commands

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

About this task

The following example procedure creates four resources for an active/passive Apache HTTP server in a Red Hat high availability cluster and then displays the pcs commands you can use to recreate those resources.

Procedure

  1. Create an LVM-activate resource.
    # pcs resource create my_lvm ocf:heartbeat:LVM-activate vgname=my_vg vg_access_mode=system_id --group apachegroup
  2. Create a Filesystem resource.
    # pcs resource create my_fs Filesystem device="/dev/my_vg/my_lv" directory="/var/www" fstype="xfs" --group apachegroup
  3. Create an IPaddr2 resource.
    # pcs resource create VirtualIP IPaddr2 ip=198.51.100.3 cidr_netmask=24 --group apachegroup
  4. Create an Apache resource.
    # pcs resource create Website apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status" --group apachegroup
  5. Display the pcs commands you can use to re-create the four resources you created on a different system.
    # pcs resource config --output-format=cmd
    pcs resource create --no-default-ops --force -- my_lvm ocf:heartbeat:LVM-activate \
      vg_access_mode=system_id vgname=my_vg \
      op \
        monitor interval=30s id=my_lvm-monitor-interval-30s timeout=90s \
        start interval=0s id=my_lvm-start-interval-0s timeout=90s \
        stop interval=0s id=my_lvm-stop-interval-0s timeout=90s;
    pcs resource create --no-default-ops --force -- my_fs ocf:heartbeat:Filesystem \
      device=/dev/my_vg/my_lv directory=/var/www fstype=xfs \
      op \
        monitor interval=20s id=my_fs-monitor-interval-20s timeout=40s \
        start interval=0s id=my_fs-start-interval-0s timeout=60s \
        stop interval=0s id=my_fs-stop-interval-0s timeout=60s;
    pcs resource create --no-default-ops --force -- VirtualIP ocf:heartbeat:IPaddr2 \
      cidr_netmask=24 ip=198.51.100.3 \
      op \
        monitor interval=10s id=VirtualIP-monitor-interval-10s timeout=20s \
        start interval=0s id=VirtualIP-start-interval-0s timeout=20s \
        stop interval=0s id=VirtualIP-stop-interval-0s timeout=20s;
    pcs resource create --no-default-ops --force -- Website ocf:heartbeat:apache \
      configfile=/etc/httpd/conf/httpd.conf statusurl=http://127.0.0.1/server-status \
      op \
        monitor interval=10s id=Website-monitor-interval-10s timeout=20s \
        start interval=0s id=Website-start-interval-0s timeout=40s \
        stop interval=0s id=Website-stop-interval-0s timeout=60s;
    pcs resource group add apachegroup \
      my_lvm my_fs VirtualIP Website
  6. Display the pcs command you can use to re-create only the IPaddr2 resource. To display only one configured resource, specify the resource ID for that resource.
    # pcs resource config VirtualIP --output-format=cmd
    pcs resource create --no-default-ops --force -- VirtualIP ocf:heartbeat:IPaddr2 \
      cidr_netmask=24 ip=198.51.100.3 \
      op \
        monitor interval=10s id=VirtualIP-monitor-interval-10s timeout=20s \
        start interval=0s id=VirtualIP-start-interval-0s timeout=20s \
        stop interval=0s id=VirtualIP-stop-interval-0s timeout=20s