Puppet Class: newrelic::infra

Inherits:
newrelic::params
Defined in:
manifests/infra.pp

Overview

Class: newrelic::infra

Installs and starts the New Relic Infrastrucure Agent, and replaces the deprecated server class.

Parameters

license_key

NewRelic API license key (String)

manage_repo

Whether to install the NewRelic OS repositories Default: Varies depending on OS (Boolean)

manage_service

Whether or not to manage the service as part of this module Default: true (Boolean)

service_ensure

State of the $service_name (newrelic-infra) service Default: running (String)

service_name

Name of the newrelic infra service Default: newrelic-infra (String)

service_enable

Whether to enable the service at boot Default: true (Boolean)

Authors

Russell Whelan <russell.whelan@claranet.uk> Craig Watson <craig.watson@claranet.uk>

Copyright 2017 Claranet

Parameters:

  • license_key (String)
  • manage_repo (Boolean) (defaults to: $::newrelic::params::manage_repo)
  • manage_service (Boolean) (defaults to: true)
  • service_ensure (String) (defaults to: 'running')
  • service_name (String) (defaults to: 'newrelic-infra')
  • service_enable (Boolean) (defaults to: true)


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
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'manifests/infra.pp', line 40

class newrelic::infra (
  String $license_key,
  Boolean $manage_repo    = $::newrelic::params::manage_repo,
  Boolean $manage_service = true,
  String  $service_ensure = 'running',
  String  $service_name   = 'newrelic-infra',
  Boolean $service_enable = true
) inherits newrelic::params {

  if $facts['os']['family'] == 'Windows' {
    fail('newrelic::infra is not supported yet on Windows.')
  }

  if $::newrelic::infra::manage_repo == true {
    contain ::newrelic::repo::infra
    File['/etc/newrelic-infra.yml'] {
      require => $::newrelic::repo::infra::require,
    }
  }

  file { '/etc/newrelic-infra.yml':
    ensure  => file,
    content => "license_key: ${license_key}\n",
    notify  => Service['newrelic-infra'],
  }

  package { 'newrelic-infra':
    ensure  => present,
    require => File['/etc/newrelic-infra.yml'],
  }

  if $manage_service {
    service { $service_name:
      ensure  => $service_ensure,
      name    => $service_name,
      enable  => $service_enable,
      require => Package['newrelic-infra']
    }
  }
}