Pacemaker Corosync OCF Resource Lifecycle

I have been currently asked to setup Pacemaker Corosync and this is entirely new for me. I currently have a 2 node cluster. And what I want to do is to reassign the IP to the other node if active node fails. So it seems like the way to do it is to create a resource agent. I've read some tutorials about creating an ocf resource. I've read OCF resource and it seems like there these things called actions. What I don't understand about actions is when and who calls these actions? And if the resource is running on the primary node and then when the primary node goes down, what happens to the resource? Does it automatically run on the other node? Also since i will need to do some steps in case an action is called, how can i check which action is called in my script, is there a variable?


Solution 1:

There is a package called resource-agents that contains a bunch of commonly used resource agents for Pacemaker. IPaddr2 is one of them that is used to move a virtual IP around in a cluster. For configuration details you can issue the command: pcs resource describe ocf:heartbeat:IPaddr2

If you do need to write your own resource agent (a subject far too deep to describe in a single StackExchange answer) there is an OCF RA Development Guide you should read first in the resource-agents github: https://github.com/ClusterLabs/resource-agents/blob/master/doc/dev-guides/ra-dev-guide.asc