From e244866f3457321a6926b383f0b527c6ce9e8584 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 22 Jul 2024 21:25:13 +0200 Subject: [PATCH] tasks: replace os_identification with facts the facts task is vendored into bolt. It supports gathering facts from systems with and without facter installed. --- REFERENCE.md | 7 ------- plans/util/retrieve_and_upload.pp | 4 ++-- spec/plans/util/retrieve_and_upload_spec.rb | 2 +- tasks/os_identification.json | 9 --------- tasks/os_identification.ps1 | 18 ------------------ tasks/os_identification.sh | 17 ----------------- 6 files changed, 3 insertions(+), 54 deletions(-) delete mode 100644 tasks/os_identification.json delete mode 100644 tasks/os_identification.ps1 delete mode 100644 tasks/os_identification.sh diff --git a/REFERENCE.md b/REFERENCE.md index d430b87c..85790bef 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -72,7 +72,6 @@ * [`infrastatus`](#infrastatus): Runs puppet infra status and returns the output * [`mkdir_p_file`](#mkdir_p_file): Create a file with the specified content at the specified location * [`mv`](#mv): Wrapper task for mv command -* [`os_identification`](#os_identification): Return the operating system runnin gon the target as a string * [`pe_install`](#pe_install): Install Puppet Enterprise from a tarball * [`pe_ldap_config`](#pe_ldap_config): Set the ldap config in the PE console * [`pe_uninstall`](#pe_uninstall): Uninstall Puppet Enterprise @@ -1298,12 +1297,6 @@ Data type: `String` New path of file -### `os_identification` - -Return the operating system runnin gon the target as a string - -**Supports noop?** false - ### `pe_install` Install Puppet Enterprise from a tarball diff --git a/plans/util/retrieve_and_upload.pp b/plans/util/retrieve_and_upload.pp index 51002d28..357b139b 100644 --- a/plans/util/retrieve_and_upload.pp +++ b/plans/util/retrieve_and_upload.pp @@ -29,8 +29,8 @@ |-HEREDOC # lint:endignore - $operating_system = run_task('peadm::os_identification', 'local://localhost') - $os_string =$operating_system.first.value['_output'] + $operating_system = run_task('facts', 'local://localhost') + $os_string =$operating_system.first.value['os']['family'] if 'windows' in $os_string { $exists = run_command("[System.IO.File]::Exists('${local_path}')", 'local://localhost') diff --git a/spec/plans/util/retrieve_and_upload_spec.rb b/spec/plans/util/retrieve_and_upload_spec.rb index a13f45da..feb18f1b 100644 --- a/spec/plans/util/retrieve_and_upload_spec.rb +++ b/spec/plans/util/retrieve_and_upload_spec.rb @@ -5,7 +5,7 @@ include BoltSpec::Plans it 'file needs downloaded and needs uploaded' do - expect_task('peadm::os_identification') + allow_task('facts').be_called_times(1).with_targets('local://localhost').always_return({ 'os' => { 'family' => 'RedHat' } }) expect_command("test -e '/tmp/download'").error_with('kind' => 'nope', 'msg' => 'The command failed with exit code 1') expect_task('peadm::download') expect_task('peadm::filesize').be_called_times(2).return_for_targets( diff --git a/tasks/os_identification.json b/tasks/os_identification.json deleted file mode 100644 index 3b54dc87..00000000 --- a/tasks/os_identification.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "description": "Return the operating system runnin gon the target as a string", - "parameters": { }, - "implementations": [ - {"name": "os_identification.sh", "requirements": ["shell"], "input_method": "environment"}, - {"name": "os_identification.ps1", "requirements": ["powershell"]} - ] - } - diff --git a/tasks/os_identification.ps1 b/tasks/os_identification.ps1 deleted file mode 100644 index f8bb39d7..00000000 --- a/tasks/os_identification.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -# os_identification.ps1 -try { - - $os = [System.Environment]::OSVersion.Platform - - if ($os -eq "Win32NT") { - $osfamily = "windows" - }elseif ($os -eq "Unix") { - $osfamily = "unix" - }else { - $osfamily = "unknown" - } - - return $osfamily -}catch { - Write-Host "Installer failed with Exception: $_.Exception.Message" - Exit 1 -} diff --git a/tasks/os_identification.sh b/tasks/os_identification.sh deleted file mode 100644 index 3e80ac5e..00000000 --- a/tasks/os_identification.sh +++ /dev/null @@ -1,17 +0,0 @@ -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - osfamily="linux" -elif [[ "$OSTYPE" == "darwin"* ]]; then - osfamily="macOS" -elif [[ "$OSTYPE" == "cygwin" ]]; then - osfamily="cygwin" -elif [[ "$OSTYPE" == "msys" ]]; then - osfamily="msys" -elif [[ "$OSTYPE" == "win32" ]]; then - osfamily="windows" -elif [[ "$OSTYPE" == "freebsd"* ]]; then - osfamily="freebsd" -else - osfamily="unknown" -fi - - echo $osfamily