lib/beaker-pe/install/pe_utils.rb in beaker-pe-1.25.0 vs lib/beaker-pe/install/pe_utils.rb in beaker-pe-1.26.0
- old
+ new
@@ -99,34 +99,10 @@
scp_to(host, local_cert_copy, agent_ca_pem_dir)
end
end
end
- # Return agent nodes with 'lb_connect' role that are not loadbalancers
- def loadbalancer_connecting_agents
- lb_connect_nodes = select_hosts(roles: ['lb_connect'])
- lb_connect_agents = lb_connect_nodes.reject { |h| h['roles'].include?('loadbalancer')}
- end
-
- # Returns true if loadbalncer exists and is configured with 'lb_connect' role
- def lb_connect_loadbalancer_exists?
- if (any_hosts_as?('loadbalancer'))
- lb_node = select_hosts(roles: ['loadbalancer'])
- lb_node.first['roles'].include?('lb_connect')
- end
- end
-
- #Returns loadbalancer if host is an agent and loadbalancer has lb_connect role
- #@param [Host] agent host with lb_connect role
- def get_lb_downloadhost(host)
- downloadhost = master
- if( ! host['roles'].include?('loadbalancer') && lb_connect_loadbalancer_exists?)
- downloadhost = loadbalancer
- end
- downloadhost
- end
-
# Generate the command line string needed to from a frictionless puppet-agent
# install on this host in a PE environment.
#
# @param [Host] host The host to install puppet-agent onto
# @param [Hash] opts The full beaker options
@@ -146,18 +122,10 @@
frictionless_install_opts << "#{section}:#{key}=#{value}"
end
end
end
- # If this is an agent node configured to connect to the loadbalancer
- # using 'lb_connect' role, then use loadbalancer in the download url
- # instead of master (PE-22051)
- downloadhost = master
- if( host['roles'].include?('lb_connect'))
- downloadhost = get_lb_downloadhost(host)
- end
-
pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -x' : ''
use_puppet_ca_cert = host[:use_puppet_ca_cert] || opts[:use_puppet_ca_cert]
if host['platform'] =~ /windows/ then
if use_puppet_ca_cert
@@ -165,20 +133,20 @@
cert_validator = %Q{\\$callback = {param(\\$sender,[System.Security.Cryptography.X509Certificates.X509Certificate]\\$certificate,[System.Security.Cryptography.X509Certificates.X509Chain]\\$chain,[System.Net.Security.SslPolicyErrors]\\$sslPolicyErrors);\\$CertificateType=[System.Security.Cryptography.X509Certificates.X509Certificate2];\\$CACert=\\$CertificateType::CreateFromCertFile('#{host['puppetpath']}/ssl/certs/ca.pem') -as \\$CertificateType;\\$chain.ChainPolicy.ExtraStore.Add(\\$CACert);return \\$chain.Build(\\$certificate)};[Net.ServicePointManager]::ServerCertificateValidationCallback = \\$callback}
else
cert_validator = '[Net.ServicePointManager]::ServerCertificateValidationCallback = {\\$true}'
end
- cmd = %Q{powershell -c "cd #{host['working_dir']};#{cert_validator};\\$webClient = New-Object System.Net.WebClient;\\$webClient.DownloadFile('https://#{downloadhost}:8140/packages/current/install.ps1', '#{host['working_dir']}/install.ps1');#{host['working_dir']}/install.ps1 -verbose #{frictionless_install_opts.join(' ')}"}
+ cmd = %Q{powershell -c "cd #{host['working_dir']};#{cert_validator};\\$webClient = New-Object System.Net.WebClient;\\$webClient.DownloadFile('https://#{master}:8140/packages/current/install.ps1', '#{host['working_dir']}/install.ps1');#{host['working_dir']}/install.ps1 -verbose #{frictionless_install_opts.join(' ')}"}
else
curl_opts = %w{--tlsv1 -O}
if use_puppet_ca_cert
curl_opts << '--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem'
elsif host['platform'] !~ /aix/
curl_opts << '-k'
end
- cmd = "FRICTIONLESS_TRACE='true'; export FRICTIONLESS_TRACE; cd #{host['working_dir']} && curl #{curl_opts.join(' ')} https://#{downloadhost}:8140/packages/current/install.bash && bash#{pe_debug} install.bash #{frictionless_install_opts.join(' ')}".strip
+ cmd = "FRICTIONLESS_TRACE='true'; export FRICTIONLESS_TRACE; cd #{host['working_dir']} && curl #{curl_opts.join(' ')} https://#{master}:8140/packages/current/install.bash && bash#{pe_debug} install.bash #{frictionless_install_opts.join(' ')}".strip
end
return cmd
end
@@ -406,45 +374,37 @@
on dashboard, "cd /opt/puppet/share/puppet-dashboard && /opt/puppet/bin/bundle exec /opt/puppet/bin/rake node:addclass[#{master},#{klass}]"
on master, puppet("agent -t"), :acceptable_exit_codes => [0,2]
else
_console_dispatcher = get_console_dispatcher_for_beaker_pe!
- # Add pe_repo packages to 'PE Master' group
- # This change will alow us to test the standard workflow where we add pe_repo packages
- # to PE Master group itself. This will also make it easy to download the packages to
- # compilemasters(PE-22051)
- # Previosuly, we were creating a new node group 'Beaker Frictionless Agent' and adding
- # pe_repo packages to that group
- #
- node_group = _console_dispatcher.get_node_group_by_name('PE Master')
+ # Check if we've already created a frictionless agent node group
+ # to avoid errors creating the same node group when the beaker hosts file contains
+ # multiple hosts with the same platform
+ node_group = _console_dispatcher.get_node_group_by_name('Beaker Frictionless Agent')
+ if node_group.nil? || node_group.empty?
+ node_group = {}
+ node_group['name'] = "Beaker Frictionless Agent"
+ # Pin the master to the node
+ node_group['rule'] = [ "and", [ '=', 'name', master.to_s ]]
+ node_group['classes'] ||= {}
+ end
# add the pe_repo platform class if it's not already present
- if (node_group)
- if( ! node_group['classes'].include?(klass))
- node_group['classes'][klass] = {}
- _console_dispatcher.create_new_node_group_model(node_group)
+ if ! node_group['classes'].include?(klass)
+ node_group['classes'][klass] = {}
- # The puppet agent run that will download the agent tarballs to the master can sometimes fail with
- # curl errors if there is a network hiccup. Use beakers `retry_on` method to retry up to
- # three times to avoid failing the entire test pipeline due to a network blip
- retry_opts = {
- :desired_exit_codes => [0,2],
- :max_retries => 3,
- # Beakers retry_on method wants the verbose value to be a string, not a bool.
- :verbose => 'true'
- }
- retry_on(master, puppet("agent -t"), retry_opts)
-
- # Download the agent tarballs to compile masters
- hosts.each do |h|
- if h['roles'].include?('compile_master')
- retry_on(h, puppet("agent -t"), retry_opts)
- end
- end
- end
- else
- raise "Failed to add pe_repo packages, PE Master node group is not available"
+ _console_dispatcher.create_new_node_group_model(node_group)
+ # The puppet agent run that will download the agent tarballs to the master can sometimes fail with
+ # curl errors if there is a network hiccup. Use beakers `retry_on` method to retry up to
+ # three times to avoid failing the entire test pipeline due to a network blip
+ retry_opts = {
+ :desired_exit_codes => [0,2],
+ :max_retries => 3,
+ # Beakers retry_on method wants the verbose value to be a string, not a bool.
+ :verbose => 'true'
+ }
+ retry_on(master, puppet("agent -t"), retry_opts)
end
end
end
#Perform a Puppet Enterprise upgrade or install
@@ -1587,37 +1547,9 @@
# scp conf.d over from master
scp_from(host, "#{MEEP_DATA_DIR}/conf.d", BEAKER_MEEP_TMP)
end
end
end
-
- # Method to install just the agent nodes
- # This method can be called only after installing PE on all other nodes
- # including infrastructure nodes, loadbalancer, hubs and spokes
- # PE-22051
- # @param [Array] agent only nodes from Beaker hosts
- # @param [Hash] opts The Beaker options hash
- #
- def install_agents_only_on(agentnodes, opts)
- if( ! agentnodes.empty?)
- configure_type_defaults_on(agentnodes)
- agentnodes.each do |host|
- if host['platform'] != master['platform']
- deploy_frictionless_to_master(host)
- end
- install_ca_cert_on(host, opts)
- on(host, installer_cmd(host, opts))
- end
- sign_certificate_for(agentnodes)
- stop_agent_on(agentnodes, :run_in_parallel => true)
- on agentnodes, puppet_agent('-t'), :acceptable_exit_codes => [0,2], :run_in_parallel => true
- agentnodes.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
-
end
end
end
end