Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fixes to Kafka, Consul, stdlib deprecations #404

Merged
merged 8 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions functions/tag6.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ function datadog_agent::tag6(
Variant[Array, String] $tag_names,
Variant[String, Boolean] $lookup_fact = false,
) {
if validate_legacy('Optional[Array]', 'is_array', $tag_names) {
if $tag_names =~ Array {
$tags = $tag_names.reduce([]) |$_tags , $tag| {
concat($_tags, datadog_agent::tag6($tag, lookup_fact))
concat($_tags, datadog_agent::tag6($tag, $lookup_fact))
}
} else {
if $lookup_fact =~ String {
$lookup = str2bool($lookup_fact)
} else {
$lookup = $lookup_fact
}
} elsif str2bool($lookup_fact) {
$value = getvar($tag_names)

if validate_legacy('Optional[Array]', 'is_array', $value){
$tags = prefix($value, "${tag_names}:")
if $lookup {
$value = getvar($tag_names)
if $value =~ Array {
$tags = prefix($value, "${tag_names}:")
} else {
$tags = [$tag_names]
}
} else {
$tags = [$tag_names]
}
} else {
$tags = [$tag_names]
}

$tags
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
'dogstatsd_non_local_traffic' => $non_local_traffic,
'log_file' => $agent6_log_file,
'log_level' => $log_level,
'tags' => union($_local_tags, $_facts_tags),
'tags' => unique(flatten(union($_local_tags, $_facts_tags))),
}

$agent_config = deep_merge($_agent_config, $extra_config)
Expand Down
8 changes: 3 additions & 5 deletions manifests/integration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

include datadog_agent

validate_array($instances)
if $init_config != undef {
validate_hash($init_config)
}
validate_string($integration)
validate_legacy(Array, 'validate_array', $instances)
validate_legacy(Optional[Hash], 'validate_hash', $init_config)
validate_legacy(String, 'validate_string', $integration)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/${integration}.yaml"
Expand Down
6 changes: 3 additions & 3 deletions manifests/integrations/apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
) inherits datadog_agent::params {
include datadog_agent

validate_string($url)
validate_array($tags)
validate_bool($disable_ssl_validation)
validate_legacy('String', 'validate_string', $url)
validate_legacy('Array', 'validate_array', $tags)
validate_legacy('Boolean', 'validate_bool', $disable_ssl_validation)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/apache.yaml"
Expand Down
3 changes: 2 additions & 1 deletion manifests/integrations/cassandra.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
$tags = {},
) inherits datadog_agent::params {
require ::datadog_agent
validate_hash($tags)

validate_legacy(Optional[Hash], 'validate_hash', $tags)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/cassandra.yaml"
Expand Down
7 changes: 4 additions & 3 deletions manifests/integrations/ceph.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
# }
#
class datadog_agent::integrations::ceph(
$tags = [ 'name:ceph_cluster' ],
$ceph_cmd = '/usr/bin/ceph',
Array $tags = [ 'name:ceph_cluster' ],
String $ceph_cmd = '/usr/bin/ceph',
) inherits datadog_agent::params {
include datadog_agent

validate_array($tags)
validate_legacy('Array', 'validate_array', $tags)
validate_legacy('String', 'validate_string', $ceph_cmd)

file { '/etc/sudoers.d/datadog_ceph':
content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n"
Expand Down
18 changes: 9 additions & 9 deletions manifests/integrations/consul.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
# }
#
class datadog_agent::integrations::consul(
$url = 'http://localhost:8500',
$catalog_checks = true,
$network_latency_checks = true,
$new_leader_checks = true,
$service_whitelist = []
String $url = 'http://localhost:8500',
Boolean $catalog_checks = true,
Boolean $network_latency_checks = true,
Boolean $new_leader_checks = true,
Optional[Array] $service_whitelist = []
) inherits datadog_agent::params {
include datadog_agent

validate_string($url)
validate_bool($catalog_checks)
validate_bool($new_leader_checks)
validate_array($service_whitelist)
validate_legacy('String', 'validate_string', $url)
validate_legacy('Boolean', 'validate_bool', $catalog_checks)
validate_legacy('Boolean', 'validate_bool', $new_leader_checks)
validate_legacy('Optional[Array]', 'validate_array', $service_whitelist)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/consul.yaml"
Expand Down
26 changes: 13 additions & 13 deletions manifests/integrations/directory.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@
# }

class datadog_agent::integrations::directory (
$directory = '',
$filegauges = false,
$recursive = true,
$countonly = false,
$nametag = '',
$dirtagname = '',
$filetagname = '',
$pattern = '',
$instances = undef,
String $directory = '',
Boolean $filegauges = false,
Boolean $recursive = true,
Boolean $countonly = false,
String $nametag = '',
String $dirtagname = '',
String $filetagname = '',
String $pattern = '',
Optional[Array] $instances = undef,
) inherits datadog_agent::params {
include datadog_agent

validate_string($directory)
validate_bool($filegauges)
validate_bool($recursive)
validate_bool($countonly)
validate_legacy(String, 'validate_string', $directory)
validate_legacy(Boolean, 'validate_bool', $filegauges)
validate_legacy(Boolean, 'validate_bool', $recursive)
validate_legacy(Boolean, 'validate_bool', $countonly)

if !$instances and $directory == '' {
fail('bad directory argument and no instances hash provided')
Expand Down
9 changes: 5 additions & 4 deletions manifests/integrations/disk.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# excluded_disk_re => '/dev/sd[e-z]*'
# }
class datadog_agent::integrations::disk (
$use_mount = 'no',
String $use_mount = 'no',
$excluded_filesystems = undef,
$excluded_disks = undef,
$excluded_disk_re = undef,
Expand All @@ -42,9 +42,10 @@
) inherits datadog_agent::params {
include datadog_agent

validate_re($use_mount, '^(no|yes)$', "use_mount should be either 'yes' or 'no'")
if $all_partitions {
validate_re($all_partitions, '^(no|yes)$', "all_partitions should be either 'yes' or 'no'")
validate_legacy('Optional[String]', 'validate_re', $all_partitions, '^(no|yes)$')

if $use_mount !~ '^(no|yes)$' {
fail('error during compilation')
}

if !$::datadog_agent::agent5_enable {
Expand Down
4 changes: 2 additions & 2 deletions manifests/integrations/dns_check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# }
#
class datadog_agent::integrations::dns_check (
$checks = [
Array $checks = [
{
'hostname' => 'google.com',
'nameserver' => '8.8.8.8',
Expand All @@ -35,7 +35,7 @@
) inherits datadog_agent::params {
include datadog_agent

validate_array($checks)
validate_legacy('Array', 'validate_array', $checks)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/dns_check.yaml"
Expand Down
41 changes: 23 additions & 18 deletions manifests/integrations/elasticsearch.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,36 @@
# }
#
class datadog_agent::integrations::elasticsearch(
$cluster_stats = false,
$password = undef,
$pending_task_stats = true,
$pshard_stats = false,
$ssl_cert = undef,
$ssl_key = undef,
$ssl_verify = true,
$tags = [],
$url = 'http://localhost:9200',
$username = undef,
$instances = undef
$cluster_stats = false,
Optional[String] $password = undef,
$pending_task_stats = true,
$pshard_stats = false,
Optional[String] $ssl_cert = undef,
Optional[String] $ssl_key = undef,
Variant[Boolean, String] $ssl_verify = true,
$tags = [],
$url = 'http://localhost:9200',
Optional[String] $username = undef,
$instances = undef
) inherits datadog_agent::params {
include datadog_agent

validate_array($tags)
validate_legacy(Array, 'validate_array', $tags)
# $ssl_verify can be a bool or a string
# https://github.com/DataDog/dd-agent/blob/master/checks.d/elastic.py#L454-L455
if is_bool($ssl_verify) {
validate_bool($ssl_verify)
} elsif $ssl_verify != undef {
validate_string($ssl_verify)
if validate_legacy('Variant[Boolean, String]', 'is_string', $ssl_verify){
validate_absolute_path($ssl_verify)
}
validate_bool($cluster_stats, $pending_task_stats, $pshard_stats)
validate_string($password, $ssl_cert, $ssl_key, $url, $username)


validate_legacy('Boolean', 'validate_bool', $cluster_stats)
validate_legacy('Boolean', 'validate_bool', $pending_task_stats)
validate_legacy('Boolean', 'validate_bool', $pshard_stats)

validate_legacy('Optional[String]', 'validate_string', $password)
validate_legacy('Optional[String]', 'validate_string', $ssl_cert)
validate_legacy('Optional[String]', 'validate_string', $ssl_key)
validate_legacy('Optional[String]', 'validate_string', $username)

if !$instances and $url {
$_instances = [{
Expand Down
4 changes: 2 additions & 2 deletions manifests/integrations/fluentd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#
class datadog_agent::integrations::fluentd(
$monitor_agent_url = 'http://localhost:24220/api/plugins.json',
$plugin_ids = [],
Optional[Array] $plugin_ids = [],
) inherits datadog_agent::params {
include ::datadog_agent

validate_array($plugin_ids)
validate_legacy('Optional[Array]', 'validate_array', $plugin_ids)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/fluentd.yaml"
Expand Down
8 changes: 4 additions & 4 deletions manifests/integrations/generic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
# }
#
class datadog_agent::integrations::generic(
$integration_name = undef,
$integration_contents = undef,
Optional[String] $integration_name = undef,
Optional[String] $integration_contents = undef,
) inherits datadog_agent::params {

validate_string($integration_name)
validate_string($integration_contents)
validate_legacy('Optional[String]', 'validate_string', $integration_name)
validate_legacy('Optional[String]', 'validate_string', $integration_contents)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/${integration_name}.yaml"
Expand Down
8 changes: 7 additions & 1 deletion manifests/integrations/kafka.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@
$servers = $instances
}

file { "${datadog_agent::params::conf_dir}/kafka.yaml":
if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/kafka.yaml"
} else {
$dst = "${datadog_agent::conf_dir}/kafka.yaml"
}

file { $dst:
ensure => file,
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
Expand Down
17 changes: 8 additions & 9 deletions manifests/integrations/memcache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@
# }
#
class datadog_agent::integrations::memcache (
$url = 'localhost',
$port = 11211,
$tags = [],
$items = false,
$slabs = false,
$instances = undef,
String $url = 'localhost',
Variant[String, Integer] $port = 11211,
Array $tags = [],
Variant[Boolean, String] $items = false,
Variant[Boolean, String] $slabs = false,
Optional[Array] $instances = undef,
) inherits datadog_agent::params {
include datadog_agent

validate_string($url)
validate_array($tags)
validate_integer($port)
validate_legacy('String', 'validate_string', $url)
validate_legacy('Array', 'validate_array', $tags)

if !$instances and $url {
$_instances = [{
Expand Down
3 changes: 2 additions & 1 deletion manifests/integrations/mongo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
) inherits datadog_agent::params {
include datadog_agent

validate_array($servers)

validate_legacy('Array', 'validate_array', $servers)

if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/mongo.yaml"
Expand Down
31 changes: 16 additions & 15 deletions manifests/integrations/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,25 @@
#
#
class datadog_agent::integrations::mysql(
$password,
$host = 'localhost',
$user = 'datadog',
$port = 3306,
$sock = undef,
$tags = [],
$replication = '0',
$galera_cluster = '0',
$extra_status_metrics = false,
$extra_innodb_metrics = false,
$extra_performance_metrics = false,
$schema_size_metrics = false,
$disable_innodb_metrics = false,
$instances = undef,
String $password,
String $host = 'localhost',
String $user = 'datadog',
Variant[String, Integer] $port = 3306,
Optional[String] $sock = undef,
Array $tags = [],
$replication = '0',
$galera_cluster = '0',
Boolean $extra_status_metrics = false,
Boolean $extra_innodb_metrics = false,
Boolean $extra_performance_metrics = false,
Boolean $schema_size_metrics = false,
Boolean $disable_innodb_metrics = false,
Optional[Array] $instances = undef,
) inherits datadog_agent::params {
include datadog_agent

validate_array($tags)
validate_legacy('Optional[String]', 'validate_string', $sock)
validate_legacy('Array', 'validate_array', $tags)

if !$instances and $host {
$_instances = [{
Expand Down
Loading