Managing Discovery Jobs with RunDeck

Do you have a very large network, or do you already manage a whole lot of scheduled jobs around your environment? Some Device42 users are managing discovery across thousands of subnets,Rundeck Device42 and hundreds of separate auto-discovery jobs! Even if you don’t have quite that many network segments (or scheduled discovery jobs), controlling and/or scheduling discovery via a simple web GUI can still prove very useful – For example, maybe you want to give a user that doesn’t have a Device42 login the ability to run a discovery job on demand!

 

Below, we’ll demonstrate how you can quickly and easily use a free scheduling tool like Rundeck, or just about any “enterprise scheduling tool” to control Device42 autodiscovery jobs outside of Device42. After all, what’s to hate about to managing all job scheduling in one central place?!

 

Pre-requisites

There are two simple requirements to duplicate the Rundeck / Device42 job orchestration in this guide:

1) A working Rundeck installation (java >=1.8 + rundeck):

On Redhat or CentOS:

$ rpm -Uvh http://repo.rundeck.org/latest.rpm
$ yum install rundeck

On Ubuntu or Debian:
There doesn’t appear to be an apt-get package available, but there is a .jar that should work just fine. See https://www.device42.com/download/ to grab a free trial
b) https://docs.device42.com/getstarted/ if you need help getting started

 

Let’s See Rundeck in Action!

With nothing more than a few simple API calls to control Device42, you’ll be able to leverage Device42’s autodiscovery without logging in. Taken further, you can begin to build jobs with RunDeck that utilize other parts of Device42’s API, as well, and/or in combination with webhooks to automate more and more tasks around your environment — alongside any other jobs you’d like to schedule around your infrastructure!

 

Create a new job in RunDeck:
Create New Rundeck D42 Discovery Job

 

Create the Job Script (you can copy and paste the example below to get started):

Create a new Rundeck Script Job

Here is the general code for an API call to launch your job. Note that the %20 encodes the “space” character within a URL. Modify and paste into your script:

#!/bin/bash

curl -X PUT -d "name=JOB%20NAME&run=yes" -u 'admin:adm!nd42' https://D42.IPorFQDN/api/1.0/auto_discovery/vserver/ --insecure

-Replace "JOB%NAME" with your autodiscovery job name from the Device42 UI.
-Replace "D42.IPorFQDN" with the IP / FQDN of your Device42 instance.

 

Run the Device42 Discovery Job; RunDeck will confirm success, and you can see the job in Device42’s Autodiscovery Job Status screen:

Create New Rundeck Script Job

You can see the results confirming a successful run & the log messages:

Rundeck Job Success Log

 

Rundeck also fully supports job scheduling (like Device42), so you can configure your jobs to run automatically. Simply edit your job, and select the “Yes” radio button next to “Schedule to run repeatedly”. There are two scheduling options:

Simple or Crontab Scheduling:

Simple Rundeck Job Scheduling via GUI

That’s it! Simple, and powerful! Though relatively straightforward, a scheduling tool like Rundeck centrally organizes your jobs providing not only better organization, but more flexibility, too! Check back for a follow up. Let us know in the comments what you’d like us to demonstrate next. Maybe you’d like to see how we can parameterize the script to substitute both job names / job types (which would work equally as well, but would be a lot more work if a PW change were to occur, etc). — or maybe you’d like to see something else?

Until next time!

 


We hope you enjoyed this use case as much as we enjoyed hearing about it! If you have any questions, your own unique use case, we’d love to hear about it! Drop us an email at support@device42.com. If it’s too complicated to explain in an email, we can set up a call.

If you still need to download a trial of Device42, it couldn’t be easier — Click here!