Skip to content

Commit

Permalink
replace to many if else blocks with a simple variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bk-lg committed Nov 18, 2024
1 parent 4a5af5c commit 12b8a3f
Showing 1 changed file with 21 additions and 49 deletions.
70 changes: 21 additions & 49 deletions manifests/package/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,69 +32,37 @@
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': {
$mainline_repo_source = $repo_source ? {
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': {
$passenger_repo_source = $repo_source ? {
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:
Expand Down

0 comments on commit 12b8a3f

Please sign in to comment.