Skip to content

Commit

Permalink
Merge pull request #10 from kcampos/mysql-int
Browse files Browse the repository at this point in the history
Add class for mysql integration
  • Loading branch information
clofresh committed Dec 10, 2013
2 parents 139828e + c211cf4 commit 77a6578
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
6 changes: 3 additions & 3 deletions manifests/init.pp
Expand Up @@ -50,10 +50,10 @@
file { "/etc/dd-agent/datadog.conf":
ensure => file,
content => template("datadog/datadog.conf.erb"),
owner => "dd-agent",
group => "root",
owner => $dd_user,
group => $dd_group,
mode => 0640,
notify => Service["datadog-agent"],
notify => Service[$service_name],
require => File["/etc/dd-agent"],
}

Expand Down
50 changes: 50 additions & 0 deletions manifests/integrations/mysql.pp
@@ -0,0 +1,50 @@
# Class: datadog::integrations::mysql
#
# This class will install the necessary configuration for the mysql integration
#
# Parameters:
# $host:
# The host mysql is running on
# $password
# The mysql password for the datadog user
# $user
# The mysql user for the datadog user
# $tags
# Optional array of tags
# $replication
# replication option
# $galera_cluster
# galera cluster option
#
# Sample Usage:
#
# class { 'datadog::integrations::mysql' :
# host => 'localhost',
# password => 'some_pass',
# user => 'datadog'
# }
#
#
class datadog::integrations::mysql(
$host,
$password,
$user = 'datadog',
$tags = [],
$replication = '0',
$galera_cluster = '0'
) inherits datadog::params {

package { $mysql_int_package :
ensure => installed,
}

file { "${conf_dir}/mysql.yaml":
ensure => file,
owner => $dd_user,
group => $dd_group,
mode => 0644,
content => template('datadog/mysql.yaml.erb'),
require => Package[$mysql_int_package],
notify => Service[$service_name]
}
}
18 changes: 12 additions & 6 deletions manifests/params.pp
Expand Up @@ -15,17 +15,23 @@
# Sample Usage:
#
class datadog::params {
$api_key = "your API key"
$dd_url = "https://app.datadoghq.com"
$api_key = "your API key"
$dd_url = "https://app.datadoghq.com"
$conf_dir = "/etc/dd-agent/conf.d"
$dd_user = "dd-agent"
$dd_group = "root"
$service_name = "datadog-agent"

case $operatingsystem {
"Ubuntu","Debian" : {
$rubygems_package = 'rubygems'
$rubydev_package = 'ruby-dev'
$rubygems_package = 'rubygems'
$rubydev_package = 'ruby-dev'
$mysql_int_package = 'python-mysqldb'
}
"RedHat","CentOS","Fedora","Amazon","Scientific" : {
$rubygems_package = 'rubygems'
$rubydev_package = 'ruby-devel'
$rubygems_package = 'rubygems'
$rubydev_package = 'ruby-devel'
$mysql_int_package = 'MySQL-python'
}
default: { fail("Class[datadog]: Unsupported operatingsystem: ${::operatingsystem}") }
}
Expand Down
15 changes: 15 additions & 0 deletions templates/mysql.yaml.erb
@@ -0,0 +1,15 @@
init_config:

instances:
- server: <%= @host %>
user: <%= @user %>
pass: <%= @password %>
<% if !@tags.empty? -%>
tags:
<% @tags.each do |tag| -%>
- <%= tag %>
<% end -%>
<% end -%>
options:
replication: <%= @replication %>
galera_cluster: <%= @galera_cluster %>

0 comments on commit 77a6578

Please sign in to comment.