Skip to content

Commit

Permalink
Add source removal
Browse files Browse the repository at this point in the history
  • Loading branch information
threepistons committed Mar 24, 2023
1 parent af51fa4 commit ad70494
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
25 changes: 25 additions & 0 deletions manifests/remove.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,29 @@
file { '/etc/LithnetAccessManagerAgent.conf' :
ensure => 'absent',
}

case $facts['os']['family'] {
'RedHat' : {
# Install the Lithnet RPM repo
# Note: Lithnet don't GPG sign their packages so gpgcheck is disabled
yumrepo { 'lithnet-am-repo':
ensure => 'absent',
baseurl => "https://packages.lithnet.io/linux/rpm/prod/repos/rhel/${facts['os']['release']['major']}",
}
}
'Debian' : {
include apt

$realosname = downcase($facts['os']['name'])

apt::source { 'Lithnet' :
ensure => 'absent',
location => "https://packages.lithnet.io/linux/deb/prod/repos/${realosname}",
}
}
# If we've ended up here, then this module doesn't currently support the OS
default : {
notify { 'Remove the Lithnet source yourself' : }
}
}
}
6 changes: 5 additions & 1 deletion spec/classes/lithnetamagent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
on_supported_os(redhat).each do |_os, os_facts|
let(:facts) { os_facts }

it { is_expected.to contain_yumrepo('lithnet-am-repo') }
it {
is_expected.to contain_yumrepo('lithnet-am-repo').with(
'baseurl' => %r{https://packages.lithnet.io/linux/rpm/prod/repos/rhel},
)
}
it {
is_expected.to contain_package('LithnetAccessManagerAgent').with(
'name' => 'LithnetAccessManagerAgent',
Expand Down
57 changes: 56 additions & 1 deletion spec/classes/remove_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
require 'spec_helper'

describe 'lithnetamagent::remove' do
ubuntu = {
supported_os: [
{
'operatingsystem' => 'Ubuntu',
'operatingsystemrelease' => ['18.04', '20.04', '22.04'],
},
],
}
redhat = {
supported_os: [
{
'operatingsystem' => 'RedHat',
'operatingsystemrelease' => ['7', '8', '9'],
},
{
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => ['7'],
},
],
}
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
Expand All @@ -14,8 +34,43 @@
'enable' => 'false',
)
}
it { is_expected.to contain_package('LithnetAccessManagerAgent').with('ensure' => 'absent') }
it { is_expected.to contain_file('/etc/LithnetAccessManagerAgent.conf').with('ensure' => 'absent') }
end
end
context 'Ubuntu-only tests' do
on_supported_os(ubuntu).each do |_os, os_facts|
let(:facts) { os_facts }

it {
is_expected.to contain_apt__source('Lithnet').with(
'ensure' => 'absent',
'location' => 'https://packages.lithnet.io/linux/deb/prod/repos/ubuntu',
)
}
it {
is_expected.to contain_package('LithnetAccessManagerAgent').with(
'name' => 'lithnetaccessmanageragent',
'ensure' => 'absent',
)
}
end # ubuntu each
end # Ubuntu context
context 'RedHat-only tests' do
on_supported_os(redhat).each do |_os, os_facts|
let(:facts) { os_facts }

it {
is_expected.to contain_yumrepo('lithnet-am-repo').with(
'ensure' => 'absent',
'baseurl' => %r{https://packages.lithnet.io/linux/rpm/prod/repos/rhel},
)
}
it {
is_expected.to contain_package('LithnetAccessManagerAgent').with(
'name' => 'LithnetAccessManagerAgent',
'ensure' => 'absent',
)
}
end # redhat each
end # RedHat context
end

0 comments on commit ad70494

Please sign in to comment.