Skip to content

Commit

Permalink
(PE-14271) Adjust BeakerAnswers call for meep
Browse files Browse the repository at this point in the history
Based on changes pending in puppetlabs/beaker-answers#16, change the
generate_installer_conf_file_for() method to submit the expected :format
option temporarily.  This will go away when we cutover to meep and no
longer have to have both installer scripts operational in the same
build.

Fleshes out the specs that verify the method returns expected answer or
pe.conf data from BeakerAnswers, as written out via scp.
  • Loading branch information
jpartlow committed May 26, 2016
1 parent 616612a commit 6bc392f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,12 @@ def prepare_host_installer_options(host)
# @param [Hash] opts The Beaker options hash
# @return [BeakerAnswers::Answers] the generated answers object
def generate_installer_conf_file_for(host, hosts, opts)
answers = BeakerAnswers::Answers.create(opts[:pe_ver] || host['pe_ver'], hosts, opts)
configuration = answers.answer_string(host)
create_remote_file(host, host['pe_installer_conf_file'], configuration)
answers
format = host['pe_installer_type'] == 'meep' ? :hiera : :bash
beaker_opts = opts.merge(:format => format )
answers = BeakerAnswers::Answers.create(opts[:pe_ver] || host['pe_ver'], hosts, beaker_opts)
configuration = answers.installer_configuration_string(host)
create_remote_file(host, host['pe_installer_conf_file'], configuration)
answers
end

# Builds the agent_only and not_agent_only arrays needed for installation.
Expand Down
26 changes: 24 additions & 2 deletions spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,30 @@ def slice_installer_options(host)
end

describe 'generate_installer_conf_file_for' do
it 'generates a legacy answer file if host["pe_installer_type"]=="legacy"'
it 'generates a meep config file if host["pe_installer_type"]=="meep"'
let(:master) { hosts.first }

it 'generates a legacy answer file if host["pe_installer_type"]=="legacy"' do
master['pe_installer_conf_file'] = '/tmp/answers'
master['pe_installer_type'] = 'legacy'
expect(subject).to receive(:create_remote_file).with(
master,
'/tmp/answers',
%r{q_install=y.*q_puppetmaster_certname=#{master}}m
)
subject.generate_installer_conf_file_for(master, hosts, opts)
end

it 'generates a meep config file if host["pe_installer_type"]=="meep"' do
master['pe_installer_conf_file'] = '/tmp/pe.conf'
master['pe_installer_type'] = 'meep'
master['pe_ver'] = '2016.2.0'
expect(subject).to receive(:create_remote_file).with(
master,
'/tmp/pe.conf',
%r{\{.*"puppet_enterprise::puppet_master_host": "#{master}"}m
)
subject.generate_installer_conf_file_for(master, hosts, opts)
end
end

describe 'fetch_pe' do
Expand Down

0 comments on commit 6bc392f

Please sign in to comment.