Skip to content

Commit 3de85cd

Browse files
authored
Fix legacy Facts (#790)
1 parent ded74e0 commit 3de85cd

20 files changed

+410
-133
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ To enable the Datadog Agent Network Performance Monitoring (NPM) features follow
204204
205205
```conf
206206
class { 'datadog_agent::system_probe':
207-
network_enabled => true,
207+
network_enabled => true,
208208
}
209209
```
210210
@@ -214,7 +214,7 @@ To enable the Datadog Agent Universal Service Monitoring (USM) use the `datadog_
214214
215215
```conf
216216
class { 'datadog_agent::system_probe':
217-
service_monitoring_enabled => true,
217+
service_monitoring_enabled => true,
218218
}
219219
```
220220
@@ -276,7 +276,7 @@ To generate tags from custom facts classify your nodes with Puppet facts as an a
276276
```conf
277277
class { "datadog_agent":
278278
api_key => "<YOUR_DD_API_KEY>",
279-
facts_to_tags => ["osfamily","networking.domain","my_custom_fact"],
279+
facts_to_tags => ["os.family","networking.domain","my_custom_fact"],
280280
}
281281
```
282282

manifests/init.pp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}")
382382
}
383383

384-
if ($::operatingsystem == 'Windows' and $windows_ddagentuser_name != undef) {
384+
if ($facts['os']['name'] == 'Windows' and $windows_ddagentuser_name != undef) {
385385
$dd_user = $windows_ddagentuser_name
386386
} else {
387387
$dd_user = $datadog_agent::params::dd_user
@@ -423,7 +423,7 @@
423423

424424
# Install agent
425425
if $manage_install {
426-
case $::operatingsystem {
426+
case $facts['os']['name'] {
427427
'Ubuntu','Debian','Raspbian' : {
428428
if $use_apt_backup_keyserver != undef or $apt_backup_keyserver != undef or $apt_keyserver != undef {
429429
notify { 'apt keyserver arguments deprecation':
@@ -477,7 +477,7 @@
477477
rpm_repo_gpgcheck => $rpm_repo_gpgcheck,
478478
}
479479
}
480-
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") }
480+
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") }
481481
}
482482
} else {
483483
if ! defined(Package[$agent_flavor]) {
@@ -496,7 +496,7 @@
496496
service_provider => $service_provider,
497497
}
498498

499-
if ($::operatingsystem != 'Windows') {
499+
if ($facts['os']['name'] != 'Windows') {
500500
if ($dd_groups) {
501501
user { $dd_user:
502502
groups => $dd_groups,
@@ -516,7 +516,7 @@
516516

517517
if $_agent_major_version == 5 {
518518

519-
if ($::operatingsystem == 'Windows') {
519+
if ($facts['os']['name'] == 'Windows') {
520520
fail('Installation of agent 5 with puppet is not supported on Windows')
521521
}
522522

@@ -752,7 +752,7 @@
752752
$agent_config = deep_merge($_agent_config, $extra_config)
753753

754754

755-
if ($::operatingsystem == 'Windows') {
755+
if ($facts['os']['name'] == 'Windows') {
756756

757757

758758
file { 'C:/ProgramData/Datadog':

manifests/integrations/haproxy.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
class datadog_agent::integrations::haproxy(
2020
$creds = {},
21-
$url = "http://${::ipaddress}:8080",
21+
$url = "http://${facts['networking']['ip']}:8080",
2222
$options = {},
2323
Optional[Array] $instances = undef
2424
) inherits datadog_agent::params {

manifests/integrations/ssh.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#
2828

2929
class datadog_agent::integrations::ssh(
30-
$host = $::fqdn,
30+
$host = $trusted['certname'],
3131
$port = 22,
3232
$username = $datadog_agent::dd_user,
3333
$password = undef,

manifests/params.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
$securityagent_service_name = 'datadog-agent-security'
2424
$module_metadata = load_module_metadata($module_name)
2525

26-
case $::operatingsystem {
26+
case $facts['os']['name'] {
2727
'Ubuntu','Debian','Raspbian' : {
2828
$rubydev_package = 'ruby-dev'
2929
case $::operatingsystemrelease{
@@ -83,7 +83,7 @@
8383
$permissions_protected_file = '0660' # as bug in: https://tickets.puppetlabs.com/browse/PA-2877
8484
$agent_binary = 'C:/Program Files/Datadog/Datadog Agent/embedded/agent.exe'
8585
}
86-
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") }
86+
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") }
8787
}
8888

8989
}

manifests/redhat.pp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
$repo_gpgcheck = $rpm_repo_gpgcheck
2626
} else {
2727
if ($agent_repo_uri == undef) and ($agent_major_version > 5) {
28-
case $::operatingsystem {
28+
case $facts['os']['name'] {
2929
'RedHat', 'CentOS', 'OracleLinux': {
3030
# disable repo_gpgcheck on 8.1 because of https://bugzilla.redhat.com/show_bug.cgi?id=1792506
31-
if $::operatingsystemrelease =~ /^8.1/ {
31+
if $facts['os']['release']['full'] =~ /^8.1/ {
3232
$repo_gpgcheck = false
3333
} else {
3434
$repo_gpgcheck = true
@@ -46,15 +46,15 @@
4646

4747
case $agent_major_version {
4848
5 : {
49-
$defaulturl = "https://yum.datadoghq.com/rpm/${::architecture}/"
49+
$defaulturl = "https://yum.datadoghq.com/rpm/${facts['os']['architecture']}/"
5050
$gpgkeys = $keys
5151
}
5252
6 : {
53-
$defaulturl = "https://yum.datadoghq.com/stable/6/${::architecture}/"
53+
$defaulturl = "https://yum.datadoghq.com/stable/6/${facts['os']['architecture']}/"
5454
$gpgkeys = $keys
5555
}
5656
7 : {
57-
$defaulturl = "https://yum.datadoghq.com/stable/7/${::architecture}/"
57+
$defaulturl = "https://yum.datadoghq.com/stable/7/${facts['os']['architecture']}/"
5858
$gpgkeys = $keys
5959
}
6060
default: { fail('invalid agent_major_version') }

manifests/reports.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
$puppet_gem_provider = $datadog_agent::params::gem_provider,
3030
) inherits datadog_agent::params {
3131

32-
if ($::operatingsystem == 'Windows') {
32+
if ($facts['os']['name'] == 'Windows') {
3333

3434
fail('Reporting is not yet supported from a Windows host')
3535

manifests/security_agent.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
}
1717

18-
if $::operatingsystem == 'Windows' {
18+
if $facts['os']['name'] == 'Windows' {
1919

2020
file { 'C:/ProgramData/Datadog/security-agent.yaml':
2121
owner => $datadog_agent::params::dd_user,

manifests/service.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
String $agent_flavor = $datadog_agent::params::package_name,
1111
) inherits datadog_agent::params {
1212

13-
if ($::operatingsystem == 'Windows') {
13+
if ($facts['os']['name'] == 'Windows') {
1414
service { $datadog_agent::params::service_name:
1515
ensure => $service_ensure,
1616
enable => $service_enable,

manifests/suse.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
if ($agent_repo_uri != undef) {
4141
$baseurl = $agent_repo_uri
4242
} else {
43-
$baseurl = "https://yum.datadoghq.com/suse/${release}/${agent_major_version}/${::architecture}"
43+
$baseurl = "https://yum.datadoghq.com/suse/${release}/${agent_major_version}/${facts['os']['architecture']}"
4444
}
4545

4646
package { 'datadog-agent-base':
@@ -78,7 +78,7 @@
7878
name => 'datadog',
7979
gpgcheck => 1,
8080
# zypper on SUSE < 15 only understands a single gpgkey value
81-
gpgkey => (Float($::operatingsystemmajrelease) >= 15.0) ? { true => join($gpgkeys, "\n "), default => $current_key },
81+
gpgkey => (Float($facts['os']['release']['full']) >= 15.0) ? { true => join($gpgkeys, "\n "), default => $current_key },
8282
# TODO: when updating zypprepo to 4.0.0, uncomment the repo_gpgcheck line
8383
# For now, we can leave this commented, as zypper by default does repodata
8484
# signature checks if the repomd.xml.asc is present, so repodata checks

0 commit comments

Comments
 (0)