beaker-pe 1.19.0 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjMzOWUyYzQwMGMzNjM2N2Y0MDNhOWM4NjExNzk4NTQ1YjljNTkyMA==
4
+ OWJmNzE1Yzg4ZjY5OTA2NmQ1ODUyNGU2ODkyNTQ4MWNlMzRhZmM5MA==
5
5
  data.tar.gz: !binary |-
6
- YThjYjA2MmE1NzZiZWI2ZWE2NzQ4NjM3OTgzNmQ3ZGMyZTk3ZmE2MA==
6
+ OGI4MzJjODkyYjQxNGI2MzMwZWNkMWYzOGVhN2RkNjYwOWRjZDc2MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDQ0YThhN2EyZjQwM2U2MzQzMTE3OWEwMDcyYjY3NmUzZjk5ZjdkYzRiMThj
10
- ZWQ5NzNmMmI1YTIxZDlkZmRjZjdkODYyODlmMDgwMDZkNzFlMDNhOGVkYWYy
11
- OTI2ZmNlNWVkZmUwMzc5NDE4NjhkNzE0MzNiNGIxOTEyZWI2Y2Y=
9
+ ZTgyZDk2Yzc4OTBkZDY5Nzk2ZjcxZjZlYjU5OGNkMTUzOGJlYjJhNTA3Y2Y4
10
+ NDg5ZGNlNmZiYWIxZWM0MGQzNTQ3MmVhYmVmYjAyYTk4MDc3NDE1MmIzNWUz
11
+ N2VhMjNkMzIyMmQ2YWZlMWE1ZTM3ZTQ1MzA0ZmU1OTBlOGViNDI=
12
12
  data.tar.gz: !binary |-
13
- NzQ5YmQ5YTdmYWYyMzllNWNkNDM5OWQ4NmUwM2I5ZTBjNGMxYzQ4NTRjOTUw
14
- YWU4OWMyYThhNWJiMzk2ZmM2OWY0YWE2MDE1MDA5MzRjZTczZmFkNTc4ZGI3
15
- NjY3OGUxYzYzY2U3OWJjMWZlNzc1OTViNTM3MTQ2YzYxZmRlOWM=
13
+ MDdlMTk5ZTZhMzdlNmQxMDNkY2MyNTI1NTRjNmU4NTkxZDYxZTU4MzFmMWY4
14
+ MDU5Y2U2OThmNDZlYmU0Mjc5ZDAwOTc1N2E3M2M4YjhiYjgzYTI2MjNjNzcx
15
+ OTcxNTQyMGUwYmQ4OGNmYThhMzgzMTViNWIzNWE0MzY2NzdhOWM=
@@ -81,6 +81,68 @@ module Beaker
81
81
  special_nodes + real_agents
82
82
  end
83
83
 
