Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always include the installer answer file in backups #912

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions definitions/features/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Features::Installer < ForemanMaintain::Feature
end

def answers
load_answers(configuration)
YAML.load_file(answer_file)
end

def configuration
Expand All @@ -28,11 +28,13 @@ def custom_hiera_file
end

def config_files
Dir.glob(File.join(config_directory, '**/*')) +
[
'/opt/puppetlabs/puppet/cache/foreman_cache_data',
'/opt/puppetlabs/puppet/cache/pulpcore_cache_data',
]
paths = [
config_directory,
'/opt/puppetlabs/puppet/cache/foreman_cache_data',
'/opt/puppetlabs/puppet/cache/pulpcore_cache_data',
]
paths << answer_file unless answer_file.start_with?("#{config_directory}/")
paths
end

def last_scenario
Expand Down Expand Up @@ -80,8 +82,8 @@ def lock_package_versions_supported?

private

def load_answers(config)
YAML.load_file(config[:answer_file])
def answer_file
configuration[:answer_file]
end

def last_scenario_config
Expand Down
8 changes: 3 additions & 5 deletions test/definitions/features/installer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@

context 'installer with scenarios' do
before do
installer_config_dir(["#{data_dir}/installer/simple_config"])
installer_config_dir("#{data_dir}/installer/simple_config")
mock_installer_package('foreman-installer')
end

it 'loads list of configs on the start' do
expected_config_files = [
"#{data_dir}/installer/simple_config/scenarios.d",
"#{data_dir}/installer/simple_config/scenarios.d/foreman-answers.yaml",
"#{data_dir}/installer/simple_config/scenarios.d/foreman.yaml",
"#{data_dir}/installer/simple_config/scenarios.d/last_scenario.yaml",
"#{data_dir}/installer/simple_config",
'/opt/puppetlabs/puppet/cache/foreman_cache_data',
'/opt/puppetlabs/puppet/cache/pulpcore_cache_data',
'test/data/installer/simple_config/scenarios.d/foreman-answers.yaml',
].sort
_(subject.config_files.sort).must_equal(expected_config_files)
end
Expand Down
Loading