Puppet Class: datadog_agent::integrations::docker_daemon

Inherits:
datadog_agent::params
Defined in:
manifests/integrations/docker_daemon.pp

Overview

Class: datadog_agent::integrations::docker_daemon

This class will install the necessary configuration for the docker integration

Parameters:

$url:
  The URL for docker API

$tags:
  optional array of tags

$group:
  optional name of docker group to add dd-agent user too

Sample Usage:

class { 'datadog_agent::integrations::docker_daemon' :
  url           => 'unix://var/run/docker.sock',
}

Parameters:

  • group (Any) (defaults to: 'docker')
  • docker_root (Any) (defaults to: '/')
  • timeout (Any) (defaults to: 10)
  • api_version (Any) (defaults to: 'auto')
  • tls (Any) (defaults to: false)
  • tls_client_cert (Any) (defaults to: '/path/to/client-cert.pem')
  • tls_client_key (Any) (defaults to: '/path/to/client-key.pem')
  • tls_cacert (Any) (defaults to: '/path/to/ca.pem')
  • tls_verify (Any) (defaults to: true)
  • init_retry_interval (Any) (defaults to: 0)
  • init_retries (Any) (defaults to: 0)
  • url (Any) (defaults to: 'unix://var/run/docker.sock')
  • collect_events (Any) (defaults to: true)
  • filtered_event_types (Any) (defaults to: [])
  • collect_container_size (Any) (defaults to: false)
  • custom_cgroups (Any) (defaults to: false)
  • health_service_check_whitelist (Any) (defaults to: [])
  • collect_container_count (Any) (defaults to: false)
  • collect_volume_count (Any) (defaults to: false)
  • collect_images_stats (Any) (defaults to: false)
  • collect_image_size (Any) (defaults to: false)
  • collect_disk_stats (Any) (defaults to: false)
  • collect_exit_codes (Any) (defaults to: false)
  • exclude (Any) (defaults to: [])
  • include (Any) (defaults to: [])
  • tags (Any) (defaults to: [])
  • ecs_tags (Any) (defaults to: true)
  • performance_tags (Any) (defaults to: [])
  • container_tags (Any) (defaults to: [])
  • collect_labels_as_tags (Any) (defaults to: [])
  • event_attributes_as_tags (Any) (defaults to: [])


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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'manifests/integrations/docker_daemon.pp', line 22

class datadog_agent::integrations::docker_daemon(
  $group = 'docker',
  $docker_root = '/',
  $timeout = 10,
  $api_version = 'auto',
  $tls = false,
  $tls_client_cert = '/path/to/client-cert.pem',
  $tls_client_key = '/path/to/client-key.pem',
  $tls_cacert = '/path/to/ca.pem',
  $tls_verify = true,
  $init_retry_interval = 0,
  $init_retries = 0,
  $url = 'unix://var/run/docker.sock',
  $collect_events = true,
  $filtered_event_types = [],
  $collect_container_size = false,
  $custom_cgroups = false,
  $health_service_check_whitelist = [],
  $collect_container_count = false,
  $collect_volume_count = false,
  $collect_images_stats = false,
  $collect_image_size = false,
  $collect_disk_stats = false,
  $collect_exit_codes = false,
  $exclude = [],
  $include = [],
  $tags = [],
  $ecs_tags = true,
  # Possible values: "container_name", "image_name", "image_tag", "docker_image"
  $performance_tags = [],
  # Possible values: "image_name", "image_tag", "docker_image"
  $container_tags = [],
  # Ex. "com.docker.compose.service", "com.docker.compose.project"
  $collect_labels_as_tags = [],
  $event_attributes_as_tags = [],
) inherits datadog_agent::params {
  require ::datadog_agent

  exec { 'dd-agent-should-be-in-docker-group':
    command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::params::dd_user}",
    unless  => "/bin/cat /etc/group | grep '^${group}:' | grep -qw ${datadog_agent::params::dd_user}",
    require => Package[$datadog_agent::params::package_name],
    notify  => Service[$datadog_agent::params::service_name]
  }

  if $::datadog_agent::_agent_major_version > 5 {
    $legacy_dir = "${datadog_agent::params::conf_dir}/docker_daemon.d"

    file { $legacy_dir:
      ensure  => directory,
      owner   => $datadog_agent::params::dd_user,
      group   => $datadog_agent::params::dd_group,
      mode    => $datadog_agent::params::permissions_directory,
      require => Package[$datadog_agent::params::package_name],
      notify  => Service[$datadog_agent::params::service_name]
    }
    $legacy_conf = "${legacy_dir}/conf.yaml"
  } else {
    $legacy_conf = "${datadog_agent::params::legacy_conf_dir}/docker.yaml"
  }

  file { $legacy_conf:
    ensure => 'absent'
  }

  if $::datadog_agent::_agent_major_version > 5 {
    $dst_dir = "${datadog_agent::params::conf_dir}/docker.d"

    file { $dst_dir:
      ensure  => directory,
      owner   => $datadog_agent::params::dd_user,
      group   => $datadog_agent::params::dd_group,
      mode    => $datadog_agent::params::permissions_directory,
      require => Package[$datadog_agent::params::package_name],
      notify  => Service[$datadog_agent::params::service_name]
    }
    $dst = "${dst_dir}/conf.yaml"
  } else {
    $dst = "${datadog_agent::params::legacy_conf_dir}/docker_daemon.yaml"
  }

  file { $dst:
    ensure  => file,
    owner   => $datadog_agent::params::dd_user,
    group   => $datadog_agent::params::dd_group,
    mode    => $datadog_agent::params::permissions_file,
    content => template('datadog_agent/agent-conf.d/docker_daemon.yaml.erb'),
    require => Package[$datadog_agent::params::package_name],
    notify  => Service[$datadog_agent::params::service_name]
  }
}