Puppet module to set up data retrieval from ServiceNow CMDB for use by Hiera and as external facts

Jesse Reynolds



4,169 latest version

5.0 quality score

Version information

  • 0.4.0 (latest)
  • 0.3.1
  • 0.2.0
  • 0.1.0
released May 28th 2018
This version is compatible with:
  • Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.7.0 < 6.0.0
  • CentOS

Start using this module


jesse/servicenow_cmdb_data — version 0.4.0 May 28th 2018


build status

This module installs a ruby script, config file, data directory, and cron job that retrieves selected fields from a ServiceNow CMDB instances' cmdb_ci_server table. It writes out the data in a json format consumable by Hiera.

Table of Contents

  1. Setup


Setup Requirements

Required Ruby Gems (as tested with)

  • rest-client (1.8.0)
  • http-cookie (1.0.3)
  • domain_name (0.5.20180417)
  • unf 0.1.4
  • unf_ext
  • mime-types (2.99.3)
  • netrc (0.11.0)

Note that some of the above gems require development tools to be installed for the gem install step to succeed as they require native code to be compiled (eg unf, unf_ext).

Beginning with servicenow_cmdb_data

Include the class on the Puppet Master (or Master of Masters)

include servicenow_cmdb_data

and supply at a minimum the following keys in Hiera:

servicenow_cmdb_data::servicenow_username: aaaaaaaa
servicenow_cmdb_data::servicenow_password: bbbbbbbb

Alternatively, use the resource syntax to include these parameters in your Puppet code:

class { 'servicenow_cmdb_data':
  servicenow_endpoint => '',
  servicenow_username => 'aaaaaaaa',
  servicenow_password => 'bbbbbbbb',


The servicenow_cmdb_data class has the following parameters:

  • servicenow_endpoint - required - the URL of the ServiceNow cmdb_ci_server table API, eg
  • servicenow_username - required - ServiceNow API User
  • servicenow_password - required - ServiceNow API Password
  • appdir - default: /opt/servicenow_cmdb_data - directory to use - has sub-directories exe, config, data, log
  • user - the system user to own the files and run the retrieval script as
  • proxy - optional proxy URL to use
  • servicenow_query_list - list of queries to include in the request to ServiceNow CMDB. Consult data/default.yaml for the defaut set of queries
  • servicenow_field_list - list of fields to request ServiceNow CMDB to return for each object
  • servicenow_extra_args - list of additional arguments to include in the ServiceNow CMDB URL, eg sysparm_display_value=true; default: undef
  • key_prefix - string to prepend each key in the output JSON data file with, default: cmdb_by_fqdn
  • manage_user - whether to manage the system user specified in user, default: true
  • cron_hour - value of the hour field for the cron job, default: * (no restriction on hour-of-day)
  • cron_minute - value of the minute field for the cron job, default: */5 (run the job every 5 minutes)

To Do

  • Add a class that automatically creates external facts corresponding to each of the retrieved fields, prefacing them with something configurable eg "cmdb_"
  • Consider what kind of validation could be done before overwriting the JSON file, eg a large percentage difference in the number of servers (or requiring existence of at least x servers in the dump for it to be valid).