-
Notifications
You must be signed in to change notification settings - Fork 247
/
agent_python.rb
70 lines (61 loc) · 1.35 KB
/
agent_python.rb
1
2
3
4
5
6
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
67
68
69
70
#
# Cookbook Name:: newrelic
# Provider:: agent_python
#
# Copyright 2012-2014, Escape Studios
#
# include helper methods
include NewRelic::Helpers
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :install do
# Check license key provided
check_license
newrelic_repository
install_python_agent
create_config_dir
generate_agent_config
verify_agent_config
end
action :remove do
python_pip 'newrelic' do
virtualenv new_resource.virtualenv if new_resource.virtualenv
version new_resource.version if new_resource.version
action :remove
end
end
def install_python_agent
python_pip 'newrelic' do
virtualenv new_resource.virtualenv if new_resource.virtualenv
version new_resource.version if new_resource.version
action :install
end
end
def generate_agent_config
template new_resource.config_file do
cookbook new_resource.cookbook
source new_resource.source
owner 'root'
group 'root'
mode 0644
variables(
:resource => new_resource
)
action :create
end
end
def verify_agent_config
execute 'verify-python-agent' do
command "newrelic-admin validate-config #{new_resource.config_file}"
end
end
def create_config_dir
dir = ::File.dirname(new_resource.config_file)
directory dir do
owner 'root'
group 'root'
recursive true
end
end