Automatic Asset Tracking in your Continuous Delivery Pipeline

Agile IT Means Fast Paced Change

Device42 talk data to me

With modern DevOps teams executing upwards of 100s of deployments a day, there is a constant flow of new IT information generated that needs to be tracked. This information, however, is often spread across a variety of tools your enterprise has deployed. Different stakeholders may control each of these tools, while the tools often contain duplicated data.

If you’ve been in this situation, you know just how much fun searching for the correct tool/spreadsheet can be. Which tool(s) should you turn to for the most up-to-date version of the data? Are the data output formats compatible?

Agile IT Departments Turn to Device42

Device42 can help ensure this doesn’t happen. Keep using your existing tools, just add some simple Device42 RESTful API calls or use some built-in Device42 integrations and keep your environment information up to date immediately as changes occur. No more grabbing information from different applications in your stack or waiting for an archaic tool to generate a report to know your footprint.

The following examples demonstrate a couple easy ways to leverage popular (and free!) DevOps and CI/CD (Continuous integration/Continuous Delivery) tools to get all the latest information about your IT infrastructure into Device42 today.

Jenkins and Device42 – Continuous Integration

Jenkins is an automation server used to facilitate continuous integration and delivery. When a build job is executed, and a new package/binary is deployed to a binary repository, the Jenkins job can use the Device42 RESTful API to create a new software object with versioning and a note specifying the URI. Add a line like into a Jenkins build command:

curl -X POST -d "name=NimbleSoft&category=Reporting¬es=http://yourbinrepo/nimblesoft/nimblesoftv2013.bin&version=2.0.13" -u 'admin:xxxxx' https://yourdevice42address/api/1.0/software_details/ --insecure

You can also use the Device42 Jenkins plugin for privilege account management; store the Device42 API credentials and have Jenkins securely access them.

Terraform and Device42 – Automatic IP Address Assignment

Terraform is an open source Infrastructure as Code (IaC) tool. The Device42 RESTful API can be used within a Terraform remote-exec provisioner to allow it to set available static IPs using Device42’s IPAM feature.

Curl can be used to make the call to request the next available IP and reserve that IP, so it cannot be used if another IP request is made before the server provisioning completes.

It would look like so:

resource "esxi_guest" "tf-ubu1804" {
…
  provisioner "remote-exec" {
    connection {
      host     = "${esxi_guest.tf-ubu1804.ip_address}"
      type     = "ssh"
      user     = "devtest"
      password = "xxxxxx"
    }

    inline = [
      "IP=`curl -X POST -d \”subnet=[YOUR-SUBNET]&reserve_ip=yes” -u 'admin:xxxxxx' https://[YOUR-D42-INSTANCE]/api/1.0/suggest_ip/ --insecure | jq -r '.ip'`",
      "sudo sed -i \"s/X.X.X.X/$${IP}/g\" /etc/netplan/01-netcfg.yaml",
      "sudo netplan apply",
      "(sleep 2; reboot)&",
    ]
  }
}

Chef and Device42 – CMDB Integration

The Device42 Chef cookbook can be added to your Chef server and added to the run_list of all Chef convergences in your environment. The Device42 cookbook is a resource cookbook that includes functionality to take information discovered via Ohai and create new device types in Device42. It also contains a helper library to use Device42’s IPAM features, so you can also use Chef to assign IP addresses during an initial configuration.

To have Chef add or update the server in Device42, create a cookbook that depends on the Device42 cookbook. Create an encrypted databag or use chef vault to store the credentials to Device42. Then create a recipe and use the device resource like the following:

device “create #{node[‘hostname’]}” do
  device_name node[‘hostname’]
  user node[‘device42’][‘user’]
  password node[‘device42’][‘password’]
  url node[‘device42’][‘instance’]
end

 

The IPAM helper library can also be used in a cookbook that ‘requires Device42’ in the metadata.rb. The ifconfig chef resource can then be used to assign the IP like so:

url = node['device42']['instance']
user = node['device42']['user']
password = node['device42']['password']

ip = IPAM.new(url, user, password).suggest_ip(#{subnet})
IPAM.new(url, user, password).reserve_ip(ip)

ifconfig ip do
  device 'eth1'
end

Thanks for reading! If you have any questions about anything discussed in this post, leave a comment here, or if you’re running into problems, email support@device42.com. Links to download both Device42 and the integrations discussed above can be found below.

Happy Discovery!


Download Device42 & Related Integrations

If you haven’t tried Device42 yet, download a 30-day free trial, or update here!

Get the Device42 Chef cookbook: From Chef Market or from GitHub | Get the Device42 Jenkins plugin | View all Device42 integrations