forked from arunjax/cookbooks-1
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmms_monitoring_agent.rb
50 lines (44 loc) · 1.69 KB
/
mms_monitoring_agent.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
Chef::Log.warn 'Found empty mms_agent.api_key attribute' if node['mongodb']['mms_agent']['api_key'].nil?
arch = node[:kernel][:machine]
agent_type = 'monitoring'
package = node['mongodb']['mms_agent']['package_url'] % { :agent_type => agent_type }
package_opts = ''
case node.platform_family
when 'debian'
arch = 'amd64' if arch == 'x86_64'
package = "#{package}_#{node[:mongodb][:mms_agent][:monitoring][:version]}_#{arch}.deb"
provider = Chef::Provider::Package::Dpkg
# Without this, if the package changes the config files that we rewrite install fails
package_opts = '--force-confold'
when 'rhel'
package = "#{package}-#{node[:mongodb][:mms_agent][:monitoring][:version]}.#{arch}.rpm"
provider = Chef::Provider::Package::Rpm
else
Chef::Log.warn('Unsupported platform family for MMS Agent.')
return
end
remote_file "#{Chef::Config[:file_cache_path]}/mongodb-mms-monitoring-agent" do
source package
end
package 'mongodb-mms-monitoring-agent' do
source "#{Chef::Config[:file_cache_path]}/mongodb-mms-monitoring-agent"
provider provider
options package_opts
end
template '/etc/mongodb-mms/monitoring-agent.config' do
source 'mms_agent_config.erb'
owner node['mongodb']['mms_agent']['user']
group node['mongodb']['mms_agent']['group']
mode 0600
variables(
:config => node['mongodb']['mms_agent']['monitoring']
)
action :create
notifies :restart, 'service[mongodb-mms-monitoring-agent]', :delayed
end
service 'mongodb-mms-monitoring-agent' do
provider Chef::Provider::Service::Upstart if node['mongodb']['apt_repo'] == 'ubuntu-upstart'
# restart is broken on rhel (MMS-1597)
supports :start => true, :stop => true, :restart => true, :status => true
action :nothing
end