From 12b8a3fb443009ae49e51ddff66e08acc89dee37 Mon Sep 17 00:00:00 2001 From: Lukas Glitt Date: Mon, 18 Nov 2024 16:13:52 +0100 Subject: [PATCH] replace to many if else blocks with a simple variable --- manifests/package/debian.pp | 70 +++++++++++-------------------------- 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/manifests/package/debian.pp b/manifests/package/debian.pp index 4657233d5..d1a389a08 100644 --- a/manifests/package/debian.pp +++ b/manifests/package/debian.pp @@ -12,6 +12,10 @@ $repo_source = $nginx::repo_source $distro = downcase($facts['os']['name']) + $arch = $facts['os']['architecture'] ? { + 'aarch64' => 'arm64', + default => $facts['os']['architecture'], + } package { 'nginx': ensure => $package_ensure, @@ -28,23 +32,12 @@ undef => "https://nginx.org/packages/${distro}", default => $repo_source, } - if $facts['os']['architecture'] == 'aarch64' { - apt::source { 'nginx': - location => $stable_repo_source, - repos => 'nginx', - key => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }, - release => $release, - architecture => 'arm64', - } - } - else { - apt::source { 'nginx': - location => $stable_repo_source, - repos => 'nginx', - key => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }, - release => $release, - architecture => $facts['os']['architecture'], - } + apt::source { 'nginx': + location => $stable_repo_source, + repos => 'nginx', + key => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }, + release => $release, + architecture => $arch, } } 'nginx-mainline': { @@ -52,23 +45,12 @@ undef => "https://nginx.org/packages/mainline/${distro}", default => $repo_source, } - if $facts['os']['architecture'] == 'aarch64' { - apt::source { 'nginx': - location => $mainline_repo_source, - repos => 'nginx', - key => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }, - release => $release, - architecture => 'arm64', - } - } - else { - apt::source { 'nginx': - location => $mainline_repo_source, - repos => 'nginx', - key => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }, - release => $release, - architecture => $facts['os']['architecture'], - } + apt::source { 'nginx': + location => $mainline_repo_source, + repos => 'nginx', + key => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' }, + release => $release, + architecture => $arch, } } 'passenger': { @@ -76,21 +58,11 @@ undef => 'https://oss-binaries.phusionpassenger.com/apt/passenger', default => $repo_source, } - if $facts['os']['architecture'] == 'aarch64' { - apt::source { 'nginx': - location => $passenger_repo_source, - repos => 'main', - key => { 'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7' }, - architecture => 'arm64', - } - } - else { - apt::source { 'nginx': - location => $passenger_repo_source, - repos => 'main', - key => { 'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7' }, - architecture => $facts['os']['architecture'], - } + apt::source { 'nginx': + location => $passenger_repo_source, + repos => 'main', + key => { 'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7' }, + architecture => $arch, } package { $passenger_package_name: