Skip to content

Commit

Permalink
Refs #32276: Add Katello hammer plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Apr 9, 2021
1 parent 2a9f9ed commit 4af6b19
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 32 deletions.
10 changes: 10 additions & 0 deletions manifests/cli/katello.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# = Hammer Katello plugin
#
# This installs the Katello plugin for Hammer CLI
#
# === Parameters:
#
class foreman::cli::katello {
foreman::cli::plugin { 'katello':
}
}
96 changes: 66 additions & 30 deletions spec/acceptance/foreman_cli_plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,77 @@
describe 'Scenario: install foreman-cli + plugins without foreman' do
before(:context) { purge_foreman }

let(:pp) do
<<-PUPPET
class { 'foreman::cli':
foreman_url => 'https://foreman.example.com',
username => 'admin',
password => 'changeme',
}
if $facts['os']['family'] == 'RedHat' {
include foreman::cli::ansible
include foreman::cli::azure
}
include foreman::cli::discovery
include foreman::cli::remote_execution
include foreman::cli::tasks
include foreman::cli::templates
PUPPET
package_prefix = fact('os.release.major') == '7' ? "tfm-" : ""

context 'for standard plugins' do
let(:pp) do
<<-PUPPET
class { 'foreman::cli':
foreman_url => 'https://foreman.example.com',
username => 'admin',
password => 'changeme',
}
if $facts['os']['family'] == 'RedHat' {
include foreman::cli::ansible
include foreman::cli::azure
}
include foreman::cli::discovery
include foreman::cli::remote_execution
include foreman::cli::tasks
include foreman::cli::templates
PUPPET
end

it_behaves_like 'a idempotent resource'

it_behaves_like 'hammer'

['discovery', 'remote_execution', 'tasks', 'templates'].each do |plugin|
package_name = case fact('os.family')
when 'RedHat'
"#{package_prefix}rubygem-hammer_cli_foreman_#{plugin}"
when 'Debian'
"ruby-hammer-cli-foreman-#{plugin.tr('_', '-')}"
else
plugin
end

describe package(package_name) do
it { is_expected.to be_installed }
end
end
end

it_behaves_like 'a idempotent resource'
if fact('os.family') == 'RedHat'
context 'for katello' do
let(:pp) do
<<-PUPPET
yumrepo { 'katello':
baseurl => "http://yum.theforeman.org/katello/nightly/katello/el${facts['os']['release']['major']}/x86_64/",
gpgcheck => 0,
}
class { 'foreman::cli':
foreman_url => 'https://foreman.example.com',
username => 'admin',
password => 'changeme',
}
include foreman::cli::katello
Yumrepo['katello'] -> Class['foreman::cli::katello']
PUPPET
end

it_behaves_like 'hammer'
it_behaves_like 'a idempotent resource'

['discovery', 'remote_execution', 'tasks', 'templates'].each do |plugin|
package_name = case fact('os.family')
when 'RedHat'
fact('os.release.major') == '7' ? "tfm-rubygem-hammer_cli_foreman_#{plugin}" : "rubygem-hammer_cli_foreman_#{plugin}"
when 'Debian'
"ruby-hammer-cli-foreman-#{plugin.tr('_', '-')}"
else
plugin
end
it_behaves_like 'hammer'

describe package(package_name) do
it { is_expected.to be_installed }
package_name = "#{package_prefix}rubygem-hammer_cli_katello"
describe package(package_name) do
it { is_expected.to be_installed }
end
end
end
end
13 changes: 11 additions & 2 deletions spec/classes/cli_plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

supported = on_supported_os

['ansible', 'azure', 'discovery', 'kubevirt', 'openscap', 'remote_execution', 'tasks', 'templates', 'virt_who_configure'].each do |plugin|
['ansible', 'azure', 'discovery', 'katello', 'kubevirt', 'openscap', 'remote_execution', 'tasks', 'templates', 'virt_who_configure'].each do |plugin|
describe "foreman::cli::#{plugin}" do
supported.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:pre_condition) { 'include foreman::cli' }
let(:plugin_name) { plugin == 'azure' ? 'foreman_azure_rm' : "foreman_#{plugin}" }
let(:plugin_name) do
case plugin
when 'azure'
'foreman_azure_rm'
when 'katello'
'katello'
else
"foreman_#{plugin}"
end
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_foreman__cli__plugin(plugin_name) }
Expand Down

0 comments on commit 4af6b19

Please sign in to comment.