Automate Tasks Across Servers Based on Events
Automate Tasks Across Servers Based on Events
Join the DZone community and get the full member experience.Join For Free
[This article was originally written by James Brown.]
One of the most complicated aspects of automation is to automate tasks that happen because something else triggers them. It’s relatively easy to manually execute a task – unless it is on a lot of servers, then it’s not so easy – and, you can leverage tools to schedule tasks (again reasonably easy on a limited number of servers), but as soon as you think about going to the next level of automation and doing that off of different events, that gets really hard.
The main reason this gets hard is that you need to send a “trigger” when that event happens and usually this isn’t on the same server. It is cross-infrastructure communication. Then, you need to have something that “receives” the trigger. That listener needs to understand what it is receiving and then figure out what to go do because of that event. Most organizations are not going to build these capabilities themselves – it’s just too time consuming. So, what ends up happening is that you either make this a manual process or you’ll script it as a scheduled task with delays in between (if this is even possible – some tasks just can’t be done that way). Or, what happens in most cases is that you just don’t try to connect the two tasks together. Sometimes distributed job scheduling solutions will try to trigger based on events, sometimes they don’t. It depends on the solution and often how you implement your workflows.
At JumpCloud, we have spent a significant amount of time developing the functionality to trigger server tasks and workflows off of events. These could be events internal to the server, they could be from other servers in your infrastructure or even third party applications. JumpCloud’s server management tools can ingest basically a Webhook from anywhere and that can kick off an action. Those actions could include server tasks, data processing tasks, user management tasks, security tasks, load balancing, monitoring, and many, many more.
Structurally, here’s how it works:
- Set up a command in JumpCloud by going to the commands tab (make sure that you select whether this is a Linux or Windows task at the top, the user with which to run the command, and the servers it should run on). Note that your command can be quite complicated. Remember that JumpCloud has the ability to “chain” tasks together as well as the ability to “split” tasks (i.e. instruct multiple servers to execute the command.
- After inputting the task that you would like to automate, simply set the command’s launch event, to “Run on Trigger (webhook)”, name the trigger.
- Save your task.
That’s it – you’re ready to go. When your event happens, it will automatically trigger the command you want. Simple. That’s the beauty of what we’ve built at JumpCloud – we are taking really complex system administration tasks and making them simple with the platform we‘ve built.
Using Event Based Triggers to Automate Tasks Across Servers
Now that we have told you how to do this, let’s talk about some simple uses of this capability.
- Autoscale / descale your servers based on load – set thresholds in your monitoring solution to let you know when you are running out of capacity or you have far too much capacity. As an action on the threshold, have it send a webhook to JumpCloud. Inside of JumpCloud, setup your scenarios for scaling and descaling with the commands to spin up or shut down servers.
- Register your servers with your load balancers and monitoring solutions – set up an event notification with your cloud provider’s console to send a webhook to JumpCloud as soon as a new server is provisioned. Once it is provisioned, your JumpCloud “action” can register that server with your load balancer and monitoring solution.
- Create AWS RDS users automatically – a slightly different implementation with this use case, because JumpCloud considers user management as a first class citizen within the service but the result is the same. When adding a new user account to a server, you can create a command that launches on a “User Add” event, and so you can also have that same user created within your third party services such as AWS RDS. With JumpCloud, creating access to all of the right servers is simple – you only have to enter the user once and JumpCloud takes care of the rest.
Modern networks are event driven and automated to create a closed control loop that can keep your systems from going off the rails. Creating an automated, event-driven network is easy with JumpCloud. Give it a try – you’ll be happy to be saving all of that time – and, getting more performance out of your infrastructure.
Published at DZone with permission of Topher Marie , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.