Puppet Class: reporting_servicenow

Defined in:
manifests/init.pp

Overview

Parameters:

  • url (Stdlib::Httpsurl) (defaults to: 'https://instance.service-now.com/api/now/table/change_request?sysparm_fields=')
  • puppet_console (Stdlib::Httpsurl) (defaults to: 'https://puppet.example.com')
  • debug (Boolean) (defaults to: false)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'manifests/init.pp', line 7

class reporting_servicenow (
  Stdlib::Httpsurl $url = 'https://instance.service-now.com/api/now/table/change_request?sysparm_fields=',
  Stdlib::Httpsurl $puppet_console = 'https://puppet.example.com',
  Boolean $debug = false
) {
  pe_ini_setting { "${module_name}_enable_reports":
    ensure  => present,
    path    => "${settings::confdir}/puppet.conf",
    section => 'agent',
    setting => 'report',
    value   => true,
  }

  pe_ini_subsetting { "${module_name}_report_handler" :
    ensure               => present,
    path                 => "${settings::confdir}/puppet.conf",
    section              => 'master',
    setting              => 'reports',
    subsetting           => $module_name,
    subsetting_separator => ',',
    notify               => Service['pe-puppetserver'],
  }

  file { "${settings::confdir}/${module_name}.yaml":
    ensure  => present,
    owner   => 'pe-puppet',
    group   => 'pe-puppet',
    mode    => '0644',
    replace => false,
    content => epp("${module_name}/${module_name}.yaml.epp"),
  }

  # Needed to compile rest-client
  package { ['gcc', 'gcc-c++', 'libstdc++', 'make']:
    ensure => present,
  }

  # Needed to post data to the API
  package { 'rest-client':
    ensure   => '2.1.0',
    provider => 'puppet_gem',
    notify   => [Exec['reset-gem-perms'],Service[ 'pe-puppetserver' ]],
  }

  package { 'rest-client-server':
    ensure   => '2.1.0',
    name     => 'rest-client',
    provider => 'puppetserver_gem',
    notify   => [Exec['reset-gem-perms'],Service[ 'pe-puppetserver' ]],
  }

  # Permissions are often left with 600 so this will fix them
  exec { 'reset-gem-perms':
    path        => $facts['path'],
    command     => 'find /opt/puppetlabs/puppet/lib/ruby/gems/ -type d -exec chmod a+rx {} \; ; find /opt/puppetlabs/puppet/lib/ruby/gems/ -type f -exec chmod a+r {} \; ; chmod a+rx /opt/puppetlabs/puppet/bin/*',  #lint:ignore:140chars
    refreshonly => true,
    logoutput   => true,
  }

}