lib/beaker-pe/install/pe_utils.rb in beaker-pe-1.11.0 vs lib/beaker-pe/install/pe_utils.rb in beaker-pe-1.12.0

- old
+ new

@@ -376,9 +376,125 @@ # {Beaker::DSL::InstallUtils::FOSSUtils#install_puppet_agent_pe_promoted_repo_on} # # @api private # def do_install hosts, opts = {} + # detect the kind of install we're doing + install_type = determine_install_type(hosts, opts) + case install_type + when :simple_monolithic + simple_monolithic_install(hosts.first, hosts.drop(1), opts) + when :simple_split + # This isn't implemented yet, so just do a generic install instead + #simple_split_install(hosts, opts) + generic_install(hosts, opts) + else + generic_install(hosts, opts) + end + end + + def has_all_roles?(host, roles) + roles.all? {|role| host['roles'].include?(role)} + end + + # Determine what kind of install is being performed + # @param [Array<Host>] hosts The sorted hosts to install or upgrade PE on + # @param [Hash{Symbol=>Symbol, String}] opts The options for how to install or upgrade PE + # + # @example + # determine_install_type(hosts, {:type => :install, :pe_ver => '2017.2.0'}) + # + # @return [Symbol] + # One of :generic, :simple_monolithic, :simple_split + # :simple_monolithic + # returned when installing >=2016.4 with a monolithic master and + # any number of frictionless agents + # :simple_split + # returned when installing >=2016.4 with a split install and any + # number of frictionless agents + # :generic + # returned for any other install or upgrade + # + # @api private + def determine_install_type(hosts, opts) + # Do a generic install if this is masterless, not all the same PE version, an upgrade, or earlier than 2016.4 + return :generic if opts[:masterless] + return :generic if hosts.map {|host| host['pe_ver']}.uniq.length > 1 + return :generic if opts[:type] == :upgrade + return :generic if version_is_less(opts[:pe_ver] || hosts.first['pe_ver'], '2016.4') + + mono_roles = ['master', 'database', 'dashboard'] + if has_all_roles?(hosts.first, mono_roles) && hosts.drop(1).all? {|host| host['roles'].include?('frictionless')} + :simple_monolithic + elsif hosts[0]['roles'].include?('master') && hosts[1]['roles'].include?('database') && hosts[2]['roles'].include?('dashboard') && hosts.drop(3).all? {|host| host['roles'].include?('frictionless')} + :simple_split + else + :generic + end + end + + # Install PE on a monolithic master and some number of frictionless agents. + # @param [Host] master The node to install the master on + # @param [Array<Host>] agents The nodes to install agents on + # @param [Hash{Symbol=>Symbol, String}] opts The options for how to install or upgrade PE + # + # @example + # simple_monolithic_install(master, agents, {:type => :install, :pe_ver => '2017.2.0'}) + # + # @return nil + # + # @api private + def simple_monolithic_install(master, agents, opts={}) + step "Performing a standard monolithic install with frictionless agents" + all_hosts = [master, *agents] + configure_type_defaults_on(all_hosts) + + # Set PE distribution on the master, create working dir + prepare_hosts([master], opts) + fetch_pe([master], opts) + prepare_host_installer_options(master) + generate_installer_conf_file_for(master, [master], opts) + on master, installer_cmd(master, opts) + + step "Setup frictionless installer on the master" do + agents.each do |agent| + # If We're *not* running the classic installer, we want + # to make sure the master has packages for us. + if agent['platform'] != master['platform'] # only need to do this if platform differs + deploy_frictionless_to_master(agent) + end + end + end + + step "Install agents" do + agents.group_by {|agent| installer_cmd(agent, opts)}.each do |cmd, agents| + on agents, cmd, :run_in_parallel => true + end + end + + step "Stop puppet agents to avoid interfering with tests" do + stop_agent_on(all_hosts, :run_in_parallel => true) + end + + step "Sign agent certificates" do + # This will sign all cert requests + sign_certificate_for(agents) + end + + step "Run puppet to setup mcollective and pxp-agent" do + on all_hosts, puppet_agent('-t'), :acceptable_exit_codes => [0,2], :run_in_parallel => true + + #Workaround for windows frictionless install, see BKR-943 for the reason + agents.select {|agent| agent['platform'] =~ /windows/}.each do |agent| + client_datadir = agent.puppet['client_datadir'] + on(agent, puppet("resource file \"#{client_datadir}\" ensure=absent force=true")) + end + end + end + + def generic_install hosts, opts = {} + step "Installing PE on a generic set of hosts" + masterless = opts[:masterless] opts[:type] = opts[:type] || :install unless masterless pre30database = version_is_less(opts[:pe_ver] || database['pe_ver'], '3.0') pre30master = version_is_less(opts[:pe_ver] || master['pe_ver'], '3.0')