diff --git a/manifests/cli/katello.pp b/manifests/cli/katello.pp new file mode 100644 index 000000000..af908da90 --- /dev/null +++ b/manifests/cli/katello.pp @@ -0,0 +1,10 @@ +# = Hammer Katello plugin +# +# This installs the Katello plugin for Hammer CLI +# +# === Parameters: +# +class foreman::cli::katello { + foreman::cli::plugin { 'katello': + } +} diff --git a/spec/acceptance/foreman_cli_plugins_spec.rb b/spec/acceptance/foreman_cli_plugins_spec.rb index 09b5ce040..e3d56feed 100644 --- a/spec/acceptance/foreman_cli_plugins_spec.rb +++ b/spec/acceptance/foreman_cli_plugins_spec.rb @@ -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', 'katello'].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 diff --git a/spec/classes/cli_plugins_spec.rb b/spec/classes/cli_plugins_spec.rb index f4c6373cf..7b06692eb 100644 --- a/spec/classes/cli_plugins_spec.rb +++ b/spec/classes/cli_plugins_spec.rb @@ -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) }