Skip to content

Commit

Permalink
Fixes #33577 - Only enable Foreman Puppet plugin with Foreman
Browse files Browse the repository at this point in the history
If the user passed in --no-enable-foreman then the Foreman plugin should
not be enabled. The same is true for the CLI side of it.

The add-cli migration is changed to respect an already present option
that is false in order to properly test this change.
  • Loading branch information
ekohl committed Sep 29, 2021
1 parent e56d06d commit ce89a30
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This fixes up 20210803130619_add_hammer_puppet_plugin.rb in case foreman::cli
# is disabled
if answers['foreman::cli::puppet'] && !answers['foreman::cli']
answers['foreman::cli::puppet'] = false
end
# This fixes up 20210708144320_add_foreman_puppet.rb in case foreman is
# disabled
if answers['foreman::plugin::puppet'] && !answers['foreman']
answers['foreman::plugin::puppet'] = false
end
4 changes: 3 additions & 1 deletion config/katello.migrations/170331152302-add-cli.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
answers['foreman::cli'] ||= true
unless answers.key?('foreman::cli')
answers['foreman::cli'] = true
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This fixes up 20210803130619-add-hammer-puppet-plugin.rb in case foreman::cli
# is disabled
if answers['foreman::cli::puppet'] && !answers['foreman::cli']
answers['foreman::cli::puppet'] = false
end
# This fixes up 210708144422-add-foreman-puppet.rb in case foreman is
# disabled
if answers['foreman::plugin::puppet'] && !answers['foreman']
answers['foreman::plugin::puppet'] = false
end
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ foreman::plugin::kubevirt: false
foreman::plugin::leapp: false
foreman::plugin::memcache: false
foreman::plugin::monitoring: false
foreman::plugin::puppet: true
foreman::plugin::puppet: false
foreman::plugin::remote_execution: true
foreman::plugin::remote_execution::cockpit: false
foreman::plugin::rh_cloud: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ foreman::plugin::kubevirt: false
foreman::plugin::leapp: false
foreman::plugin::memcache: false
foreman::plugin::monitoring: false
foreman::plugin::puppet: true
foreman::plugin::puppet: false
foreman::plugin::remote_execution: true
foreman::plugin::remote_execution::cockpit: false
foreman::plugin::rh_cloud: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ foreman::plugin::kubevirt: false
foreman::plugin::leapp: false
foreman::plugin::memcache: false
foreman::plugin::monitoring: false
foreman::plugin::puppet: true
foreman::plugin::puppet: false
foreman::plugin::remote_execution: true
foreman::plugin::remote_execution::cockpit: false
foreman::plugin::rh_cloud: false
Expand Down
34 changes: 34 additions & 0 deletions spec/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,38 @@
end
end
end

context 'disable puppet if needed' do
%w[foreman katello].each do |scenario_name|
context "on #{scenario_name}" do
let(:answers) do
{
'foreman' => false,
'foreman::cli' => false,
}
end
let(:scenario_name) { scenario_name }
let(:config) { load_config_yaml("#{scenario_name}.yaml") }
let(:migrations) { config_path("#{scenario_name}.migrations") }
let(:migrator) { Kafo::Migrations.new(migrations).run(config, answers) }
subject(:migrated_answers) { migrator[1] }

it 'keeps foreman::cli disabled' do
expect(migrated_answers['foreman::cli']).to be false
end

it 'adds foreman::cli::puppet disabled' do
expect(migrated_answers['foreman::cli::puppet']).to be false
end

it 'keeps foreman disabled' do
expect(migrated_answers['foreman']).to be false
end

it 'adds foreman::plugin::puppet disabled' do
expect(migrated_answers['foreman::plugin::puppet']).to be false
end
end
end
end
end

0 comments on commit ce89a30

Please sign in to comment.