Skip to content

Commit

Permalink
Add Debian OS family support
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Sep 27, 2024
1 parent 86351c0 commit ee135d6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
fixtures:
repositories:
apt: https://github.com/puppetlabs/puppetlabs-apt.git
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
sudo: https://github.com/saz/puppet-sudo.git
systemd: https://github.com/voxpupuli/puppet-systemd.git
Expand Down
6 changes: 3 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ Data type: `Stdlib::HTTPSUrl`

HTTPS URL to the yumrepo base

Default value: `'https://yum.puppet.com/'`
Default value: `$facts['os']['family'] ? { 'Debian' => 'https://apt.puppet.com/', 'RedHat' => 'https://yum.puppet.com/'`

##### <a name="-bolt--release_package"></a>`release_package`

Data type: `String[1]`

filename for the release package rpm

Default value: `"puppet-tools-release-el-${facts['os']['release']['major']}.noarch.rpm"`
Default value: `$facts['os']['family'] ? { 'Debian' => "puppet-release-${fact('os.distro.codename')}.deb", 'RedHat' => "puppet-tools-release-el-${facts['os']['release']['major']}.noarch.rpm"`

##### <a name="-bolt--gpgkey"></a>`gpgkey`

Data type: `String[1]`

name of the GPG key filename in the repo

Default value: `'RPM-GPG-KEY-puppet-20250406'`
Default value: `$facts['os']['family'] ? { 'Debian' => 'DEB-GPG-KEY-puppet-20250406', 'RedHat' => 'RPM-GPG-KEY-puppet-20250406'`

##### <a name="-bolt--use_release_package"></a>`use_release_package`

Expand Down
33 changes: 20 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#
class bolt (
String[1] $version = 'installed',
Stdlib::HTTPSUrl $base_url = 'https://yum.puppet.com/',
String[1] $release_package = "puppet-tools-release-el-${facts['os']['release']['major']}.noarch.rpm",
String[1] $gpgkey = 'RPM-GPG-KEY-puppet-20250406',
Stdlib::HTTPSUrl $base_url = $facts['os']['family'] ? { 'Debian' => 'https://apt.puppet.com/', 'RedHat' => 'https://yum.puppet.com/', },
String[1] $release_package = $facts['os']['family'] ? { 'Debian' => "puppet-release-${fact('os.distro.codename')}.deb", 'RedHat' => "puppet-tools-release-el-${facts['os']['release']['major']}.noarch.rpm", },
String[1] $gpgkey = $facts['os']['family'] ? { 'Debian' => 'DEB-GPG-KEY-puppet-20250406', 'RedHat' => 'RPM-GPG-KEY-puppet-20250406', },
Boolean $use_release_package = true,
Stdlib::HTTPSUrl $yumrepo_base_url = "${base_url}puppet-tools/el/${facts['os']['release']['major']}/\$basearch",
Boolean $manage_repo = true,
) {
unless $facts['os']['family'] == 'RedHat' {
fail('class bolt only works on RedHat OS family')
unless $facts['os']['family'] in ['RedHat', 'Debian'] {
fail("class bolt only works on ${facts['os']['family']} OS family")
}

$ensure = $version ? {
Expand All @@ -55,14 +55,21 @@
before => Package['puppet-bolt'],
}
} else {
yumrepo { 'puppet-tools':
ensure => $ensure,
baseurl => $yumrepo_base_url,
descr => "Puppet Tools Repository el ${facts['os']['release']['major']} - \$basearch",
enabled => '1',
gpgcheck => '1',
gpgkey => "${base_url}${gpgkey}",
before => Package['puppet-bolt'],
if $facts['os']['family'] == 'RedHat' {
yumrepo { 'puppet-tools':
ensure => $ensure,
baseurl => $yumrepo_base_url,
descr => "Puppet Tools Repository el ${facts['os']['release']['major']} - \$basearch",
enabled => '1',
gpgcheck => '1',
gpgkey => "${base_url}${gpgkey}",
before => Package['puppet-bolt'],
}
} else {
apt::source { 'puppet-tools-release':
location => $base_url,
repos => 'puppet-tools',
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
{
"name": "saz/sudo",
"version_requirement": ">= 8.0.0 < 9.0.0"
},
{
"name": "puppetlabs/apt",
"version_requirement": ">= 9.4.0 < 10.0.0"
}
],
"operatingsystem_support": [
Expand Down Expand Up @@ -59,6 +63,20 @@
"8",
"9"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"12"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"20.04",
"22.04",
"24.04"
]
}
],
"requirements": [
Expand Down
15 changes: 11 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
require 'spec_helper'

describe 'bolt' do
on_supported_os.each do |os, facts|
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let :facts do
facts
os_facts
end

context 'with all defaults' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('puppet-bolt') }
it { is_expected.to contain_package('puppet-tools-release') }
it { is_expected.not_to contain_yumrepo('puppet-tools') }
it { is_expected.not_to contain_apt__source('puppet-tools-release') }
end

context 'with use_release_package=false' do
Expand All @@ -22,10 +23,15 @@
end

it { is_expected.not_to contain_package('puppet-tools-release') }
it { is_expected.to contain_yumrepo('puppet-tools') }

if os_facts['os']['family'] == 'RedHat'
it { is_expected.to contain_yumrepo('puppet-tools') }
else
it { is_expected.to contain_apt__source('puppet-tools-release') }
end
end

context 'with use_release_package=false and odd mirrors' do
context 'with use_release_package=false and odd mirrors', if: os_facts['os']['family'] == 'RedHat' do
let :params do
{
use_release_package: false,
Expand All @@ -45,6 +51,7 @@

it { is_expected.not_to contain_package('puppet-tools-release') }
it { is_expected.not_to contain_yumrepo('puppet-tools') }
it { is_expected.not_to contain_apt__source('puppet-tools-release') }
end
end
end
Expand Down

0 comments on commit ee135d6

Please sign in to comment.