diff --git a/README.md b/README.md index 6a6a9eeb..86fe3d24 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ To enable the Datadog Agent Network Performance Monitoring (NPM) features follow ```conf class { 'datadog_agent::system_probe': - network_enabled => true, + network_enabled => true, } ``` @@ -214,7 +214,7 @@ To enable the Datadog Agent Universal Service Monitoring (USM) use the `datadog_ ```conf class { 'datadog_agent::system_probe': - service_monitoring_enabled => true, + service_monitoring_enabled => true, } ``` @@ -276,7 +276,7 @@ To generate tags from custom facts classify your nodes with Puppet facts as an a ```conf class { "datadog_agent": api_key => "", - facts_to_tags => ["osfamily","networking.domain","my_custom_fact"], + facts_to_tags => ["os.family","networking.domain","my_custom_fact"], } ``` diff --git a/manifests/init.pp b/manifests/init.pp index f20158cc..d52a9111 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -381,7 +381,7 @@ fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}") } - if ($::operatingsystem == 'Windows' and $windows_ddagentuser_name != undef) { + if ($facts['os']['name'] == 'Windows' and $windows_ddagentuser_name != undef) { $dd_user = $windows_ddagentuser_name } else { $dd_user = $datadog_agent::params::dd_user @@ -423,7 +423,7 @@ # Install agent if $manage_install { - case $::operatingsystem { + case $facts['os']['name'] { 'Ubuntu','Debian','Raspbian' : { if $use_apt_backup_keyserver != undef or $apt_backup_keyserver != undef or $apt_keyserver != undef { notify { 'apt keyserver arguments deprecation': @@ -477,7 +477,7 @@ rpm_repo_gpgcheck => $rpm_repo_gpgcheck, } } - default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") } + default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } } } else { if ! defined(Package[$agent_flavor]) { @@ -496,7 +496,7 @@ service_provider => $service_provider, } - if ($::operatingsystem != 'Windows') { + if ($facts['os']['name'] != 'Windows') { if ($dd_groups) { user { $dd_user: groups => $dd_groups, @@ -516,7 +516,7 @@ if $_agent_major_version == 5 { - if ($::operatingsystem == 'Windows') { + if ($facts['os']['name'] == 'Windows') { fail('Installation of agent 5 with puppet is not supported on Windows') } @@ -752,7 +752,7 @@ $agent_config = deep_merge($_agent_config, $extra_config) - if ($::operatingsystem == 'Windows') { + if ($facts['os']['name'] == 'Windows') { file { 'C:/ProgramData/Datadog': diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index 3eeef9d4..ee8728b2 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -18,7 +18,7 @@ # class datadog_agent::integrations::haproxy( $creds = {}, - $url = "http://${::ipaddress}:8080", + $url = "http://${facts['networking']['ip']}:8080", $options = {}, Optional[Array] $instances = undef ) inherits datadog_agent::params { diff --git a/manifests/integrations/ssh.pp b/manifests/integrations/ssh.pp index 4750303d..697497bc 100644 --- a/manifests/integrations/ssh.pp +++ b/manifests/integrations/ssh.pp @@ -27,7 +27,7 @@ # class datadog_agent::integrations::ssh( - $host = $::fqdn, + $host = $trusted['certname'], $port = 22, $username = $datadog_agent::dd_user, $password = undef, diff --git a/manifests/params.pp b/manifests/params.pp index a3ab161a..26297f4b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,7 +23,7 @@ $securityagent_service_name = 'datadog-agent-security' $module_metadata = load_module_metadata($module_name) - case $::operatingsystem { + case $facts['os']['name'] { 'Ubuntu','Debian','Raspbian' : { $rubydev_package = 'ruby-dev' case $::operatingsystemrelease{ @@ -83,7 +83,7 @@ $permissions_protected_file = '0660' # as bug in: https://tickets.puppetlabs.com/browse/PA-2877 $agent_binary = 'C:/Program Files/Datadog/Datadog Agent/embedded/agent.exe' } - default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") } + default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } } } diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 398be603..40237990 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -25,10 +25,10 @@ $repo_gpgcheck = $rpm_repo_gpgcheck } else { if ($agent_repo_uri == undef) and ($agent_major_version > 5) { - case $::operatingsystem { + case $facts['os']['name'] { 'RedHat', 'CentOS', 'OracleLinux': { # disable repo_gpgcheck on 8.1 because of https://bugzilla.redhat.com/show_bug.cgi?id=1792506 - if $::operatingsystemrelease =~ /^8.1/ { + if $facts['os']['release']['full'] =~ /^8.1/ { $repo_gpgcheck = false } else { $repo_gpgcheck = true @@ -46,15 +46,15 @@ case $agent_major_version { 5 : { - $defaulturl = "https://yum.datadoghq.com/rpm/${::architecture}/" + $defaulturl = "https://yum.datadoghq.com/rpm/${facts['os']['architecture']}/" $gpgkeys = $keys } 6 : { - $defaulturl = "https://yum.datadoghq.com/stable/6/${::architecture}/" + $defaulturl = "https://yum.datadoghq.com/stable/6/${facts['os']['architecture']}/" $gpgkeys = $keys } 7 : { - $defaulturl = "https://yum.datadoghq.com/stable/7/${::architecture}/" + $defaulturl = "https://yum.datadoghq.com/stable/7/${facts['os']['architecture']}/" $gpgkeys = $keys } default: { fail('invalid agent_major_version') } diff --git a/manifests/reports.pp b/manifests/reports.pp index 9ff40a47..ad3fb119 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -29,7 +29,7 @@ $puppet_gem_provider = $datadog_agent::params::gem_provider, ) inherits datadog_agent::params { - if ($::operatingsystem == 'Windows') { + if ($facts['os']['name'] == 'Windows') { fail('Reporting is not yet supported from a Windows host') diff --git a/manifests/security_agent.pp b/manifests/security_agent.pp index d68a8548..eceb1203 100644 --- a/manifests/security_agent.pp +++ b/manifests/security_agent.pp @@ -15,7 +15,7 @@ }, } - if $::operatingsystem == 'Windows' { + if $facts['os']['name'] == 'Windows' { file { 'C:/ProgramData/Datadog/security-agent.yaml': owner => $datadog_agent::params::dd_user, diff --git a/manifests/service.pp b/manifests/service.pp index 6eda3c09..fbd74eef 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -10,7 +10,7 @@ String $agent_flavor = $datadog_agent::params::package_name, ) inherits datadog_agent::params { - if ($::operatingsystem == 'Windows') { + if ($facts['os']['name'] == 'Windows') { service { $datadog_agent::params::service_name: ensure => $service_ensure, enable => $service_enable, diff --git a/manifests/suse.pp b/manifests/suse.pp index e837b1f3..554d801a 100644 --- a/manifests/suse.pp +++ b/manifests/suse.pp @@ -40,7 +40,7 @@ if ($agent_repo_uri != undef) { $baseurl = $agent_repo_uri } else { - $baseurl = "https://yum.datadoghq.com/suse/${release}/${agent_major_version}/${::architecture}" + $baseurl = "https://yum.datadoghq.com/suse/${release}/${agent_major_version}/${facts['os']['architecture']}" } package { 'datadog-agent-base': @@ -78,7 +78,7 @@ name => 'datadog', gpgcheck => 1, # zypper on SUSE < 15 only understands a single gpgkey value - gpgkey => (Float($::operatingsystemmajrelease) >= 15.0) ? { true => join($gpgkeys, "\n "), default => $current_key }, + gpgkey => (Float($facts['os']['release']['full']) >= 15.0) ? { true => join($gpgkeys, "\n "), default => $current_key }, # TODO: when updating zypprepo to 4.0.0, uncomment the repo_gpgcheck line # For now, we can leave this commented, as zypper by default does repodata # signature checks if the repomd.xml.asc is present, so repodata checks diff --git a/manifests/system_probe.pp b/manifests/system_probe.pp index 420c1ea0..df0443a5 100644 --- a/manifests/system_probe.pp +++ b/manifests/system_probe.pp @@ -1,7 +1,7 @@ # Class: datadog_agent::system_probe # # This class contains the Datadog agent system probe (NPM) configuration. -# On Windows, install the NPM driver by setting 'windows_npm_install' +# On Windows, install the NPM driver by setting 'windows_npm_install' # to 'true on the datadog_agent class. # @@ -36,7 +36,7 @@ 'runtime_security_config' => $runtime_security_config, } - if $::operatingsystem == 'Windows' { + if $facts['os']['name'] == 'Windows' { file { 'C:/ProgramData/Datadog/system-probe.yaml': owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, diff --git a/manifests/ubuntu.pp b/manifests/ubuntu.pp index d7237ff4..806cbef8 100644 --- a/manifests/ubuntu.pp +++ b/manifests/ubuntu.pp @@ -62,8 +62,8 @@ } } - if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16') == -1) or - ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') == -1) { + if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16') == -1) or + ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { file { $apt_trusted_d_keyring: mode => '0644', source => "file://${apt_usr_share_keyring}", diff --git a/spec/classes/datadog_agent_integrations_haproxy_spec.rb b/spec/classes/datadog_agent_integrations_haproxy_spec.rb index fe8c1116..cd03c8a5 100644 --- a/spec/classes/datadog_agent_integrations_haproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_haproxy_spec.rb @@ -6,7 +6,7 @@ let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } let(:facts) do { - ipaddress: '1.2.3.4', + networking: { 'ip' => '1.2.3.4' }, } end diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 4597ef5b..889cc9ea 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -8,9 +8,15 @@ let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'Fedora', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'Fedora', + 'release' => { + 'major' => '36', + 'full' => '36', + }, + }, } end @@ -58,9 +64,15 @@ context 'agent 6' do let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'Fedora', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'Fedora', + 'release' => { + 'major' => '36', + 'full' => '36', + }, + }, } end @@ -108,9 +120,15 @@ context 'agent 7' do let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'Fedora', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'Fedora', + 'release' => { + 'major' => '36', + 'full' => '36', + }, + }, } end @@ -160,10 +178,15 @@ # we expect repo_gpgcheck to be false on 8.1 let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'RedHat', - operatingsystemrelease: '8.1', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'RedHat', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, + }, } end @@ -193,10 +216,15 @@ # we expect repo_gpgcheck to be true on 8.2 (and later) let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'RedHat', - operatingsystemrelease: '8.2', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'RedHat', + 'release' => { + 'major' => '8', + 'full' => '8.2', + }, + }, } end @@ -226,10 +254,15 @@ context 'almalinux 8', if: min_puppet_version('7.12.0') do let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'AlmaLinux', - operatingsystemrelease: '8.5', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'AlmaLinux', + 'release' => { + 'major' => '8', + 'full' => '8.5', + }, + }, } end @@ -258,10 +291,15 @@ context 'rocky 8', if: min_puppet_version('7.12.0') do let(:facts) do { - osfamily: 'redhat', - operatingsystem: 'Rocky', - operatingsystemrelease: '8.5', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'Rocky', + 'release' => { + 'major' => '8', + 'full' => '8.5', + }, + }, } end diff --git a/spec/classes/datadog_agent_reports_spec.rb b/spec/classes/datadog_agent_reports_spec.rb index 1ff45f21..a88c2041 100644 --- a/spec/classes/datadog_agent_reports_spec.rb +++ b/spec/classes/datadog_agent_reports_spec.rb @@ -20,9 +20,15 @@ describe "datadog_agent class common actions on #{operatingsystem}" do let(:facts) do { - operatingsystem: operatingsystem, - osfamily: getosfamily(operatingsystem), - operatingsystemrelease: getosrelease(operatingsystem), + os: { + 'architecture' => 'x86_64', + 'family' => getosfamily(operatingsystem), + 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, + }, } end @@ -81,8 +87,15 @@ describe 'datadog_agent class dogapi version override' do let(:facts) do { - operatingsystem: 'Debian', - osfamily: 'debian', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, + }, } end @@ -123,8 +136,15 @@ describe 'datadog_agent class puppet gem provider override' do let(:facts) do { - operatingsystem: 'Debian', - osfamily: 'debian', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, + }, } end @@ -160,8 +180,15 @@ describe 'datadog_agent class dogapi version override' do let(:facts) do { - operatingsystem: 'Debian', - osfamily: 'debian', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, + }, } end @@ -199,8 +226,15 @@ describe 'datadog_agent class dogapi version override' do let(:facts) do { - operatingsystem: 'Debian', - osfamily: 'debian', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, + }, } end diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index c0ffa73c..d765197e 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -6,8 +6,15 @@ describe 'datadog_agent class without any parameters on Solaris/Nexenta' do let(:facts) do { - osfamily: 'Solaris', - operatingsystem: 'Nexenta', + os: { + 'architecture' => 'x86_64', + 'family' => 'Solaris', + 'name' => 'Nexenta', + 'release' => { + 'major' => '3', + 'full' => '3.0', + }, + }, } end @@ -27,8 +34,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -46,8 +60,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -65,8 +86,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -84,8 +112,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -103,8 +138,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -122,8 +164,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -141,8 +190,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -162,8 +218,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -179,8 +242,15 @@ context 'windows NPM' do let(:facts) do { - osfamily: 'windows', - operatingsystem: 'Windows', + os: { + 'architecture' => 'x86_64', + 'family' => 'windows', + 'name' => 'Windows', + 'release' => { + 'major' => '2019', + 'full' => '2019 SP1', + }, + }, } end @@ -226,8 +296,15 @@ ALL_OS.each do |operatingsystem| let(:facts) do { - operatingsystem: operatingsystem, - osfamily: getosfamily(operatingsystem), + os: { + 'architecture' => 'x86_64', + 'family' => getosfamily(operatingsystem), + 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, + }, } end @@ -268,8 +345,15 @@ end let(:facts) do { - operatingsystem: operatingsystem, - osfamily: getosfamily(operatingsystem), + os: { + 'architecture' => 'x86_64', + 'family' => getosfamily(operatingsystem), + 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, + }, } end @@ -1620,8 +1704,15 @@ end let(:facts) do { - operatingsystem: operatingsystem, - osfamily: getosfamily(operatingsystem), + os: { + 'architecture' => 'x86_64', + 'family' => getosfamily(operatingsystem), + 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, + }, } end @@ -1646,8 +1737,15 @@ end let(:facts) do { - operatingsystem: operatingsystem, - osfamily: getosfamily(operatingsystem), + os: { + 'architecture' => 'x86_64', + 'family' => getosfamily(operatingsystem), + 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, + }, } end @@ -2249,14 +2347,21 @@ { agent_major_version: 6, puppet_run_reports: true, - facts_to_tags: ['osfamily'], + facts_to_tags: ['os.family'], trusted_facts_to_tags: ['extensions.trusted_fact', 'extensions.facts_array', 'extensions.facts_hash.actor.first_name'], } end let(:facts) do { - 'operatingsystem' => 'CentOS', - 'osfamily' => 'redhat', + 'os' => { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'CentOS', + 'release' => { + 'major' => '6', + 'full' => '6.3', + }, + }, } end let(:trusted_facts) do @@ -2274,7 +2379,7 @@ it do is_expected.to contain_file('/etc/datadog-agent/datadog.yaml') - .with_content(%r{tags:\n- osfamily:redhat\n- extensions.trusted_fact:test\n- extensions.facts_array:one\n- extensions.facts_array:two\n- extensions.facts_hash.actor.first_name:Macaulay}) + .with_content(%r{tags:\n- os.family:redhat\n- extensions.trusted_fact:test\n- extensions.facts_array:one\n- extensions.facts_array:two\n- extensions.facts_hash.actor.first_name:Macaulay}) end end end @@ -2285,13 +2390,11 @@ { agent_major_version: 6, puppet_run_reports: true, - facts_to_tags: ['osfamily', 'facts_array', 'facts_hash.actor.first_name', 'looks.like.a.path'], + facts_to_tags: ['os.family', 'facts_array', 'facts_hash.actor.first_name', 'looks.like.a.path'], } end let(:facts) do { - 'operatingsystem' => 'CentOS', - 'osfamily' => 'redhat', 'facts_array' => ['one', 'two'], 'facts_hash' => { 'actor' => { @@ -2300,12 +2403,21 @@ }, }, 'looks.like.a.path' => 'but_its_not', + 'os' => { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'CentOS', + 'release' => { + 'major' => '6', + 'full' => '6.3', + }, + }, } end it do is_expected.to contain_file('/etc/datadog-agent/datadog.yaml') - .with_content(%r{tags:\n- osfamily:redhat\n- facts_array:one\n- facts_array:two\n- facts_hash.actor.first_name:Macaulay\n- looks.like.a.path:but_its_not}) + .with_content(%r{tags:\n- os.family:redhat\n- facts_array:one\n- facts_array:two\n- facts_hash.actor.first_name:Macaulay\n- looks.like.a.path:but_its_not}) end end @@ -2319,9 +2431,17 @@ end let(:facts) do { - operatingsystem: 'CentOS', - osfamily: 'redhat', facts_array: ['one', 'two'], + osfamily: 'redhat', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'CentOS', + 'release' => { + 'major' => '6', + 'full' => '6.3', + }, + }, } end diff --git a/spec/classes/datadog_agent_suse_spec.rb b/spec/classes/datadog_agent_suse_spec.rb index ab0ead18..fbfe5e7a 100644 --- a/spec/classes/datadog_agent_suse_spec.rb +++ b/spec/classes/datadog_agent_suse_spec.rb @@ -7,15 +7,30 @@ let(:facts) do { - operatingsystem: 'OpenSuSE', - architecture: 'x86_64', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'OpenSuSE', + 'release' => { + 'major' => '14', + 'full' => '14.3', + }, + }, } end context 'suse >= 15' do let(:facts) do { - operatingsystemmajrelease: '15', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'OpenSuSE', + 'release' => { + 'major' => '15', + 'full' => '15.3', + }, + }, } end @@ -63,7 +78,15 @@ context 'suse < 15' do let(:facts) do { - operatingsystemmajrelease: '14', + os: { + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'OpenSuSE', + 'release' => { + 'major' => '14', + 'full' => '14.3', + }, + }, } end diff --git a/spec/classes/datadog_agent_ubuntu_spec.rb b/spec/classes/datadog_agent_ubuntu_spec.rb index d7335aa6..6de162e5 100644 --- a/spec/classes/datadog_agent_ubuntu_spec.rb +++ b/spec/classes/datadog_agent_ubuntu_spec.rb @@ -34,8 +34,15 @@ end let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -79,8 +86,15 @@ let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -124,8 +138,15 @@ let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -166,9 +187,15 @@ let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', - operatingsystemrelease: '14.04', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, + }, } end @@ -184,9 +211,15 @@ let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Ubuntu', - operatingsystemrelease: '16.04', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Ubuntu', + 'release' => { + 'major' => '16', + 'full' => '16.04', + }, + }, } end @@ -202,9 +235,15 @@ let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Debian', - operatingsystemrelease: '8.0', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.0', + }, + }, } end @@ -220,9 +259,15 @@ let(:facts) do { - osfamily: 'debian', - operatingsystem: 'Debian', - operatingsystemrelease: '9.0', + os: { + 'architecture' => 'x86_64', + 'family' => 'debian', + 'name' => 'Debian', + 'release' => { + 'major' => '9', + 'full' => '9.0', + }, + }, } end diff --git a/spec/defines/datadog_agent__install_integration_spec.rb b/spec/defines/datadog_agent__install_integration_spec.rb index 271c6b99..4ad2ef51 100644 --- a/spec/defines/datadog_agent__install_integration_spec.rb +++ b/spec/defines/datadog_agent__install_integration_spec.rb @@ -5,9 +5,15 @@ ALL_OS.each do |operatingsystem| let(:facts) do { - operatingsystem: operatingsystem, - osfamily: getosfamily(operatingsystem), - operatingsystemrelease: getosrelease(operatingsystem), + os: { + 'architecture' => 'x86_64', + 'family' => getosfamily(operatingsystem), + 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, + }, } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6b345ced..8bf6b938 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,6 +40,16 @@ def getosfamily(operatingsystem) end end +def getosmajor(operatingsystem) + if DEBIAN_OS.include?(operatingsystem) + '14' + elsif REDHAT_OS.include?(operatingsystem) + '7' + else + '2019' + end +end + def getosrelease(operatingsystem) if DEBIAN_OS.include?(operatingsystem) '14.04' @@ -61,12 +71,13 @@ def getosrelease(operatingsystem) 'lsbdistrelease' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), 'lsbdistcodename' => (RSpec::Support::OS.windows? ? '2019' : '14.04'), 'os' => { - 'name' => (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), - 'family' => (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), - 'release' => { - 'major' => (RSpec::Support::OS.windows? ? '2019' : '14'), - 'minor' => (RSpec::Support::OS.windows? ? 'SP1' : '04'), - 'full' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), + 'architecture' => 'x86_64', + 'name' => (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), + 'family' => (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), + 'release' => { + 'major' => (RSpec::Support::OS.windows? ? '2019' : '14'), + 'minor' => (RSpec::Support::OS.windows? ? 'SP1' : '04'), + 'full' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), }, }, }