servicenow_cmdb_data
Puppet module to set up data retrieval from ServiceNow CMDB for use by Hiera and as external facts
Version information
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
- ,
Start using this module
Add this module to your Puppetfile:
mod 'jesse-servicenow_cmdb_data', '0.4.0'
Learn more about managing modules with a PuppetfileDocumentation
jesse/servicenow_cmdb_data — version 0.4.0 May 28th 2018
servicenow_cmdb_data
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
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 0.0.7.5
- 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_endpoint: https://exampleorg.service-now.com/api/now/table/cmdb_ci_server
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 => 'https://exampleorg.service-now.com/api/now/table/cmdb_ci_server',
servicenow_username => 'aaaaaaaa',
servicenow_password => 'bbbbbbbb',
}
Reference
The servicenow_cmdb_data
class has the following parameters:
servicenow_endpoint
- required - the URL of the ServiceNow cmdb_ci_server table API, eghttps://exampleorg.service-now.com/api/now/table/cmdb_ci_server
servicenow_username
- required - ServiceNow API Userservicenow_password
- required - ServiceNow API Passwordappdir
- default:/opt/servicenow_cmdb_data
- directory to use - has sub-directoriesexe
,config
,data
,log
user
- the system user to own the files and run the retrieval script asproxy
- optional proxy URL to useservicenow_query_list
- list of queries to include in the request to ServiceNow CMDB. Consultdata/default.yaml
for the defaut set of queriesservicenow_field_list
- list of fields to request ServiceNow CMDB to return for each objectservicenow_extra_args
- list of additional arguments to include in the ServiceNow CMDB URL, egsysparm_display_value=true
; default: undefkey_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 inuser
, default: truecron_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).