Automation of IT processes can be a huge time saver. Unfortunately beginning with automation can be quite challeging and expensive.

I was really excited when I heard from my friends at Infiverve that they have released an orchestration tool called flint.

Flint is an automation platform that uses Groovy and Ruby to create automated services. One of their big advantages is, that they store all of their workflows are stored within a Git repository. So it is easy to test and deploy different versions of your workflows.

Let's get started and see how it works...

What's in the Box

Once you have installed flint you can login to your server at http://yourflintserver:3500. After login you will see the dashboard which gives you an overview about your automation platform.

Grid

The Grid shows you all the nodes that are currently configured. It acts as kind of cluster and jobs will be distributed between all active nodes of the cluster. As long as one node in your grid is working you have a running automation platform.

Flintbox

A flintbox is a link to a Git repository and stores all workflows (called Flintbits) for one purpose.

Connectors

They let you talk to external systems. Some sample connector types are: HTTP, Database, SSH, Amazon EC2 and many more. Since there is no BMC Remedy Connector available, we currently create our own. 

Listeners

You cannot only talk to the world but also listen. Right now MQTT and IMAP Listeners are available.

Scheduler

With schedulers you can run your workflows periodically. The configuration is based on the Cron Syntax.

Global Config

Is great to store and share connection strings or parameters across all workflows.

TOD

The Trigger On Demand console let you run and test your workflows. It's great for debugging and developing purposes.

User Management

Let you create and manage different user accounts. Right now the functionality is very basic and each user has full access. But thats supposed to change in future releases.

Start Coding

First create a new Git repository. For this example we create a new public repository on Github. You can also use your private Git Server if you want. 

Now you can add your repository as new Flintbox on your grid.

Don't forget to enable your new Flintbox.

Since flint does not come with it's own IDE you can use any Editor you want to create your workflow scripts. I prefer to use Atom, a free Text Editor that is available for Mac, Windows and Linux. The great thing about Atom is that it comes with a plugin for flint that makes development a lot easier.

You can now go to the folder <flinthome>/flintbox/<yourflintbox> and start creating your first flintbits. If you have flint installed on a remote machine and your are working on a Mac I can highly recommend Transmit to open your files.

Let's create a simple "hello.groovy" flintbit.

log.info "Hello World"

Now let's run it in flint. Open the TOD console, enter flintsample:basic:hello.groovy as flintbit name. Don't forget to enable logging on the LOGS tab and press run.

You should see the following output:

That was easy - right?

Now let's make it a bit more dynamic. Change your flintbit to:

name = input.get("name") ?: "World"
log.info "Hello " + name

If you provide some input to your flintbit now:

Your output will change as follows:

Start talking

We can now run basic flintbits and handle input data. It's now time to interact with the outside world. Let's create a flintbit that calls OpenWeatherMap to get the current temperature and humidity based for a City provided by an input parameter.

First we need to create a new HTTP connector that we can use.

Now create a new flintbit called weather.groovy with the following content.

import groovy.json.*

//get config values
def apiKey = config.global("weather.key")

//get input parameters
def city = input.get("city")

//build the url
def url="http://api.openweathermap.org/data/2.5/weather?q=" + city + "&appid=" + apiKey + "&units=metric"

//call the connector
def wResponse=call.connector("OpenWeather")
         .set("method","get")
         .set("url",url)
         .set("timeout",5000)
         .sync()

//get the response
def myBody = wResponse.body

//Create a Object out of the JSON response
def jsonSlurper = new JsonSlurper()
def myWeather = jsonSlurper.parseText(myBody)

//Get the actual Values
log.info "Humidity: " + myWeather.main.humidity + "%"
log.info "Temp: " + myWeather.main.temp + "°C"

//Provide some output
output.set("Wetter", "${myWeather.weather.main}")
output.set("Temp", myWeather.main.temp.toString())

We have a quite a few improvements here. We read the API Key for the OpenWeatherMap service from a global configuration object with this code:

//get config values
def apiKey = config.global("weather.key")

This makes sure that the API configuration is stored in a single place and can be used by more than on flintbit. The configuration will look like this:

We call the HTTP-Connector with the following code:

//call the connector
def wResponse=call.connector("OpenWeather")
         .set("method","get")
         .set("url",url)
         .set("timeout",5000)
         .sync()

//get the response
def myBody = wResponse.body

This performs a GET Action on the OpenWeatherMap Webservice and stores the Body (JSON reply from the API) in the myBody Variable. The variable contains the following String:

{  
   "coord":{  
      "lon":11.58,
      "lat":48.14
   },
   "weather":[  
      {  
         "id":804,
         "main":"Clouds",
         "description":"overcast clouds",
         "icon":"04n"
      }
   ],
   "base":"cmc stations",
   "main":{  
      "temp":0.57,
      "pressure":942.92,
      "humidity":88,
      "temp_min":0.57,
      "temp_max":0.57,
      "sea_level":1015.72,
      "grnd_level":942.92
   },
   "wind":{  
      "speed":8.59,
      "deg":259
   },
   "clouds":{  
      "all":88
   },
   "dt":1455131881,
   "sys":{  
      "message":0.0098,
      "country":"DE",
      "sunrise":1455085705,
      "sunset":1455121684
   },
   "id":6940463,
   "name":"Altstadt",
   "cod":200
}

To make life a bit easier we can parse the JSON response into an Object.

//Create a Object out of the JSON response
def jsonSlurper = new JsonSlurper()
def myWeather = jsonSlurper.parseText(myBody)

Now we can easily access all the return values. Let's write the current temperature and humidity to the log and return some information:

//Get the actual Values
log.info "Humidity: " + myWeather.main.humidity + "%"
log.info "Temp: " + myWeather.main.temp + "°C"

//Provide some output
output.set("Wetter", "${myWeather.weather.main}")
output.set("Temp", myWeather.main.temp.toString())

If you run the flintbit you'll see the following information in the log:

So the weather is quite uncomfortable right now :)

The output of the flintbit will be the following:

This output could now be used by other flintbits. For example we could easily store it in a database or the textfile.

conclusion

Flint is a really promising automation platform with a lot of potential. It's easy to get you started with automation and it has a really small resource footprint in your environment. A lot of connectors are already there and some more are coming. In the future there will be an SDK available to create your own connectors. We're currently creating one to BMC's Remedy Platform right now. Flint can be a game changer and can make process automation more widely available for a lot of users.

Comment