84
+ # If host or opts has the :use_puppet_ca_cert flag set, then push the master's
85
+ # ca cert onto the given host at /etc/puppetlabs/puppet/ssl/certs/ca.pem.
86
+ #
87
+ # This in turn allows +frictionless_agent_installer_cmd+ to generate
88
+ # an install which references the cert to verify the master when downloading
89
+ # resources.
90
+ def install_ca_cert_on(host, opts)
91
+ if host[:use_puppet_ca_cert] || opts[:use_puppet_ca_cert]
92
+ @cert_cache_dir ||= Dir.mktmpdir("master_ca_cert")
93
+ local_cert_copy = "#{@cert_cache_dir}/ca.pem"
94
+ step "Copying master ca.pem to agent for secure frictionless install" do
95
+ ca_pem_dir = '/etc/puppetlabs/puppet/ssl/certs'
96
+ ca_pem_path = "#{ca_pem_dir}/ca.pem"
97
+ scp_from(master, ca_pem_path , @cert_cache_dir) unless File.exist?(local_cert_copy)
98
+ on(host, "mkdir -p #{ca_pem_dir}")
99
+ scp_to(host, local_cert_copy, ca_pem_dir)
100
+ end
101
+ end
102
+ end
103
+
104
+ # Generate the command line string needed to from a frictionless puppet-agent
105
+ # install on this host in a PE environment.
106
+ #
107
+ # @param [Host] host The host to install puppet-agent onto
108
+ # @param [Hash] opts The full beaker options
109
+ # @option opts [Boolean] :use_puppet_ca_cert (false) if true the
110
+ # command will reference the local puppet ca cert to verify the master
111
+ # when obtaining the installation script
112
+ # @param [String] pe_version The PE version string for capabilities testing
113
+ # @return [String] of the commands to be executed for the install
114
+ def frictionless_agent_installer_cmd(host, opts, pe_version)
115
+ # PE 3.4 introduced the ability to pass in config options to the bash
116
+ # script in the form of <section>:<key>=<value>
117
+ frictionless_install_opts = []
118
+ if host.has_key?('frictionless_options') and ! version_is_less(pe_version, '3.4.0')
119
+ # since we have options to pass in, we need to tell the bash script
120
+ host['frictionless_options'].each do |section, settings|
121
+ settings.each do |key, value|
122
+ frictionless_install_opts << "#{section}:#{key}=#{value}"
123
+ end
124
+ end
125
+ end
126
+
127
+ pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -x' : ''
128
+ use_puppet_ca_cert = host[:use_puppet_ca_cert] || opts[:use_puppet_ca_cert]
129
+
130
+ if host['platform'] =~ /windows/ then
131
+ cmd = %Q{powershell -c "cd #{host['working_dir']};[Net.ServicePointManager]::ServerCertificateValidationCallback = {\\$true};\\$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(' ')}"}
132
+ else
133
+ curl_opts = %w{--tlsv1 -O}
134
+ if use_puppet_ca_cert
135
+ curl_opts << '--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem'
136
+ elsif host['platform'] !~ /aix/
137
+ curl_opts << '-k'
138
+ end
139
+
140
+ cmd = "export FRICTIONLESS_TRACE=true; 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
141
+ end
142
+
143
+ return cmd
144
+ end
145
+
84
146
  #Create the PE install command string based upon the host and options settings
85
147
  # @param [Host] host The host that PE is to be installed on
86
148
  # For UNIX machines using the full PE installer, the host object must have the 'pe_installer' field set correctly.
@@ -96,28 +158,7 @@ module Beaker
96
158
  # Frictionless install didn't exist pre-3.2.0, so in that case we fall
97
159
  # through and do a regular install.
98
160
  if host['roles'].include? 'frictionless' and ! version_is_less(version, '3.2.0')
99
- # PE 3.4 introduced the ability to pass in config options to the bash script in the form
100
- # of <section>:<key>=<value>
101
- frictionless_install_opts = []
102
- if host.has_key?('frictionless_options') and ! version_is_less(version, '3.4.0')
103
- # since we have options to pass in, we need to tell the bash script
104
- host['frictionless_options'].each do |section, settings|
105
- settings.each do |key, value|
106
- frictionless_install_opts << "#{section}:#{key}=#{value}"
107
- end
108
- end
109
- end
110
-
111
- pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -x' : ''
112
- if host['platform'] =~ /windows/ then
113
- "powershell -c \"cd #{host['working_dir']};[Net.ServicePointManager]::ServerCertificateValidationCallback = {\\$true};\\$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(' ')}\""
114
- elsif host['platform'] =~ /aix/ then
115
- curl_opts = '--tlsv1 -O'
116
- "cd #{host['working_dir']} && curl #{curl_opts} https://#{master}:8140/packages/current/install.bash && bash#{pe_debug} install.bash #{frictionless_install_opts.join(' ')}".strip
117
- else
118
- curl_opts = '--tlsv1 -kO'
119
- "cd #{host['working_dir']} && curl #{curl_opts} https://#{master}:8140/packages/current/install.bash && bash#{pe_debug} install.bash #{frictionless_install_opts.join(' ')}".strip
120
- end
161
+ frictionless_agent_installer_cmd(host, opts, version)
121
162
  elsif host['platform'] =~ /osx/
122
163
  version = host['pe_ver'] || opts[:pe_ver]
123
164
  pe_debug = host[:pe_debug] || opts[:pe_debug] ? ' -verboseR' : ''
@@ -295,7 +336,7 @@ module Beaker
295
336
  end
296
337
  end
297
338
 
298
- #Classify the master so that it can deploy frictionless packages for a given host.
339
+ #Classify the master so that it can deploy frictionless packages for a given host.
299
340
  #This function does nothing when using meep for classification.
300
341
  # @param [Host] host The host to install pacakges for
