diff --git a/.fixtures.yml b/.fixtures.yml
index d07a6c7..6e6f78e 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -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
diff --git a/REFERENCE.md b/REFERENCE.md
index f4ee9c6..681eea7 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -77,7 +77,7 @@ 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/'`
##### `release_package`
@@ -85,7 +85,7 @@ 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"`
##### `gpgkey`
@@ -93,7 +93,7 @@ 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'`
##### `use_release_package`
@@ -101,7 +101,7 @@ Data type: `Boolean`
enable/disable the puppet-tools-release package installation. When disabled, we will configure the repo as yumrepo resource
-Default value: `true`
+Default value: `$facts['os']['family'] ? { 'Debian' => false, 'RedHat' => true`
##### `yumrepo_base_url`
diff --git a/manifests/init.pp b/manifests/init.pp
index 1616c51..94a7876 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -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',
- Boolean $use_release_package = true,
+ 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 = $facts['os']['family'] ? { 'Debian' => false, 'RedHat' => 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 ? {
@@ -55,14 +55,22 @@
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',
+ before => Package['puppet-bolt'],
+ }
}
}
}
diff --git a/metadata.json b/metadata.json
index dd28119..4d7ca5d 100644
--- a/metadata.json
+++ b/metadata.json
@@ -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": [
@@ -59,6 +63,14 @@
"8",
"9"
]
+ },
+ {
+ "operatingsystem": "Ubuntu",
+ "operatingsystemrelease": [
+ "20.04",
+ "22.04",
+ "24.04"
+ ]
}
],
"requirements": [
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index da4ec71..6266c35 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -3,17 +3,23 @@
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') }
+ if os_facts['os']['family'] == 'RedHat'
+ it { is_expected.to contain_package('puppet-tools-release') }
+ it { is_expected.not_to contain_apt__source('puppet-tools-release') }
+ else
+ it { is_expected.not_to contain_package('puppet-tools-release') }
+ it { is_expected.to contain_apt__source('puppet-tools-release') }
+ end
end
context 'with use_release_package=false' do
@@ -22,10 +28,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,
@@ -45,6 +56,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
diff --git a/spec/defines/project_spec.rb b/spec/defines/project_spec.rb
index ac1f79a..2d7778c 100644
--- a/spec/defines/project_spec.rb
+++ b/spec/defines/project_spec.rb
@@ -29,10 +29,17 @@
it { is_expected.to contain_user(title) }
it { is_expected.to contain_group(title) }
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.to contain_sudo__conf(title) }
it { is_expected.to contain_systemd__unit_file("#{title}@.service") }
+
+ if os_facts['os']['family'] == 'RedHat'
+ it { is_expected.to contain_package('puppet-tools-release') }
+ it { is_expected.not_to contain_apt__source('puppet-tools-release') }
+ else
+ it { is_expected.not_to contain_package('puppet-tools-release') }
+ it { is_expected.to contain_apt__source('puppet-tools-release') }
+ end
end
end