Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for New Relic Infrastructure #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions manifests/infrastructure.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# == Class: newrelic::infrastructure
#
# [*newrelic_license_key*]
# License key from new relic. Required.
#
class newrelic::infrastructure (
$newrelic_license_key = undef,
$newrelic_infra_conf_file = $newrelic::params::infra_conf_file
) inherits newrelic::params {
include ::newrelic

if ! $newrelic_license_key {
fail('You must specify a valid License Key.')
}

case $::kernel {
'Linux': {
contain ::newrelic::infrastructure::linux
}
'Windows': {
contain ::newrelic::infrastructure::windows
}
default: {
warning("Unsupported Kernel ${::kernel}")
}
}

file { $newrelic_infra_conf_file:
ensure => file,
require => Package['newrelic-infra'],
}->

file_line {'Add License key for config YML':
ensure => present,
path => $newrelic_infra_conf_file,
line => "license_key: ${newrelic_license_key}",
match => '^license_key:',
require => Package['newrelic-infra'],
}->

service{'newrelic-infra':
ensure => running,
require => Package['newrelic-infra'],
}
}
39 changes: 39 additions & 0 deletions manifests/infrastructure/linux.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# == Class: newrelic::infrastructure::linux
#
class newrelic::infrastructure::linux {
case $::osfamily {
'Debian': {
apt::source { 'newrelic-infra':
location => 'https://download.newrelic.com/infrastructure_agent/linux/apt',
repos => 'main',
key => {
id => 'A758B3FBCD43BE8D123A3476BB29EE038ECCE87C',
key => 'https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg',
},
include => {
src => false,
},
release => $::lsbdistcodename,
}->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting apt errors if I don't include architecure => 'amd64' in this block. That will exclude the i386 builds which don't actually exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, will correct that.


package { 'newrelic-infra':
ensure => installed,
}
}
'RedHat': {
exec { 'create-newrelic-infra-repo':
command => join(['curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/',
$::operatingsystemmajrelease, '/x86_64/newrelic-infra.repo'], ''),
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
creates => '/etc/yum.repos.d/newrelic-infra.repo',
}->

package { 'newrelic-infra':
ensure => installed,
}
}
default: {
warning("Unsupported OS Family ${::osfamily}")
}
}
}
36 changes: 36 additions & 0 deletions manifests/infrastructure/windows.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# == Class: newrelic::infrastructure::windows
#
# [*staging_folder*]
# Which folder to download the agent before installation.
# Defaults to c:/temp
#
# [*source_url*]
# URL to download the agent
# Defaults to NR's URL
#
# [*download_proxy*]
# Which proxy to use for downloading the agent
# Defaults to undef
#
class newrelic::infrastructure::windows (
$staging_folder = 'c:/temp',
$source_url = 'https://download.newrelic.com/infrastructure_agent/windows/newrelic-infra.msi',
$download_proxy = undef,
){
exec { 'Make sure staging directory exists':
command => "mkdir -p '${staging_folder}'",
creates => $staging_folder,
provider => powershell,
}->

download_file { 'Download New Relic Infrastructure' :
url => $source_url,
destination_directory => $staging_folder,
proxy_address => $download_proxy,
}->

package { 'newrelic-infra':
ensure => installed,
source => "${staging_folder}/newrelic-infra.msi",
}
}
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#
class newrelic {

require newrelic::params
require ::newrelic::params

}
4 changes: 4 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

case $::osfamily {
'RedHat': {
$infra_conf_file = '/etc/newrelic-infra.yml'
$newrelic_package_name = 'newrelic-sysmond'
$newrelic_service_name = 'newrelic-sysmond'
$newrelic_php_package = 'newrelic-php5'
Expand All @@ -26,6 +27,7 @@
}
}
'Debian': {
$infra_conf_file = '/etc/newrelic-infra.yml'
$newrelic_package_name = 'newrelic-sysmond'
$newrelic_service_name = 'newrelic-sysmond'
$newrelic_php_package = 'newrelic-php5'
Expand All @@ -42,6 +44,7 @@
},
release => 'newrelic',
}

case $::operatingsystem {
'Debian': {
case $::operatingsystemrelease {
Expand Down Expand Up @@ -69,6 +72,7 @@
}
}
'windows': {
$infra_conf_file = 'C:/Program Files/New Relic/newrelic-infra/newrelic-infra.yml'
$bitness = regsubst($::architecture,'^x([\d]{2})','\1')
$newrelic_package_name = 'New Relic Server Monitor'
$newrelic_service_name = 'nrsvrmon'
Expand Down