301
342
  # @api private
@@ -345,7 +386,16 @@ module Beaker
345
386
  node_group['classes'][klass] = {}
346
387
 
347
388
  _console_dispatcher.create_new_node_group_model(node_group)
348
- on master, puppet("agent -t"), :acceptable_exit_codes => [0,2]
389
+ # The puppet agent run that will download the agent tarballs to the master can sometimes fail with
390
+ # curl errors if there is a network hiccup. Use beakers `retry_on` method to retry up to
391
+ # three times to avoid failing the entire test pipeline due to a network blip
392
+ retry_opts = {
393
+ :desired_exit_codes => [0,2],
394
+ :max_retries => 3,
395
+ # Beakers retry_on method wants the verbose value to be a string, not a bool.
396
+ :verbose => 'true'
397
+ }
398
+ retry_on(master, puppet("agent -t"), retry_opts)
349
399
  end
350
400
  end
351
401
  end
@@ -471,6 +521,7 @@ module Beaker
471
521
 
472
522
  step "Install agents" do
473
523
  block_on(agents, {:run_in_parallel => true}) do |host|
524
+ install_ca_cert_on(host, opts)
474
525
  on(host, installer_cmd(host, opts))
475
526
  end
476
527
  end
@@ -571,6 +622,7 @@ module Beaker
571
622
  if host['platform'] != master['platform'] # only need to do this if platform differs
572
623
  deploy_frictionless_to_master(host)
573
624
  end
625
+ install_ca_cert_on(host, opts)
574
626
  on host, installer_cmd(host, opts)
575
627
  configure_type_defaults_on(host)
576
628
  elsif host['platform'] =~ /osx|eos/
@@ -3,7 +3,7 @@ module Beaker
3
3
  module PE
4
4
 
5
5
  module Version
6
- STRING = '1.19.0'
6
+ STRING = '1.20.0'
7
7
  end
8
8
 
9
9
  end
@@ -188,6 +188,62 @@ describe ClassMixedWithDSLInstallUtils do
188
188
  end
189
189
  end
190
190
 
191
+ describe 'frictionless_agent_installer_cmd' do
192
+ let(:host) do
193
+ the_host = unixhost.dup
194
+ the_host['roles'] = ['frictionless']
195
+ the_host
196
+ end
197
+
198
+ before(:each) do
199
+ expect( subject ).to receive( :master ).and_return( 'testmaster' )
200
+ end
201
+
202
+ it 'generates a unix PE frictionless install command without cert verification' do
203
+ expect( subject.frictionless_agent_installer_cmd( host, {}, '2016.4.0' ) ).to eq("export FRICTIONLESS_TRACE=true; cd /tmp && curl --tlsv1 -O -k https://testmaster:8140/packages/current/install.bash && bash install.bash")
204
+ end
205
+
206
+ it 'generates a unix PE frictionless install command with cert verification' do
207
+ host['use_puppet_ca_cert'] = true
208
+ expect( subject.frictionless_agent_installer_cmd( host, {}, '2016.4.0' ) ).to eq("export FRICTIONLESS_TRACE=true; cd /tmp && curl --tlsv1 -O --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem https://testmaster:8140/packages/current/install.bash && bash install.bash")
209
+ end
210
+
211
+ it 'generates a unix PE frictionless install command without cert verification on aix' do
212
+ host['platform'] = 'aix-61-power'
213
+ expect( subject.frictionless_agent_installer_cmd( host, {}, '2016.4.0' ) ).to eq("export FRICTIONLESS_TRACE=true; cd /tmp && curl --tlsv1 -O https://testmaster:8140/packages/current/install.bash && bash install.bash")
214
+ end
215
+
216
+ it 'generates a PS1 frictionless install command for windows' do
217
+ host['platform'] = 'windows-2012-64'
218
+ expect( subject.frictionless_agent_installer_cmd( host, {}, '2016.4.0' ) ).to eq(%q{powershell -c "cd /tmp;[Net.ServicePointManager]::ServerCertificateValidationCallback = {\\$true};\\$webClient = New-Object System.Net.WebClient;\\$webClient.DownloadFile('https://testmaster:8140/packages/current/install.ps1', '/tmp/install.ps1');/tmp/install.ps1 -verbose "})
219
+ end
220
+ end
221
+
222
+ describe 'install_ca_cert_on' do
223
+ let(:host) do
224
+ the_host = unixhost.dup
225
+ the_host['roles'] = ['frictionless']
226
+ the_host
227
+ end
228
+
229
+ before(:each) do
230
+ allow( subject ).to receive( :master ).and_return( 'testmaster' )
231
+ end
232
+
233
+ it 'installs ca.pem if use_puppet_ca_cert is true' do
234
+ host['use_puppet_ca_cert'] = true
235
+ expect(Dir).to receive(:mktmpdir).with('master_ca_cert').and_return('/tmp/master_ca_cert_random')
236
+ expect(subject).to receive(:on).with(host, 'mkdir -p /etc/puppetlabs/puppet/ssl/certs')
237
+ expect(subject).to receive(:scp_from).with('testmaster', '/etc/puppetlabs/puppet/ssl/certs/ca.pem', %r{/tmp/master_ca_cert_random})
238
+ expect(subject).to receive(:scp_to).with(host, %r{/tmp/master_ca_cert_random/ca.pem}, '/etc/puppetlabs/puppet/ssl/certs')
239
+ expect( subject.install_ca_cert_on(host, {}) )
240
+ end
241
+
242
+ it 'does nothing if use_puppet_ca_cert is false' do
243
+ expect( subject.install_ca_cert_on(host, {}) ).to be_nil
244
+ end
245
+ end
246
+
191
247
  describe 'installer_cmd' do
