diff --git a/lib/facter/beta_repo.rb b/lib/facter/beta_repo.rb new file mode 100644 index 00000000..44b3bf6a --- /dev/null +++ b/lib/facter/beta_repo.rb @@ -0,0 +1,5 @@ +Facter.add('apt_agent6_beta_repo') do + setcode do + File.exist? '/etc/apt/sources.list.d/datadog-beta.list' + end +end diff --git a/manifests/ubuntu.pp b/manifests/ubuntu.pp index ebcca8d8..8ed34fe2 100644 --- a/manifests/ubuntu.pp +++ b/manifests/ubuntu.pp @@ -32,15 +32,37 @@ } } - file { '/etc/apt/sources.list.d/datadog-beta.list': - ensure => absent, + # This is a hack - I'm not happy about it, but we should rarely + # hit this code path + # + # Also, using $::apt_agent6_beta_repo to access fact instead of + # $facts hash - for compatibility with puppet3.x default behavior + if $::apt_agent6_beta_repo and $agent_version == 'latest' { + exec { 'datadog_apt-get_remove_agent6': + command => '/usr/bin/apt-get remove -y -q datadog-agent', + } + } else { + exec { 'datadog_apt-get_remove_agent6': + command => ':', # NOOP builtin + noop => true, + refreshonly => true, + provider => 'shell', + } + } + + if $::apt_agent6_beta_repo { + file { '/etc/apt/sources.list.d/datadog-beta.list': + ensure => absent, + } } file { '/etc/apt/sources.list.d/datadog.list': + ensure => file, owner => 'root', group => 'root', content => template('datadog_agent/datadog.list.erb'), - notify => Exec['datadog_apt-get_update'], + notify => [Exec['datadog_apt-get_remove_agent6'], + Exec['datadog_apt-get_update']], require => Package['apt-transport-https'], } @@ -49,7 +71,7 @@ refreshonly => true, tries => 2, # https://bugs.launchpad.net/launchpad/+bug/1430011 won't get fixed until 16.04 xenial try_sleep => 30, - require => File['/etc/apt/sources.list.d/datadog-beta.list'], + require => File['/etc/apt/sources.list.d/datadog.list'], } package { 'datadog-agent-base': @@ -70,5 +92,4 @@ pattern => 'dd-agent', require => Package['datadog-agent'], } - } diff --git a/metadata.json b/metadata.json index f7cf8209..4905b3f3 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "datadog-datadog_agent", - "version": "1.12.0-alpha", + "version": "1.12.0", "author": "James Turnbull () and Rob Terhaar () for Datadog Inc.", "summary": "Install the Datadog monitoring agent and report Puppet runs to Datadog", "license": "Apache-2.0",