Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #252 from a-know/newrelic-infrastructure
Newrelic infrastructure
  • Loading branch information
a-know committed Oct 21, 2017
2 parents 4bf2a6f + 08813b2 commit c03d838
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .chef/knife.rb
Expand Up @@ -4,6 +4,7 @@
environment_path "environments"
data_bag_path "./data_bags"
encrypted_data_bag_secret "data_bag_key"
local_mode true

knife[:berkshelf_path] = "cookbooks"
Chef::Config[:ssl_verify_mode] = :verify_peer if defined? ::Chef
10 changes: 10 additions & 0 deletions data_bags/credentials/newrelic-infrastructure.json
@@ -0,0 +1,10 @@
{
"id": "newrelic-infrastructure",
"license_key": {
"encrypted_data": "2b6xU/9ub66kWcpsVkM7eohfYXYMxWzjMCwFFwymoUAzyYqAVAKMpfUnL8dj\nK44HDr1YwdJpyzPq6H0=\n",
"iv": "IfbOUz3vxx8cSylY\n",
"auth_tag": "Xhy8HwbZpaoQKoqZXDh0kg==\n",
"version": 3,
"cipher": "aes-256-gcm"
}
}
1 change: 1 addition & 0 deletions roles/aws-prod.json
Expand Up @@ -5,6 +5,7 @@

"run_list": [
"recipe[crontab]",
"recipe[newrelic-infrastructure]",
"recipe[mackerel]",
"recipe[mackerel::plugin]",
"recipe[mkswap]"
Expand Down
7 changes: 7 additions & 0 deletions site-cookbooks/newrelic-infrastructure/metadata.rb
@@ -0,0 +1,7 @@
name 'newrelic-infrastructure'
maintainer 'a-know'
license 'All rights reserved'
description 'Installs/Configures NewRelic Infrastructure'
long_description 'ditto' # IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'yumrepo'
17 changes: 17 additions & 0 deletions site-cookbooks/newrelic-infrastructure/recipes/default.rb
@@ -0,0 +1,17 @@
include_recipe 'yumrepo::newrelic-infrastructure'

mackerel_credentials = Chef::EncryptedDataBagItem.load('credentials', 'newrelic-infrastructure')

template '/etc/newrelic-infra.yml' do
owner 'root'
group 'root'
mode '0644'
variables license_key: mackerel_credentials['license_key']
end

execute 'yum cache clear' do
user 'root'
command "yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'"
end

yum_package 'newrelic-infra'
@@ -0,0 +1 @@
license_key: <%= @license_key %>
6 changes: 6 additions & 0 deletions site-cookbooks/yumrepo/files/default/newrelic-infra.repo
@@ -0,0 +1,6 @@
[newrelic-infra]
name=New Relic Infrastructure
baseurl=http://download.newrelic.com/infrastructure_agent/linux/yum/el/7/x86_64
gpgkey=http://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg
gpgcheck=1
repo_gpgcheck=1
3 changes: 3 additions & 0 deletions site-cookbooks/yumrepo/recipes/newrelic-infrastructure.rb
@@ -0,0 +1,3 @@
cookbook_file '/etc/yum.repos.d/newrelic-infra.repo' do
action :create_if_missing
end
1 change: 1 addition & 0 deletions spec/roles/aws_prod_spec.rb
Expand Up @@ -30,6 +30,7 @@
# aws-prod
it_behaves_like 'crond'
it_behaves_like 'crontab'
it_behaves_like 'newrelic-infrastructure'
it_behaves_like 'mackerel'
it_behaves_like 'mkswap'
it_behaves_like 'perl-json'
Expand Down
10 changes: 10 additions & 0 deletions spec/shared/newrelic-infrastructure.rb
@@ -0,0 +1,10 @@
shared_examples 'newrelic-infrastructure' do
describe package 'newrelic-infra' do
it { should be_installed }
end

describe service 'newrelic-infra' do
it { should be_enabled }
it { should be_running }
end
end

0 comments on commit c03d838

Please sign in to comment.