192
248
 
193
249
  it 'generates a unix PE install command for a unix host' do
@@ -203,7 +259,7 @@ describe ClassMixedWithDSLInstallUtils do
203
259
  the_host['pe_ver'] = '3.8.0'
204
260
  the_host['pe_installer'] = 'puppet-enterprise-installer'
205
261
  the_host['roles'] = ['frictionless']
206
- expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/current/install.bash && bash install.bash"
262
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "export FRICTIONLESS_TRACE=true; cd /tmp && curl --tlsv1 -O -k https://testmaster:8140/packages/current/install.bash && bash install.bash"
207
263
  end
208
264
 
209
265
  it 'generates a unix PE frictionless install command for a unix host with role "frictionless" and "frictionless_options"' do
@@ -213,7 +269,7 @@ describe ClassMixedWithDSLInstallUtils do
213
269
  the_host['pe_installer'] = 'puppet-enterprise-installer'
214
270
  the_host['roles'] = ['frictionless']
215
271
  the_host['frictionless_options'] = { 'main' => { 'dns_alt_names' => 'puppet' } }
216
- expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/current/install.bash && bash install.bash main:dns_alt_names=puppet"
272
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "export FRICTIONLESS_TRACE=true; cd /tmp && curl --tlsv1 -O -k https://testmaster:8140/packages/current/install.bash && bash install.bash main:dns_alt_names=puppet"
217
273
  end
218
274
 
219
275
  it 'generates a osx PE install command for a osx host' do
@@ -250,7 +306,7 @@ describe ClassMixedWithDSLInstallUtils do
250
306
  the_host['pe_installer'] = 'puppet-enterprise-installer'
251
307
  the_host['roles'] = ['frictionless']
252
308
  the_host[:pe_debug] = true
253
- expect( subject.installer_cmd( the_host, {} ) ).to be === "cd /tmp && curl --tlsv1 -kO https://testmaster:8140/packages/current/install.bash && bash -x install.bash"
309
+ expect( subject.installer_cmd( the_host, {} ) ).to be === "export FRICTIONLESS_TRACE=true; cd /tmp && curl --tlsv1 -O -k https://testmaster:8140/packages/current/install.bash && bash -x install.bash"
254
310
  end
255
311
  end
256
312
 
@@ -978,7 +1034,7 @@ describe ClassMixedWithDSLInstallUtils do
978
1034
  let(:node_group) { {} }
979
1035
 
980
1036
  before :each do
981
- allow(subject).to receive(:on)
1037
+ allow(subject).to receive(:retry_on)
982
1038
 
983
1039
  allow(subject).to receive(:hosts).and_return([master, agent])
984
1040
  allow(Scooter::HttpDispatchers::ConsoleDispatcher).to receive(:new).and_return(dispatcher)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-pe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-30 00:00:00.000000000 Z
11
+ date: 2017-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec