Forge Home

reporting_servicenow

Send Puppet corrective change reports to open ServiceNOW tickets

1,882 downloads

1,882 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.2.0 (latest)
released Jul 20th 2020
This version is compatible with:
  • Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.7.0 < 7.0.0
  • , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'ahead-reporting_servicenow', '1.2.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add ahead-reporting_servicenow
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install ahead-reporting_servicenow --version 1.2.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

ahead/reporting_servicenow — version 1.2.0 Jul 20th 2020

reporting_servicenow

Table of Contents

  1. Description
  2. Setup - The basics of getting started with reporting_servicenow
  3. Usage - Configuration options and additional functionality

Description

reporting_servicenow uses the Puppet Reporting API to open new incidents in ServiceNow if there have been corrective changes.

Setup

What reporting_servicenow affects

On the Puppet Master, this module:

  • Adds configuration to /etc/puppetlabs/puppet/puppet.conf
  • Creates the configuration file /etc/puppetlabs/puppet/reporting_servicenow.yaml
  • Adds a ruby plugin to commuincate with the ServiceNow API
  • Create the log file /var/log/puppetlabs/puppetserver/reporting_servicenow.log

Setup Requirements

reporting_servicenow requires the rest-client gem. This will be installed as part of the class, along with the supporting libraries and compilers need to build it.

Beginning with reporting_servicenow

There are 4 steps to the reporting_servicenow configuration:

  • declare the reporting_servicenow class in a manifest:
class { 'reporting_servicenow':
  url            => 'https://<YOUR SERVICENOW INSTANCE HERE>/api/now/table/incident',
  puppet_console => 'https://<YOUR CONSOLE HERE>',
}
  • run puppet - This will create the file /etc/puppetlabs/puppet/reporting_servicenow.yaml with content similar to this:
---
api_url: "https://<YOUR SERVICENOW INSTANCE HERE>/api/now/table/incident"
console_url: "https://<YOUR CONSOLE HERE>"
debug: false
# add servicenow username and password below
username: PROVIDE_THE_SERVICENOW_USER
password: PROVIDE_THE_PASSWORD
  • Edit /etc/puppetlabs/puppet/reporting_servicenow.yaml. (**NOTE: this file is only created once by puppet and then not changed back on subsequent puppet runs.) Add the ServiceNow username and password:
---
api_url: "https://<YOUR SERVICENOW INSTANCE HERE>/api/now/table/incident"
console_url: "https://<YOUR CONSOLE HERE>"
debug: false
# add servicenow username and password below
username: <SERVICENOW USER>
password: <PASSWORD>
  • restart the puppetserver service:
systemctl restart pe-puppetserver

Usage

Once set up, there is nothing more to do. Corrective changes will be reported to ServiceNow and a simple log entry containing the node, environment and ServiceNow Change Request will be added to /var/log/puppetlabs/puppetserver/reporting_servicenow.log.

[2017-10-07T18:17:26Z]: Puppet run on ip-172-31-32-95.us-west-2.compute.internal resulted in a status of changed (corrective) in the production environment
[2017-10-07T18:17:26Z]: ServiceNow Change CHG0010009 was created on 2017-10-07 18:17:26

There is also debugging log option that can be turned on which will add debug messages to /var/log/puppetlabs/puppetserver/reporting_servicenow.log. Set debug: true in /etc/puppetlabs/puppet/reporting_servicenow.yaml and restart the puppetserver service.

When there are corrective changes and debgugging is turned on, your log will contain much for info:

[2017-10-07T18:27:53Z]: DEBUG: msg: Puppet run resulted in a status of 'unchanged'' in the 'production' environment
[2017-10-07T18:30:13Z]: DEBUG: msg: Puppet run resulted in a status of 'changed (corrective)'' in the 'production' environment
[2017-10-07T18:30:13Z]: DEBUG: payload:
-------
{:active=>"false", :category=>"Puppet Corrective Change", :description=>"Puppet run resulted in a status of 'changed (corrective)'' in the 'production' environment", :escalation=>"0", :impact=>"1", :incident_state=>"3", :priority=>"2", :severity=>"1", :short_description=>"Puppet Corrective Change on ip-172-31-32-95.us-west-2.compute.internal", :state=>"7", :sys_created_by=>"Puppet but not Kermit", :urgency=>"1", :work_notes=>"Node Reports: [code]<a class='web' target='_blank' href='https://puppet.aws.aheadaviation.com/#/node_groups/inventory/node/ip-172-31-32-95.us-west-2.compute.internal/reports'>Reports</a>[/code]"}
-----
[2017-10-07T18:30:13Z]: DEBUG: response:
-------
{"result":{"parent":"","made_sla":"true","caused_by":"","watch_list":"","upon_reject":"cancel","sys_updated_on":"2017-10-07 18:30:15","child_incidents":"0","hold_reason":"","approval_history":"","number":"INC0010010","resolved_by":{"link":"https://dev31247.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"sys_updated_by":"admin","opened_by":{"link":"https://dev31247.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"user_input":"","sys_created_on":"2017-10-07 18:30:15","sys_domain":{"link":"https://dev31247.service-now.com/api/now/table/sys_user_group/global","value":"global"},"state":"7","sys_created_by":"admin","knowledge":"false","order":"","calendar_stc":"0","closed_at":"2017-10-07 18:30:15","cmdb_ci":"","delivery_plan":"","impact":"1","active":"false","work_notes_list":"","business_service":"","priority":"1","sys_domain_path":"/","rfc":"","time_worked":"","expected_start":"","opened_at":"2017-10-07 18:30:15","business_duration":"1970-01-01 00:00:00","group_list":"","work_end":"","caller_id":"","resolved_at":"2017-10-07 18:30:15","approval_set":"","subcategory":"","work_notes":"","short_description":"Puppet Corrective Change on ip-172-31-32-95.us-west-2.compute.internal","close_code":"","correlation_display":"","delivery_task":"","work_start":"","assignment_group":"","additional_assignee_list":"","business_stc":"0","description":"Puppet run resulted in a status of 'changed (corrective)'' in the 'production' environment","calendar_duration":"1970-01-01 00:00:00","close_notes":"","notify":"1","sys_class_name":"incident","closed_by":{"link":"https://dev31247.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"follow_up":"","parent_incident":"","sys_id":"6f9e856f4fe503006ad47d218110c704","contact_type":"","incident_state":"7","urgency":"1","problem_id":"","company":"","reassignment_count":"0","activity_due":"","assigned_to":"","severity":"1","comments":"","approval":"not requested","sla_due":"","comments_and_work_notes":"","due_date":"","sys_mod_count":"0","reopen_count":"0","sys_tags":"","escalation":"0","upon_approval":"proceed","correlation_id":"","location":"","category":"inquiry"}}
-----
[2017-10-07T18:30:13Z]: Puppet run on ip-172-31-32-95.us-west-2.compute.internal resulted in a status of changed (corrective) in the production environment
[2017-10-07T18:30:13Z]: ServiceNow Change CHG0010010 was created on 2017-10-07 18:30:15