From 81206e6bf81c2288980242911e481ef82cae5a48 Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Tue, 24 Oct 2023 08:32:08 +0200 Subject: [PATCH] Fill facts with values checks by apt puppet module --- spec/classes/datadog_agent_redhat_spec.rb | 32 ++++++- spec/classes/datadog_agent_reports_spec.rb | 26 +++++- spec/classes/datadog_agent_spec.rb | 89 ++++++++++++++++++- spec/classes/datadog_agent_suse_spec.rb | 21 ++++- spec/classes/datadog_agent_ubuntu_spec.rb | 39 +++++++- ...datadog_agent__install_integration_spec.rb | 6 +- spec/spec_helper.rb | 23 +++-- 7 files changed, 216 insertions(+), 20 deletions(-) diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 2c788075..bf6362e3 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -15,6 +15,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'Fedora', + 'release' => { + 'major' => '36', + 'full' => '36', + }, }, } end @@ -70,6 +74,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'Fedora', + 'release' => { + 'major' => '36', + 'full' => '36', + }, }, } end @@ -125,6 +133,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'Fedora', + 'release' => { + 'major' => '36', + 'full' => '36', + }, }, } end @@ -183,7 +195,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'RedHat', - 'release' => { 'full' => '8.1' }, + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, }, } end @@ -222,7 +237,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'RedHat', - 'release' => { 'full' => '8.2' }, + 'release' => { + 'major' => '8', + 'full' => '8.2', + }, }, } end @@ -261,7 +279,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'AlmaLinux', - 'release' => { 'full' => '8.5' }, + 'release' => { + 'major' => '8', + 'full' => '8.5', + }, }, } end @@ -299,7 +320,10 @@ 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'Rocky', - 'release' => { 'full' => '8.5' }, + '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 0b097f3c..34642be0 100644 --- a/spec/classes/datadog_agent_reports_spec.rb +++ b/spec/classes/datadog_agent_reports_spec.rb @@ -24,9 +24,13 @@ osfamily: getosfamily(operatingsystem), operatingsystemrelease: getosrelease(operatingsystem), os: { + 'architecture' => 'x86_64', 'family' => getosfamily(operatingsystem), 'name' => operatingsystem, - 'release' => { 'full' => getosrelease(operatingsystem) }, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, }, } end @@ -90,8 +94,13 @@ operatingsystem: 'Debian', osfamily: 'debian', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, }, } end @@ -138,8 +147,13 @@ operatingsystem: 'Debian', osfamily: 'debian', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, }, } end @@ -181,8 +195,13 @@ operatingsystem: 'Debian', osfamily: 'debian', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Debian', + 'release' => { + 'major' => '8', + 'full' => '8.1', + }, }, } end @@ -226,8 +245,13 @@ 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 89365edb..f88bc711 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -9,8 +9,13 @@ osfamily: 'Solaris', operatingsystem: 'Nexenta', os: { + 'architecture' => 'x86_64', 'family' => 'Solaris', 'name' => 'Nexenta', + 'release' => { + 'major' => '3', + 'full' => '3.0', + }, }, } end @@ -34,8 +39,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -57,8 +67,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -80,8 +95,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -103,8 +123,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -126,8 +151,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -149,8 +179,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -172,8 +207,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -197,8 +237,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -218,8 +263,13 @@ osfamily: 'windows', operatingsystem: 'Windows', os: { + 'architecture' => 'x86_64', 'family' => 'windows', 'name' => 'Windows', + 'release' => { + 'major' => '2019', + 'full' => '2019 SP1', + }, }, } end @@ -269,8 +319,13 @@ operatingsystem: operatingsystem, osfamily: getosfamily(operatingsystem), os: { + 'architecture' => 'x86_64', 'family' => getosfamily(operatingsystem), 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, }, } end @@ -315,8 +370,13 @@ operatingsystem: operatingsystem, osfamily: getosfamily(operatingsystem), os: { + 'architecture' => 'x86_64', 'family' => getosfamily(operatingsystem), 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, }, } end @@ -1671,8 +1731,13 @@ operatingsystem: operatingsystem, osfamily: getosfamily(operatingsystem), os: { + 'architecture' => 'x86_64', 'family' => getosfamily(operatingsystem), 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, }, } end @@ -1701,8 +1766,13 @@ operatingsystem: operatingsystem, osfamily: getosfamily(operatingsystem), os: { + 'architecture' => 'x86_64', 'family' => getosfamily(operatingsystem), 'name' => operatingsystem, + 'release' => { + 'major' => getosmajor(operatingsystem), + 'full' => getosrelease(operatingsystem), + }, }, } end @@ -2313,9 +2383,14 @@ { 'operatingsystem' => 'CentOS', 'osfamily' => 'redhat', - os => { + 'os' => { + 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'CentOS', + 'release' => { + 'major' => '6', + 'full' => '6.3', + }, }, } end @@ -2360,9 +2435,14 @@ }, }, 'looks.like.a.path' => 'but_its_not', - os => { + 'os' => { + 'architecture' => 'x86_64', 'family' => 'redhat', 'name' => 'CentOS', + 'release' => { + 'major' => '6', + 'full' => '6.3', + }, }, } end @@ -2387,8 +2467,13 @@ osfamily: 'redhat', facts_array: ['one', 'two'], 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 63a3374d..125e8021 100644 --- a/spec/classes/datadog_agent_suse_spec.rb +++ b/spec/classes/datadog_agent_suse_spec.rb @@ -11,7 +11,12 @@ architecture: 'x86_64', os: { 'architecture' => 'x86_64', + 'family' => 'redhat', 'name' => 'OpenSuSE', + 'release' => { + 'major' => '14', + 'full' => '14.3', + }, }, } end @@ -21,7 +26,13 @@ { operatingsystemmajrelease: '15', os: { - 'release' => { 'major' => '15' }, + 'architecture' => 'x86_64', + 'family' => 'redhat', + 'name' => 'OpenSuSE', + 'release' => { + 'major' => '15', + 'full' => '15.3', + }, }, } end @@ -72,7 +83,13 @@ { operatingsystemmajrelease: '14', os: { - 'release' => { 'major' => '14' }, + '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 5bac9a33..2fb98a48 100644 --- a/spec/classes/datadog_agent_ubuntu_spec.rb +++ b/spec/classes/datadog_agent_ubuntu_spec.rb @@ -37,8 +37,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -86,8 +91,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -135,8 +145,13 @@ osfamily: 'debian', operatingsystem: 'Ubuntu', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -182,9 +197,13 @@ operatingsystem: 'Ubuntu', operatingsystemrelease: '14.04', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', - 'release' => { 'full' => '14.04' }, + 'release' => { + 'major' => '14', + 'full' => '14.04', + }, }, } end @@ -205,9 +224,13 @@ operatingsystem: 'Ubuntu', operatingsystemrelease: '16.04', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Ubuntu', - 'release' => { 'full' => '16.04' }, + 'release' => { + 'major' => '16', + 'full' => '16.04', + }, }, } end @@ -228,9 +251,13 @@ operatingsystem: 'Debian', operatingsystemrelease: '8.0', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Debian', - 'release' => { 'full' => '8.0' }, + 'release' => { + 'major' => '8', + 'full' => '8.0', + }, }, } end @@ -251,9 +278,13 @@ operatingsystem: 'Debian', operatingsystemrelease: '9.0', os: { + 'architecture' => 'x86_64', 'family' => 'debian', 'name' => 'Debian', - 'release' => { 'full' => '9.0' }, + '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 d6fbafa8..d5404670 100644 --- a/spec/defines/datadog_agent__install_integration_spec.rb +++ b/spec/defines/datadog_agent__install_integration_spec.rb @@ -9,9 +9,13 @@ osfamily: getosfamily(operatingsystem), operatingsystemrelease: getosrelease(operatingsystem), os: { + 'architecture' => 'x86_64', 'family' => getosfamily(operatingsystem), 'name' => operatingsystem, - 'release' => { 'full' => getosrelease(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'), }, }, }