diff --git a/manifests/integrations/cacti.pp b/manifests/integrations/cacti.pp new file mode 100644 index 00000000..b8471d64 --- /dev/null +++ b/manifests/integrations/cacti.pp @@ -0,0 +1,32 @@ +# Class: datadog_agent::integrations::cacti +# +# This class will install the necessary configuration for the cacti integration +# +# Parameters: +# $host: +# The host cacti MySQL db is running on +# $user +# The cacti MySQL password +# $password +# The cacti MySQL sb port. +# $path +# The path to the cacti rrd directory e.g. /var/lib/cacti/rra/ +# +class datadog_agent::integrations::cacti( + $mysql_host = 'localhost', + $mysql_user = 'cacti', + $mysql_password = undef, + $rrd_path = '/var/lib/cacti/rra/', +) inherits datadog_agent::params { + include datadog_agent + + file { "${datadog_agent::params::conf_dir}/cacti.yaml": + ensure => file, + owner => $datadog_agent::params::dd_user, + group => $datadog_agent::params::dd_group, + mode => '0600', + content => template('datadog_agent/agent-conf.d/cacti.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name] + } +} diff --git a/spec/classes/datadog_agent_integrations_cacti_spec.rb b/spec/classes/datadog_agent_integrations_cacti_spec.rb new file mode 100644 index 00000000..516afa2d --- /dev/null +++ b/spec/classes/datadog_agent_integrations_cacti_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::cacti' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/cacti.yaml" } + + context 'with default parameters' do + it { should compile } + end + + context 'with parameters set' do + let(:params) {{ + mysql_host: 'localhost', + mysql_user: 'foo', + mysql_password: 'bar', + rrd_path: 'path', + }} + it { should contain_file(conf_file).with_content(/mysql_host: localhost/) } + it { should contain_file(conf_file).with_content(/mysql_user: foo/) } + it { should contain_file(conf_file).with_content(/mysql_password: bar/) } + it { should contain_file(conf_file).with_content(/rrd_path: path/) } + end +end diff --git a/templates/agent-conf.d/cacti.yaml.erb b/templates/agent-conf.d/cacti.yaml.erb new file mode 100644 index 00000000..75533dc0 --- /dev/null +++ b/templates/agent-conf.d/cacti.yaml.erb @@ -0,0 +1,12 @@ +# +# MANAGED BY PUPPET +# + +init_config: + +instances: + - mysql_host: <%= @mysql_host %> + mysql_user: <%= @mysql_user %> + mysql_password: <%= @mysql_password %> + rrd_path: <%= @rrd_path %> +