Skip to content

Commit

Permalink
Fixes #32885: Remove puppet from foreman::user_groups if present
Browse files Browse the repository at this point in the history
The change theforeman/puppet-foreman#938
introduced dynamically determining if the puppet group needed to
be added to the foreman user. This no longer needs to be set
explicitly on the foreman::user_groups parameter thus the migration
cleans it up if present.
  • Loading branch information
ehelms committed Jun 25, 2021
1 parent 3cbb7bd commit 405e925
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if answers['foreman'].is_a?(Hash)
if answers['foreman']['user_groups'] && answers['foreman']['user_groups'].include?('puppet')
answers['foreman']['user_groups'].delete('puppet')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if answers['foreman'].is_a?(Hash)
if answers['foreman']['user_groups'] && answers['foreman']['user_groups'].include?('puppet')
answers['foreman']['user_groups'].delete('puppet')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foreman:
user_groups: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foreman:
user_groups: ['puppet']
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foreman:
user_groups: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
foreman:
user_groups: ['puppet']
20 changes: 20 additions & 0 deletions spec/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,24 @@
end
end
end

%w[foreman katello].each do |scenario_name|
context "foreman drop puppet from user_groups" do
let(:answers_after) { load_fixture_yaml('cleanup-foreman-user-groups', "#{scenario_name}-answers-after.yaml") }
let(:scenario) do
{
:answers => load_fixture_yaml('cleanup-foreman-user-groups', "#{scenario_name}-answers-before.yaml"),
:config => load_config_yaml("#{scenario_name}.yaml"),
:migrations => config_path("#{scenario_name}.migrations"),
}
end

let(:migrator) { Kafo::Migrations.new(scenario[:migrations]).run(scenario[:config], scenario[:answers]) }

it 'changes scenario answers' do
_, after = migrator
expect(after).to include answers_after
end
end
end
end

0 comments on commit 405e925

Please sign in to comment.