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

$conf_dir_purge breaks when $agent5_enable is false #512

Open
gotyaoi opened this issue Apr 10, 2019 · 1 comment
Open

$conf_dir_purge breaks when $agent5_enable is false #512

gotyaoi opened this issue Apr 10, 2019 · 1 comment

Comments

@gotyaoi
Copy link
Contributor

gotyaoi commented Apr 10, 2019

If the $conf_dir_purge setting is true and $agent5_enable is false, puppet will purge all the directories of the integrations in conf.d created by first class integration, ie. datadog_agent::integrations::*, and not those created by datadog_agent::integration. It will then try to create the yaml file for the check and fail, as the directory is gone.

This seems to occur because while datadog_agent::integration creates a file resource for the directory when $agent5_enable is false, datadog_agent::integrations::* do not.

@Aramack
Copy link
Contributor

Aramack commented May 1, 2019

This occurs because the conf_dir_purge value purges untracked files from the conf directoy.
https://github.com/DataDog/puppet-datadog-agent/blob/master/manifests/init.pp#L654

Currently, the integration.d directories within conf.d are created when the agent is installed, but they're not tracked anywhere by puppet.

However, the datadog::integration modules assume the integration.d directories will be present:
https://github.com/DataDog/puppet-datadog-agent/blob/master/manifests/integrations/disk.pp#L59

As a result, having these flags set will result in an error like:

Error: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /etc/datadog-agent/conf.d/disk.d/conf.yaml20190501-1944-1hui08f.lock (file: /etc/puppetlabs/code/puppet-cloud/module-2/datadog_agent/manifests/integrations/disk.pp, line: 67)

Puppet doesn't have a way to recursively create files along a path, so this would need to be fixed by tracking the file with something like:

if !$::datadog_agent::agent5_enable {
  $dst_dir = "${datadog_agent::conf6_dir}/disk.d"
  file { $legacy_dst:
    ensure => 'absent'
  }
  file { $dst_dir:
    ensure  => directory,
    owner   => $datadog_agent::params::dd_user,
    group   => $datadog_agent::params::dd_group,
    mode    => '0755',
    require => Package[$datadog_agent::params::package_name],
    notify  => Service[$datadog_agent::params::service_name]
  }
  $dst = "${dst_dir}/conf.yaml"
else {
  $dst = $legacy_dst
}

I also would like to see a solution to this problem, because using $conf_dir_purge is an effective way to remove a check that is no longer needed from a hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants