How It Works - mrvisser/node-cowboy GitHub Wiki
Cowboy is made up of 2 components:
Cattle Server: The cattle server runs as a background/daemon process that listens for commands issued from the cowboy client
Cowboy Client: The cowboy client is a command-line tool that is used to issue commands to all listening cattle nodes in parallel
Communication between the Cowboy and Cattle nodes is facilitated using Redis Pub/Sub messaging. The command workflow goes as follows:
- Cattle nodes are running, they are listening on the command channel in Redis
- User executes
cowboy ping
at the command line - Cowboy sends a request frame onto the command Redis Pub/Sub channel
- Cowboy opens up a unique reply Redis channel to listen for Cattle responses
- All Cattle servers receive the request, and the command is executed while sending any number of response frames back to the Cowboy through the unique reply Redis channel
- When all Cattle nodes have finished executing, the Cowboy module will issue its output
Note that the logic of Command execution and output is completely customizable when implementing your own custom command.
Do I need Cowboy?
Cowboy is great for managing and auditing small to large networks of servers. At the moment it has a pretty simple set of functionality, and there are alternatives that might be better for you.
MCollective
If you've used MCollective by PuppetLabs, you've probably ascertained that Cowboy's architecture is inspired by it.
So, why not MCollective? Cowboy may be a better fit for you in the following ways:
- It's Node.js! Therefore the plugin/module system is pure JavaScript and distributed using the awesome NPM tool. This gives much more plugin-writing power to the Node community
- Using Redis instead of ActiveMQ greatly simplifies installation
- Redis provides more functionality than just message passing, such as a key-value store. This provides more powerful ways to communicate. As an example, in order to speed up the request/response cycle and reduce timeout hangs, a "presence" system is implemented in Cowboy using a Redis key where all cattle nodes can emit presence and are known ahead of time by the cowboy client when a command is invoked. This means the cowboy client has a better idea when all commands have finished executing
On the other hand, MCollective being a more mature product with more resources behind it, there is more functionality that you might need out of such a utility:
- MCollective currently has more ways to filter nodes so you don't have to have a network host naming convention. Cowboy is working toward that goal, but we're stuck with hostnames for now
- More built-in security like topic authorization, per-user auditing and encryption. Cowboy only has connection-level authentication with Redis, and encryption is achieved using SSH Tunnelling.
If you need this stuff, you might want to have a look at MCollective.
Fabric
Fabric "is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks." Think about it as SSH in a for
loop.
This is why you might need Cowboy over Fabric:
- It's Node.js! Plugin logic is JS and not bash scripts, libraries++!
- Using the message-passing paradigm means Cowboy is made aware of nodes dynamically, rather than managing a list of hosts, or specifying them on the command line
- Cowboy's built-in regex Host filtering allows you to more easily specify how to select nodes for execution
However, Fabric includes the following advantages:
- More built-in security with raw SSH. You get per-user authorization and auditing of tasks
- Local management of script execution makes it easier to write ad-hoc tasks