From baf586c73f6e2650ee11dc9cf52692efc2c5a5d5 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 14:50:00 +0100 Subject: [PATCH 01/14] unwrap one level of indirection in apt package classes --- manifests/repo/apt.pp | 26 +++++++++++++++- manifests/repo/apt/erlang_solutions.pp | 30 ------------------ .../classes/repo/apt/erlang_solutions_spec.rb | 31 ------------------- spec/classes/repo/apt_spec.rb | 13 +++++++- 4 files changed, 37 insertions(+), 63 deletions(-) delete mode 100644 manifests/repo/apt/erlang_solutions.pp delete mode 100644 spec/classes/repo/apt/erlang_solutions_spec.rb diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index f7d8271..e77a03f 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -2,10 +2,34 @@ class erlang::repo::apt ( String $ensure = $erlang::repo_ensure, Erlang::RepoSource $source = $erlang::repo_source, + String $location = 'https://packages.erlang-solutions.com/debian', + # trusty, xenial, bionic, etc + String $release = downcase($facts['os']['distro']['codename']), + String $repos = 'contrib', + String $key = '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', + String $key_source = 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc', + Optional[Variant[Numeric, String]] $pin = $erlang::package_apt_pin, ) inherits erlang { case $source { 'erlang_solutions': { - contain erlang::repo::apt::erlang_solutions + apt::source { 'erlang-erlang_solutions': + ensure => $ensure, + location => $location, + release => $release, + repos => $repos, + key => { + 'id' => $key, + 'source' => $key_source, + }, + } + + if $pin { + apt::pin { 'erlang': + packages => '*', + priority => $pin, + origin => inline_template('<%= require \'uri\'; URI(@location).host %>'), + } + } } default: { fail("Only 'erlang_solutions' repo_sources is supported for Apt repos, the following is not supported: ${source}") diff --git a/manifests/repo/apt/erlang_solutions.pp b/manifests/repo/apt/erlang_solutions.pp deleted file mode 100644 index ea3adbb..0000000 --- a/manifests/repo/apt/erlang_solutions.pp +++ /dev/null @@ -1,30 +0,0 @@ -# erlang erlang_solutions apt repo -class erlang::repo::apt::erlang_solutions ( - String $ensure = $erlang::repo::apt::ensure, - String $location = 'https://packages.erlang-solutions.com/debian', - # trusty, xenial, bionic, etc - String $release = downcase($facts['os']['distro']['codename']), - String $repos = 'contrib', - String $key = '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', - String $key_source = 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc', - Optional[Variant[Numeric, String]] $pin = $erlang::package_apt_pin, -) inherits erlang { - apt::source { 'erlang-erlang_solutions': - ensure => $ensure, - location => $location, - release => $release, - repos => $repos, - key => { - 'id' => $key, - 'source' => $key_source, - }, - } - - if $pin { - apt::pin { 'erlang': - packages => '*', - priority => $pin, - origin => inline_template('<%= require \'uri\'; URI(@location).host %>'), - } - } -} diff --git a/spec/classes/repo/apt/erlang_solutions_spec.rb b/spec/classes/repo/apt/erlang_solutions_spec.rb deleted file mode 100644 index cbadf62..0000000 --- a/spec/classes/repo/apt/erlang_solutions_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'erlang::repo::apt::erlang_solutions' do # rubocop:disable RSpec/EmptyExampleGroup - on_supported_os.each do |os, facts| - case facts[:os]['family'] - when 'Debian' - context "on #{os}" do - let(:facts) { facts } - let(:release) { facts[:os]['distro']['codename'] } - - it { is_expected.to compile.with_all_deps } - - context 'with default parameters' do - it do - is_expected.to contain_apt__source('erlang-erlang_solutions'). - with('ensure' => 'present', - 'location' => 'https://packages.erlang-solutions.com/debian', - 'release' => release, - 'repos' => 'contrib', - 'key' => { - 'id' => '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', - 'source' => 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc' - }) - end - end - end - end - end -end diff --git a/spec/classes/repo/apt_spec.rb b/spec/classes/repo/apt_spec.rb index d25d232..d8ab5c3 100644 --- a/spec/classes/repo/apt_spec.rb +++ b/spec/classes/repo/apt_spec.rb @@ -13,8 +13,19 @@ context 'with source set to erlang_solutions' do let(:params) { { source: 'erlang_solutions' } } + let(:release) { facts[:os]['distro']['codename'] } - it { is_expected.to contain_class('erlang::repo::apt::erlang_solutions') } + it do + is_expected.to contain_apt__source('erlang-erlang_solutions'). + with('ensure' => 'present', + 'location' => 'https://packages.erlang-solutions.com/debian', + 'release' => release, + 'repos' => 'contrib', + 'key' => { + 'id' => '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', + 'source' => 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc' + }) + end end context 'with source set to invalid' do From 71617fd15ced33b300bfc67e22f5a65a4ae55d08 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 15:45:55 +0100 Subject: [PATCH 02/14] remove one layer of indirection from yum repo handling --- manifests/repo/yum.pp | 33 ++++++++++++-- manifests/repo/yum/epel.pp | 7 --- manifests/repo/yum/erlang_solutions.pp | 15 ------- manifests/repo/yum/packagecloud.pp | 16 ------- spec/classes/repo/yum/epel_spec.rb | 17 ------- .../classes/repo/yum/erlang_solutions_spec.rb | 28 ------------ spec/classes/repo/yum/packagecloud_spec.rb | 29 ------------ spec/classes/repo/yum_spec.rb | 44 ++++++++++++++++--- 8 files changed, 68 insertions(+), 121 deletions(-) delete mode 100644 manifests/repo/yum/epel.pp delete mode 100644 manifests/repo/yum/erlang_solutions.pp delete mode 100644 manifests/repo/yum/packagecloud.pp delete mode 100644 spec/classes/repo/yum/epel_spec.rb delete mode 100644 spec/classes/repo/yum/erlang_solutions_spec.rb delete mode 100644 spec/classes/repo/yum/packagecloud_spec.rb diff --git a/manifests/repo/yum.pp b/manifests/repo/yum.pp index ae6f9e5..4964a79 100644 --- a/manifests/repo/yum.pp +++ b/manifests/repo/yum.pp @@ -2,18 +2,43 @@ class erlang::repo::yum ( String $ensure = $erlang::repo_ensure, Erlang::RepoSource $source = $erlang::repo_source, + String $erlang_solutions_baseurl = "https://packages.erlang-solutions.com/rpm/centos/\$releasever/\$basearch", + String $erlang_solutions_gpgkey = 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc', + String $packagecloud_baseurl = "https://packagecloud.io/rabbitmq/erlang/el/${$facts['os']['release']['major']}/\$basearch", + String $packagecloud_gpgkey = 'https://packagecloud.io/rabbitmq/erlang/gpgkey' ) inherits erlang { case $source { 'epel': { - contain erlang::repo::yum::epel + # include epel instead of contain because lots of other stuff declares epel + include epel + # specifically declare dependency on epel repo + Class['epel'] -> Package[$erlang::package_name] } 'erlang_solutions': { # erlang_solutions package requires things from EPEL - contain erlang::repo::yum::epel - contain erlang::repo::yum::erlang_solutions + # include epel instead of contain because lots of other stuff declares epel + include epel + # specifically declare dependency on epel repo + Class['epel'] -> Package[$erlang::package_name] + yumrepo { 'erlang-erlang_solutions': + ensure => $ensure, + name => 'erlang-erlang_solutions', + baseurl => $erlang_solutions_baseurl, + enabled => '1', + gpgcheck => '1', + gpgkey => $erlang_solutions_gpgkey, + } } 'packagecloud': { - contain erlang::repo::yum::packagecloud + yumrepo { 'erlang-packagecloud': + ensure => $ensure, + name => 'erlang-packagecloud', + baseurl => $packagecloud_baseurl, + enabled => '1', + gpgcheck => '0', + repo_gpgcheck => '1', + gpgkey => $packagecloud_gpgkey, + } } default: { fail("Only 'packagecloud', 'epel' repo_source are supported for Yum repos, the following is not supported: ${source}") diff --git a/manifests/repo/yum/epel.pp b/manifests/repo/yum/epel.pp deleted file mode 100644 index ed10961..0000000 --- a/manifests/repo/yum/epel.pp +++ /dev/null @@ -1,7 +0,0 @@ -# Erlang packagecloud yum repo -class erlang::repo::yum::epel inherits erlang { - # include epel instead of contain because lots of other stuff declares epel - include epel - # specifically declare dependency on epel repo - Class['epel'] -> Package[$erlang::package_name] -} diff --git a/manifests/repo/yum/erlang_solutions.pp b/manifests/repo/yum/erlang_solutions.pp deleted file mode 100644 index c2c811f..0000000 --- a/manifests/repo/yum/erlang_solutions.pp +++ /dev/null @@ -1,15 +0,0 @@ -# Erlang packagecloud yum repo -class erlang::repo::yum::erlang_solutions ( - String $ensure = $erlang::repo::yum::ensure, - String $baseurl = "https://packages.erlang-solutions.com/rpm/centos/\$releasever/\$basearch", - String $gpgkey = 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc', -) inherits erlang { - yumrepo { 'erlang-erlang_solutions': - ensure => $ensure, - name => 'erlang-erlang_solutions', - baseurl => $baseurl, - enabled => '1', - gpgcheck => '1', - gpgkey => $gpgkey, - } -} diff --git a/manifests/repo/yum/packagecloud.pp b/manifests/repo/yum/packagecloud.pp deleted file mode 100644 index 538dfd0..0000000 --- a/manifests/repo/yum/packagecloud.pp +++ /dev/null @@ -1,16 +0,0 @@ -# Erlang packagecloud yum repo -class erlang::repo::yum::packagecloud ( - String $ensure = $erlang::repo::yum::ensure, - String $baseurl = "https://packagecloud.io/rabbitmq/erlang/el/${$facts['os']['release']['major']}/\$basearch", - String $gpgkey = 'https://packagecloud.io/rabbitmq/erlang/gpgkey' -) inherits erlang { - yumrepo { 'erlang-packagecloud': - ensure => $ensure, - name => 'erlang-packagecloud', - baseurl => $baseurl, - enabled => '1', - gpgcheck => '0', - repo_gpgcheck => '1', - gpgkey => $gpgkey, - } -} diff --git a/spec/classes/repo/yum/epel_spec.rb b/spec/classes/repo/yum/epel_spec.rb deleted file mode 100644 index bffcb71..0000000 --- a/spec/classes/repo/yum/epel_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'erlang::repo::yum::epel' do - on_supported_os.each do |os, facts| - context "on #{os}" do - case facts[:os]['family'] - when 'RedHat' - let(:facts) { facts } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('epel').that_comes_before('Package[erlang]') } - end - end - end -end diff --git a/spec/classes/repo/yum/erlang_solutions_spec.rb b/spec/classes/repo/yum/erlang_solutions_spec.rb deleted file mode 100644 index 802b9b2..0000000 --- a/spec/classes/repo/yum/erlang_solutions_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'erlang::repo::yum::erlang_solutions' do - on_supported_os.each do |os, facts| - context "on #{os}" do - case facts[:os]['family'] - when 'RedHat' - let(:facts) { facts } - - it { is_expected.to compile.with_all_deps } - - context 'with default parameters' do - it do - is_expected.to contain_yumrepo('erlang-erlang_solutions'). - with('ensure' => 'present', - 'name' => 'erlang-erlang_solutions', - 'baseurl' => 'https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch', - 'enabled' => '1', - 'gpgcheck' => '1', - 'gpgkey' => 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc') - end - end - end - end - end -end diff --git a/spec/classes/repo/yum/packagecloud_spec.rb b/spec/classes/repo/yum/packagecloud_spec.rb deleted file mode 100644 index c32a90d..0000000 --- a/spec/classes/repo/yum/packagecloud_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'erlang::repo::yum::packagecloud' do - on_supported_os.each do |os, facts| - context "on #{os}" do - case facts[:os]['family'] - when 'RedHat' - let(:facts) { facts } - - it { is_expected.to compile.with_all_deps } - - context 'with default parameters' do - it do - is_expected.to contain_yumrepo('erlang-packagecloud'). - with('ensure' => 'present', - 'name' => 'erlang-packagecloud', - 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", - 'enabled' => '1', - 'gpgcheck' => '0', - 'repo_gpgcheck' => '1', - 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') - end - end - end - end - end -end diff --git a/spec/classes/repo/yum_spec.rb b/spec/classes/repo/yum_spec.rb index 75d7fee..de69741 100644 --- a/spec/classes/repo/yum_spec.rb +++ b/spec/classes/repo/yum_spec.rb @@ -12,26 +12,60 @@ it { is_expected.to compile.with_all_deps } context 'with default parameters' do - it { is_expected.to contain_class('erlang::repo::yum::packagecloud') } + it do + is_expected.to contain_yumrepo('erlang-packagecloud'). + with('ensure' => 'present', + 'name' => 'erlang-packagecloud', + 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", + 'enabled' => '1', + 'gpgcheck' => '0', + 'repo_gpgcheck' => '1', + 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') + end end context 'with source set to epel' do let(:params) { { source: 'epel' } } - it { is_expected.to contain_class('erlang::repo::yum::epel') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('epel').that_comes_before('Package[erlang]') } end context 'with source set to erlang_solutions' do let(:params) { { source: 'erlang_solutions' } } - it { is_expected.to contain_class('erlang::repo::yum::epel') } - it { is_expected.to contain_class('erlang::repo::yum::erlang_solutions') } + it { is_expected.to compile.with_all_deps } + + context 'with default parameters' do + it do + is_expected.to contain_yumrepo('erlang-erlang_solutions'). + with('ensure' => 'present', + 'name' => 'erlang-erlang_solutions', + 'baseurl' => 'https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch', + 'enabled' => '1', + 'gpgcheck' => '1', + 'gpgkey' => 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc') + end + end end context 'with source set to packagecloud' do let(:params) { { source: 'packagecloud' } } - it { is_expected.to contain_class('erlang::repo::yum::packagecloud') } + it { is_expected.to compile.with_all_deps } + + context 'with default parameters' do + it do + is_expected.to contain_yumrepo('erlang-packagecloud'). + with('ensure' => 'present', + 'name' => 'erlang-packagecloud', + 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", + 'enabled' => '1', + 'gpgcheck' => '0', + 'repo_gpgcheck' => '1', + 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') + end + end end context 'with source set to invalid' do From c97bdbf6bb4dc008708934266e92e920291a2d16 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 17:47:01 +0100 Subject: [PATCH 03/14] remove static parameter (its default) --- manifests/repo/apt.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index e77a03f..6ad8d41 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -25,7 +25,6 @@ if $pin { apt::pin { 'erlang': - packages => '*', priority => $pin, origin => inline_template('<%= require \'uri\'; URI(@location).host %>'), } From beffadeb32ba13c51c71827aa8021e1b155b3054 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 22:32:52 +0100 Subject: [PATCH 04/14] regenerate reference --- REFERENCE.md | 102 ++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 82 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index e1eefab..ca69ac3 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -9,11 +9,7 @@ * [`erlang`](#erlang): Manages the Erlang repository and package installation. * [`erlang::repo`](#erlang--repo): Class that manages the erlang repo * [`erlang::repo::apt`](#erlang--repo--apt): erlang apt repo -* [`erlang::repo::apt::erlang_solutions`](#erlang--repo--apt--erlang_solutions): erlang erlang_solutions apt repo * [`erlang::repo::yum`](#erlang--repo--yum): erlang yum repo -* [`erlang::repo::yum::epel`](#erlang--repo--yum--epel): Erlang packagecloud yum repo -* [`erlang::repo::yum::erlang_solutions`](#erlang--repo--yum--erlang_solutions): Erlang packagecloud yum repo -* [`erlang::repo::yum::packagecloud`](#erlang--repo--yum--packagecloud): Erlang packagecloud yum repo ### Data types @@ -149,6 +145,12 @@ The following parameters are available in the `erlang::repo::apt` class: * [`ensure`](#-erlang--repo--apt--ensure) * [`source`](#-erlang--repo--apt--source) +* [`location`](#-erlang--repo--apt--location) +* [`release`](#-erlang--repo--apt--release) +* [`repos`](#-erlang--repo--apt--repos) +* [`key`](#-erlang--repo--apt--key) +* [`key_source`](#-erlang--repo--apt--key_source) +* [`pin`](#-erlang--repo--apt--pin) ##### `ensure` @@ -166,31 +168,7 @@ Data type: `Erlang::RepoSource` Default value: `$erlang::repo_source` -### `erlang::repo::apt::erlang_solutions` - -erlang erlang_solutions apt repo - -#### Parameters - -The following parameters are available in the `erlang::repo::apt::erlang_solutions` class: - -* [`ensure`](#-erlang--repo--apt--erlang_solutions--ensure) -* [`location`](#-erlang--repo--apt--erlang_solutions--location) -* [`release`](#-erlang--repo--apt--erlang_solutions--release) -* [`repos`](#-erlang--repo--apt--erlang_solutions--repos) -* [`key`](#-erlang--repo--apt--erlang_solutions--key) -* [`key_source`](#-erlang--repo--apt--erlang_solutions--key_source) -* [`pin`](#-erlang--repo--apt--erlang_solutions--pin) - -##### `ensure` - -Data type: `String` - - - -Default value: `$erlang::repo::apt::ensure` - -##### `location` +##### `location` Data type: `String` @@ -198,7 +176,7 @@ Data type: `String` Default value: `'https://packages.erlang-solutions.com/debian'` -##### `release` +##### `release` Data type: `String` @@ -206,7 +184,7 @@ Data type: `String` Default value: `downcase($facts['os']['distro']['codename'])` -##### `repos` +##### `repos` Data type: `String` @@ -214,7 +192,7 @@ Data type: `String` Default value: `'contrib'` -##### `key` +##### `key` Data type: `String` @@ -222,7 +200,7 @@ Data type: `String` Default value: `'434975BD900CCBE4F7EE1B1ED208507CA14F4FCA'` -##### `key_source` +##### `key_source` Data type: `String` @@ -230,7 +208,7 @@ Data type: `String` Default value: `'https://packages.erlang-solutions.com/debian/erlang_solutions.asc'` -##### `pin` +##### `pin` Data type: `Optional[Variant[Numeric, String]]` @@ -248,6 +226,10 @@ The following parameters are available in the `erlang::repo::yum` class: * [`ensure`](#-erlang--repo--yum--ensure) * [`source`](#-erlang--repo--yum--source) +* [`erlang_solutions_baseurl`](#-erlang--repo--yum--erlang_solutions_baseurl) +* [`erlang_solutions_gpgkey`](#-erlang--repo--yum--erlang_solutions_gpgkey) +* [`packagecloud_baseurl`](#-erlang--repo--yum--packagecloud_baseurl) +* [`packagecloud_gpgkey`](#-erlang--repo--yum--packagecloud_gpgkey) ##### `ensure` @@ -265,31 +247,7 @@ Data type: `Erlang::RepoSource` Default value: `$erlang::repo_source` -### `erlang::repo::yum::epel` - -Erlang packagecloud yum repo - -### `erlang::repo::yum::erlang_solutions` - -Erlang packagecloud yum repo - -#### Parameters - -The following parameters are available in the `erlang::repo::yum::erlang_solutions` class: - -* [`ensure`](#-erlang--repo--yum--erlang_solutions--ensure) -* [`baseurl`](#-erlang--repo--yum--erlang_solutions--baseurl) -* [`gpgkey`](#-erlang--repo--yum--erlang_solutions--gpgkey) - -##### `ensure` - -Data type: `String` - - - -Default value: `$erlang::repo::yum::ensure` - -##### `baseurl` +##### `erlang_solutions_baseurl` Data type: `String` @@ -297,7 +255,7 @@ Data type: `String` Default value: `"https://packages.erlang-solutions.com/rpm/centos/\$releasever/\$basearch"` -##### `gpgkey` +##### `erlang_solutions_gpgkey` Data type: `String` @@ -305,27 +263,7 @@ Data type: `String` Default value: `'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc'` -### `erlang::repo::yum::packagecloud` - -Erlang packagecloud yum repo - -#### Parameters - -The following parameters are available in the `erlang::repo::yum::packagecloud` class: - -* [`ensure`](#-erlang--repo--yum--packagecloud--ensure) -* [`baseurl`](#-erlang--repo--yum--packagecloud--baseurl) -* [`gpgkey`](#-erlang--repo--yum--packagecloud--gpgkey) - -##### `ensure` - -Data type: `String` - - - -Default value: `$erlang::repo::yum::ensure` - -##### `baseurl` +##### `packagecloud_baseurl` Data type: `String` @@ -333,7 +271,7 @@ Data type: `String` Default value: `"https://packagecloud.io/rabbitmq/erlang/el/${$facts['os']['release']['major']}/\$basearch"` -##### `gpgkey` +##### `packagecloud_gpgkey` Data type: `String` From cd252eea57badfc7f590b96be872b31f467c9f9e Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 22:36:53 +0100 Subject: [PATCH 05/14] fix rubocop --- spec/classes/repo/apt_spec.rb | 14 +++++++------- spec/classes/repo/yum_spec.rb | 34 +++++++++++++++++----------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/classes/repo/apt_spec.rb b/spec/classes/repo/apt_spec.rb index d8ab5c3..1b49ff8 100644 --- a/spec/classes/repo/apt_spec.rb +++ b/spec/classes/repo/apt_spec.rb @@ -18,13 +18,13 @@ it do is_expected.to contain_apt__source('erlang-erlang_solutions'). with('ensure' => 'present', - 'location' => 'https://packages.erlang-solutions.com/debian', - 'release' => release, - 'repos' => 'contrib', - 'key' => { - 'id' => '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', - 'source' => 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc' - }) + 'location' => 'https://packages.erlang-solutions.com/debian', + 'release' => release, + 'repos' => 'contrib', + 'key' => { + 'id' => '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', + 'source' => 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc' + }) end end diff --git a/spec/classes/repo/yum_spec.rb b/spec/classes/repo/yum_spec.rb index de69741..860ebc9 100644 --- a/spec/classes/repo/yum_spec.rb +++ b/spec/classes/repo/yum_spec.rb @@ -15,12 +15,12 @@ it do is_expected.to contain_yumrepo('erlang-packagecloud'). with('ensure' => 'present', - 'name' => 'erlang-packagecloud', - 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", - 'enabled' => '1', - 'gpgcheck' => '0', - 'repo_gpgcheck' => '1', - 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') + 'name' => 'erlang-packagecloud', + 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", + 'enabled' => '1', + 'gpgcheck' => '0', + 'repo_gpgcheck' => '1', + 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') end end @@ -40,11 +40,11 @@ it do is_expected.to contain_yumrepo('erlang-erlang_solutions'). with('ensure' => 'present', - 'name' => 'erlang-erlang_solutions', - 'baseurl' => 'https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch', - 'enabled' => '1', - 'gpgcheck' => '1', - 'gpgkey' => 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc') + 'name' => 'erlang-erlang_solutions', + 'baseurl' => 'https://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch', + 'enabled' => '1', + 'gpgcheck' => '1', + 'gpgkey' => 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc') end end end @@ -58,12 +58,12 @@ it do is_expected.to contain_yumrepo('erlang-packagecloud'). with('ensure' => 'present', - 'name' => 'erlang-packagecloud', - 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", - 'enabled' => '1', - 'gpgcheck' => '0', - 'repo_gpgcheck' => '1', - 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') + 'name' => 'erlang-packagecloud', + 'baseurl' => "https://packagecloud.io/rabbitmq/erlang/el/#{facts[:os]['release']['major']}/$basearch", + 'enabled' => '1', + 'gpgcheck' => '0', + 'repo_gpgcheck' => '1', + 'gpgkey' => 'https://packagecloud.io/rabbitmq/erlang/gpgkey') end end end From 92f7d3627467c6faf0d174c8751bf45cbb4e263c Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 22:55:50 +0100 Subject: [PATCH 06/14] test if debian already has package list and key --- manifests/repo.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/repo.pp b/manifests/repo.pp index b2ed956..ab6f388 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -2,7 +2,7 @@ class erlang::repo { case $facts['os']['family'] { 'Debian': { - contain erlang::repo::apt +# contain erlang::repo::apt } 'RedHat': { contain erlang::repo::yum From 20a28c1088a9c2b8369e5c3c946e3af5ff99715e Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 23:04:01 +0100 Subject: [PATCH 07/14] remove debian apt source expectation --- manifests/repo.pp | 3 --- manifests/repo/apt.pp | 37 ------------------------------------- spec/classes/repo_spec.rb | 2 -- 3 files changed, 42 deletions(-) delete mode 100644 manifests/repo/apt.pp diff --git a/manifests/repo.pp b/manifests/repo.pp index ab6f388..de2bc42 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -1,9 +1,6 @@ # Class that manages the erlang repo class erlang::repo { case $facts['os']['family'] { - 'Debian': { -# contain erlang::repo::apt - } 'RedHat': { contain erlang::repo::yum } diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp deleted file mode 100644 index 6ad8d41..0000000 --- a/manifests/repo/apt.pp +++ /dev/null @@ -1,37 +0,0 @@ -# erlang apt repo -class erlang::repo::apt ( - String $ensure = $erlang::repo_ensure, - Erlang::RepoSource $source = $erlang::repo_source, - String $location = 'https://packages.erlang-solutions.com/debian', - # trusty, xenial, bionic, etc - String $release = downcase($facts['os']['distro']['codename']), - String $repos = 'contrib', - String $key = '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', - String $key_source = 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc', - Optional[Variant[Numeric, String]] $pin = $erlang::package_apt_pin, -) inherits erlang { - case $source { - 'erlang_solutions': { - apt::source { 'erlang-erlang_solutions': - ensure => $ensure, - location => $location, - release => $release, - repos => $repos, - key => { - 'id' => $key, - 'source' => $key_source, - }, - } - - if $pin { - apt::pin { 'erlang': - priority => $pin, - origin => inline_template('<%= require \'uri\'; URI(@location).host %>'), - } - } - } - default: { - fail("Only 'erlang_solutions' repo_sources is supported for Apt repos, the following is not supported: ${source}") - } - } -} diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index a4f0c89..cde0718 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -10,8 +10,6 @@ it { is_expected.to compile.with_all_deps } case facts[:os]['family'] - when 'Debian' - it { is_expected.to contain_class('erlang::repo::apt') } when 'RedHat' it { is_expected.to contain_class('erlang::repo::yum') } end From 67801caa7cecd63f75460e23c7425a282e363259 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 23:18:44 +0100 Subject: [PATCH 08/14] regenerate reference --- REFERENCE.md | 82 ---------------------------------------------------- 1 file changed, 82 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index ca69ac3..dc12a77 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -8,7 +8,6 @@ * [`erlang`](#erlang): Manages the Erlang repository and package installation. * [`erlang::repo`](#erlang--repo): Class that manages the erlang repo -* [`erlang::repo::apt`](#erlang--repo--apt): erlang apt repo * [`erlang::repo::yum`](#erlang--repo--yum): erlang yum repo ### Data types @@ -135,87 +134,6 @@ Default value: `'packagecloud'` Class that manages the erlang repo -### `erlang::repo::apt` - -erlang apt repo - -#### Parameters - -The following parameters are available in the `erlang::repo::apt` class: - -* [`ensure`](#-erlang--repo--apt--ensure) -* [`source`](#-erlang--repo--apt--source) -* [`location`](#-erlang--repo--apt--location) -* [`release`](#-erlang--repo--apt--release) -* [`repos`](#-erlang--repo--apt--repos) -* [`key`](#-erlang--repo--apt--key) -* [`key_source`](#-erlang--repo--apt--key_source) -* [`pin`](#-erlang--repo--apt--pin) - -##### `ensure` - -Data type: `String` - - - -Default value: `$erlang::repo_ensure` - -##### `source` - -Data type: `Erlang::RepoSource` - - - -Default value: `$erlang::repo_source` - -##### `location` - -Data type: `String` - - - -Default value: `'https://packages.erlang-solutions.com/debian'` - -##### `release` - -Data type: `String` - - - -Default value: `downcase($facts['os']['distro']['codename'])` - -##### `repos` - -Data type: `String` - - - -Default value: `'contrib'` - -##### `key` - -Data type: `String` - - - -Default value: `'434975BD900CCBE4F7EE1B1ED208507CA14F4FCA'` - -##### `key_source` - -Data type: `String` - - - -Default value: `'https://packages.erlang-solutions.com/debian/erlang_solutions.asc'` - -##### `pin` - -Data type: `Optional[Variant[Numeric, String]]` - - - -Default value: `$erlang::package_apt_pin` - ### `erlang::repo::yum` erlang yum repo From 62eb99182320ee81f8ba6cc288899d55d12b55cd Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 23:24:27 +0100 Subject: [PATCH 09/14] yank apt class spec --- manifests/repo.pp | 1 + spec/classes/repo/apt_spec.rb | 39 ----------------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 spec/classes/repo/apt_spec.rb diff --git a/manifests/repo.pp b/manifests/repo.pp index de2bc42..71c36fc 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -4,6 +4,7 @@ 'RedHat': { contain erlang::repo::yum } + 'Debian': {} default: { fail("The only supported OS families are 'Debian' and 'RedHat', currently trying to install on OS family: ${$facts['os']['family']}") } diff --git a/spec/classes/repo/apt_spec.rb b/spec/classes/repo/apt_spec.rb deleted file mode 100644 index 1b49ff8..0000000 --- a/spec/classes/repo/apt_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'erlang::repo::apt' do # rubocop:disable RSpec/EmptyExampleGroup - on_supported_os.each do |os, facts| - case facts[:os]['family'] - when 'Debian' - context "on #{os}" do - let(:facts) { facts } - - it { is_expected.to compile.with_all_deps } - - context 'with source set to erlang_solutions' do - let(:params) { { source: 'erlang_solutions' } } - let(:release) { facts[:os]['distro']['codename'] } - - it do - is_expected.to contain_apt__source('erlang-erlang_solutions'). - with('ensure' => 'present', - 'location' => 'https://packages.erlang-solutions.com/debian', - 'release' => release, - 'repos' => 'contrib', - 'key' => { - 'id' => '434975BD900CCBE4F7EE1B1ED208507CA14F4FCA', - 'source' => 'https://packages.erlang-solutions.com/debian/erlang_solutions.asc' - }) - end - end - - context 'with source set to invalid' do - let(:params) { { source: 'invalid' } } - - it { is_expected.to compile.and_raise_error(%r{parameter 'source' expects a match for}) } - end - end - end - end -end From 87bbc59baf1e0b4c9f3506097f6795de39a95b4a Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 6 Feb 2024 17:33:44 +0100 Subject: [PATCH 10/14] add ubuntu 22.04 support --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 72d592b..3f1e915 100644 --- a/metadata.json +++ b/metadata.json @@ -35,7 +35,8 @@ "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "18.04", - "20.04" + "20.04", + "22.04" ] } ], From 76fb815900f9fe69a3d8c310e1594514253411c3 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 10:45:43 +0100 Subject: [PATCH 11/14] drop ubuntu 18.04 --- metadata.json | 1 - 1 file changed, 1 deletion(-) diff --git a/metadata.json b/metadata.json index 3f1e915..0c3d447 100644 --- a/metadata.json +++ b/metadata.json @@ -34,7 +34,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "18.04", "20.04", "22.04" ] From 2a88a21a3524faea3cbf65f3b489fa46e71c9886 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sat, 15 Mar 2025 23:42:21 +0100 Subject: [PATCH 12/14] add debian 12 support --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 0c3d447..dd619bc 100644 --- a/metadata.json +++ b/metadata.json @@ -28,7 +28,8 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "11" + "11", + "12" ] }, { From a5c33bac06f0fda3e7035907916f6bf06bc2f8c7 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sun, 16 Mar 2025 10:45:26 +0100 Subject: [PATCH 13/14] harden types --- manifests/init.pp | 6 +++--- manifests/repo/yum.pp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index fa74e6b..ba4db10 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -59,10 +59,10 @@ # class erlang ( String $package_name = 'erlang', - String $package_ensure = 'installed', + Stdlib::Ensure::Package $package_ensure = 'installed', Optional[Variant[Numeric, String]] $package_apt_pin = undef, - Boolean $manage_repo = true, - String $repo_ensure = 'present', + Boolean $manage_repo = true, + Enum['present','absent'] $repo_ensure = 'present', Erlang::RepoSource $repo_source = 'packagecloud', ) { if $manage_repo { diff --git a/manifests/repo/yum.pp b/manifests/repo/yum.pp index 4964a79..532b267 100644 --- a/manifests/repo/yum.pp +++ b/manifests/repo/yum.pp @@ -1,11 +1,11 @@ # erlang yum repo class erlang::repo::yum ( - String $ensure = $erlang::repo_ensure, + Enum['absent','present'] $ensure = $erlang::repo_ensure, Erlang::RepoSource $source = $erlang::repo_source, - String $erlang_solutions_baseurl = "https://packages.erlang-solutions.com/rpm/centos/\$releasever/\$basearch", - String $erlang_solutions_gpgkey = 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc', - String $packagecloud_baseurl = "https://packagecloud.io/rabbitmq/erlang/el/${$facts['os']['release']['major']}/\$basearch", - String $packagecloud_gpgkey = 'https://packagecloud.io/rabbitmq/erlang/gpgkey' + Variant[Stdlib::HTTPSUrl,Enum['absent']] $erlang_solutions_baseurl = "https://packages.erlang-solutions.com/rpm/centos/\$releasever/\$basearch", + Variant[Stdlib::HTTPSUrl,Enum['absent']] $erlang_solutions_gpgkey = 'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc', + Variant[Stdlib::HTTPSUrl,Enum['absent']] $packagecloud_baseurl = "https://packagecloud.io/rabbitmq/erlang/el/${$facts['os']['release']['major']}/\$basearch", + Variant[Stdlib::HTTPSUrl,Enum['absent']] $packagecloud_gpgkey = 'https://packagecloud.io/rabbitmq/erlang/gpgkey' ) inherits erlang { case $source { 'epel': { From 91b717b758acef06b70c3f8b1045d35c4eb8c0d6 Mon Sep 17 00:00:00 2001 From: zilchms Date: Sun, 16 Mar 2025 10:48:15 +0100 Subject: [PATCH 14/14] regenerate reference --- REFERENCE.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index dc12a77..76d226f 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -85,7 +85,7 @@ Default value: `'erlang'` ##### `package_ensure` -Data type: `String` +Data type: `Stdlib::Ensure::Package` Determines the ensure state of the package. Set to installed by default, but could be changed to latest. @@ -109,7 +109,7 @@ Default value: `true` ##### `repo_ensure` -Data type: `String` +Data type: `Enum['present','absent']` Determines the ensure state of the repo. @@ -151,7 +151,7 @@ The following parameters are available in the `erlang::repo::yum` class: ##### `ensure` -Data type: `String` +Data type: `Enum['absent','present']` @@ -167,7 +167,7 @@ Default value: `$erlang::repo_source` ##### `erlang_solutions_baseurl` -Data type: `String` +Data type: `Variant[Stdlib::HTTPSUrl,Enum['absent']]` @@ -175,7 +175,7 @@ Default value: `"https://packages.erlang-solutions.com/rpm/centos/\$releasever/\ ##### `erlang_solutions_gpgkey` -Data type: `String` +Data type: `Variant[Stdlib::HTTPSUrl,Enum['absent']]` @@ -183,7 +183,7 @@ Default value: `'https://packages.erlang-solutions.com/rpm/erlang_solutions.asc' ##### `packagecloud_baseurl` -Data type: `String` +Data type: `Variant[Stdlib::HTTPSUrl,Enum['absent']]` @@ -191,7 +191,7 @@ Default value: `"https://packagecloud.io/rabbitmq/erlang/el/${$facts['os']['rele ##### `packagecloud_gpgkey` -Data type: `String` +Data type: `Variant[Stdlib::HTTPSUrl,Enum['absent']]`