-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Relic Infrastructure implementation
- Loading branch information
Showing
17 changed files
with
299 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
source 'https://supermarket.chef.io' | ||
|
||
cookbook 'newrelic_lwrp_test', :path => 'test/fixtures/cookbooks/newrelic_lwrp_test' | ||
# uninitialized constant Win32 caused by ark-cookbook change in v1.2.0 | ||
# (https://github.com/chef-cookbooks/ark/commit/0012c57188ff6e7df2ac69883c029bb88ce001e2) | ||
cookbook 'ark', '= 1.1.0' | ||
|
||
group :integration do | ||
cookbook 'newrelic_lwrp_test', :path => 'test/fixtures/cookbooks/newrelic_lwrp_test' | ||
end | ||
|
||
metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# | ||
# Cookbook Name:: newrelic | ||
# Provider:: agent_infrastructure | ||
# | ||
# Copyright (c) 2017, David Joos | ||
# | ||
|
||
# include helper methods | ||
include NewRelic::Helpers | ||
|
||
use_inline_resources if defined?(use_inline_resources) | ||
|
||
def whyrun_supported? | ||
true | ||
end | ||
|
||
action :install do | ||
check_license | ||
newrelic_repository_infrastructure | ||
case node['platform_family'] | ||
when 'debian', 'rhel' | ||
install_newrelic_infrastructure_service_linux | ||
when 'windows' | ||
install_newrelic_infrastructure_service_windows | ||
end | ||
end | ||
|
||
def install_newrelic_infrastructure_service_linux | ||
# install the newrelic infrastructure agent | ||
package 'newrelic-infra' do | ||
action new_resource.action | ||
action new_resource.version unless new_resource.version.nil? | ||
end | ||
|
||
# workaround for issue on RHEL family version six | ||
# service is not known to chkconfig | ||
# dribble the issue by not making use of the RHEL service provider | ||
service_provider = if node['platform_family'] == 'rhel' && node['platform_version'] =~ /^6/ | ||
Chef::Provider::Service::Upstart | ||
end | ||
|
||
# setup newrelic infrastructure service | ||
service 'newrelic-infra' do | ||
provider service_provider unless service_provider.nil? | ||
action new_resource.service_actions | ||
end | ||
|
||
# lay down newrelic-infra agent config | ||
template '/etc/newrelic-infra.yml' do | ||
cookbook new_resource.template_cookbook | ||
source new_resource.template_source | ||
owner 'root' | ||
group 'root' | ||
mode '0644' | ||
variables( | ||
:resource => new_resource | ||
) | ||
notifies :restart, 'service[newrelic-infra]', :delayed | ||
end | ||
end | ||
|
||
def install_newrelic_infrastructure_service_windows | ||
windows_package 'newrelic-infra' do | ||
source "https://download.newrelic.com/infrastructure_agent/windows/newrelic-infra.#{new_resource.windows_version}.msi" | ||
installer_type :msi | ||
version new_resource.windows_version | ||
action new_resource.action | ||
checksum new_resource.windows_checksum | ||
end | ||
|
||
# lay down newrelic-infra agent config | ||
template 'C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml' do | ||
cookbook new_resource.template_cookbook | ||
source new_resource.template_source | ||
variables( | ||
:resource => new_resource | ||
) | ||
notifies :restart, 'service[newrelic-infra]', :delayed | ||
end | ||
|
||
# setup newrelic-infra service | ||
service 'newrelic-infra' do | ||
action new_resource.service_actions | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# | ||
# Cookbook Name:: newrelic | ||
# Recipe:: infrastructure_agent | ||
# | ||
# Copyright (c) 2017, David Joos | ||
# | ||
|
||
newrelic_agent_infrastructure 'Install' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Cookbook Name:: newrelic | ||
# Resource:: agent_infrastructure | ||
# | ||
# Copyright (c) 2017, David Joos | ||
# | ||
|
||
actions :install | ||
default_action :install | ||
|
||
attribute :license, :kind_of => String, :default => NewRelic.application_monitoring_license(node) | ||
attribute :version, :kind_of => String, :default => nil | ||
|
||
attribute :display_name, :kind_of => String, :default => nil | ||
attribute :logfile, :kind_of => String, :default => nil | ||
attribute :verbose, :kind_of => Integer, :default => 0 | ||
attribute :proxy, :kind_of => String, :default => nil | ||
attribute :template_cookbook, :kind_of => String, :default => 'newrelic' | ||
attribute :template_source, :kind_of => String, :default => 'agent/infrastructure/newrelic.yml.erb' | ||
attribute :service_actions, :kind_of => Array, :default => %w(enable start) | ||
attribute :windows_version, :kind_of => String, :default => '1.0.703' | ||
attribute :windows_checksum, :kind_of => String, :default => '3c9f98325dc484ee8735f01b913803eaef54f06641348b3dd9f3c0b3cd803ace' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
describe 'newrelic_lwrp_test::agent_infrastructure' do | ||
before do | ||
stub_resources | ||
end | ||
|
||
context 'Centos' do | ||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new(:log_level => LOG_LEVEL, :platform => 'centos', :version => '6.6', :step_into => ['newrelic_agent_infrastructure']) do |node| | ||
stub_node_resources(node) | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'installs New Relic Infrastructure agent' do | ||
expect(chef_run).to install_newrelic_agent_infrastructure('Install') | ||
end | ||
|
||
it 'creates a yum_repository for newrelic' do | ||
expect(chef_run).to create_yum_repository('newrelic-infra') | ||
end | ||
|
||
it 'creates newrelic infrastructure yml config template from agent/infrastructure/newrelic.yml.erb' do | ||
expect(chef_run).to render_file('/etc/newrelic-infra.yml').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') | ||
end | ||
|
||
it 'installs newrelic-infra' do | ||
expect(chef_run).to install_package('newrelic-infra') | ||
end | ||
|
||
it 'enables newrelic-infra service' do | ||
expect(chef_run).to enable_service('newrelic-infra') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
################### | ||
# Generated by Chef | ||
################### | ||
# | ||
# This file configures the New Relic Infrastructure Agent. | ||
|
||
license_key: <%= @resource.license %> | ||
<% unless @resource.display_name.nil? -%> | ||
display_name: <%= @resource.display_name %> | ||
<% end -%> | ||
<% unless @resource.logfile.nil? -%> | ||
log_file: <%= @resource.logfile %> | ||
<% end -%> | ||
<% unless @resource.verbose.nil? -%> | ||
verbose: <%= @resource.verbose %> | ||
<% end -%> | ||
<% unless @resource.proxy.nil? -%> | ||
proxy: <%= @resource.proxy %> | ||
<% end -%> |
Oops, something went wrong.