beaker-aws 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25ed7d4088360b6932af6030241fbec171819c1f
4
- data.tar.gz: 5a087caf648e84fc6886f7cb77aea9c430569fa5
3
+ metadata.gz: 9b39f1ca1a2bdc0a2a8e75730e76cd69d4cc934c
4
+ data.tar.gz: 7759619b5826a06b6f575315504c98aec4b91266
5
5
  SHA512:
6
- metadata.gz: 0e8141e8939e84487128d04be5315dd7e3ac747076d6a01201aa75d16ede330650c06eed48d8d6ef1b052ef8c32abe80a3993db562866492f3d33212ae838263
7
- data.tar.gz: bc3a0e59c45667e3a38939a7f8896f404a4997facf5dc7942f826385af689dbf915d6a1424add235ee2c6a32de41212aba0a53a32250e1e410b168974190da71
6
+ metadata.gz: 8fc76af69f00c9454c590af3bf8bcb1e79dfd0955a2f025b65820bc80d4af3a55bed483d5fb0c21b98212f0c29050a667c896e7514dbf5e11fe8cdf579e55d39
7
+ data.tar.gz: f75390cb0aeddbf63c8764c19e806c110f98f3d26077a0143386576d9728aa0f763158912676c588849e4aad2ffee408638c5fb6a72d25e0f8fc8db4fded007a
@@ -1,3 +1,3 @@
1
1
  module BeakerAws
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -65,11 +65,19 @@ module Beaker
65
65
  # Perform the main launch work
66
66
  launch_all_nodes()
67
67
 
68
- wait_for_status_netdev()
69
-
70
68
  # Add metadata tags to each instance
69
+ # tagging early as some nodes take longer
70
+ # to initialize and terminate before it has
71
+ # a chance to provision
71
72
  add_tags()
72
73
 
74
+ # adding the correct security groups to the
75
+ # network interface, as during the `launch_all_nodes()`
76
+ # step they never get assigned, although they get created
77
+ modify_network_interface()
78
+
79
+ wait_for_status_netdev()
80
+
73
81
  # Grab the ip addresses and dns from EC2 for each instance to use for ssh
74
82
  populate_dns()
75
83
 
@@ -352,6 +360,10 @@ module Beaker
352
360
  :instance_initiated_shutdown_behavior => "terminate",
353
361
  }
354
362
  if assoc_pub_ip_addr
363
+ # this never gets created, so they end up with
364
+ # default security group which only allows for
365
+ # ssh access from outside world which
366
+ # doesn't work well with remote devices etc.
355
367
  config[:network_interfaces] = [{
356
368
  :subnet_id => subnet_id,
357
369
  :groups => [security_group.group_id, ping_security_group.group_id],
@@ -485,7 +497,7 @@ module Beaker
485
497
  # Wait for each node to reach status :running
486
498
  @logger.notify("aws-sdk: Waiting for all hosts to be #{state_name}")
487
499
  instances.each do |x|
488
- name = x[:host].name
500
+ name = x[:host] ? x[:host].name : x[:name]
489
501
  instance = x[:instance]
490
502
  @logger.notify("aws-sdk: Wait for node #{name} to be #{state_name}")
491
503
  # Here we keep waiting for the machine state to reach 'running' with an
@@ -530,9 +542,9 @@ module Beaker
530
542
  wait_for_status(:running, @hosts)
531
543
 
532
544
  wait_for_status(nil, @hosts) do |instance|
533
- instance_status_collection = instance.client.describe_instance_status({:instance_ids => [instance.instance_id]})
534
- first_instance = instance_status_collection.reservations.first.instances.first
535
- first_instance[:system_status][:status] == "ok"
545
+ instance_status_collection = client.describe_instance_status({:instance_ids => [instance.instance_id]})
546
+ first_instance = instance_status_collection.first[:instance_statuses].first
547
+ first_instance[:instance_status][:status] == "ok" if first_instance
536
548
  end
537
549
 
538
550
  break
@@ -587,6 +599,33 @@ module Beaker
587
599
  nil
588
600
  end
589
601
 
602
+ # Add correct security groups to hosts network_interface
603
+ # as during the create_instance stage it is too early in process
604
+ # to configure
605
+ #
606
+ # @return [void]
607
+ # @api private
608
+ def modify_network_interface
609
+ @hosts.each do |host|
610
+ instance = host['instance']
611
+ host['sg_cidr_ips'] = host['sg_cidr_ips'] || '0.0.0.0/0';
612
+ sg_cidr_ips = host['sg_cidr_ips'].split(',')
613
+
614
+ # Define tags for the instance
615
+ @logger.notify("aws-sdk: Update network_interface for #{host.name}")
616
+
617
+ security_group = ensure_group(instance[:network_interfaces].first, Beaker::EC2Helper.amiports(host), sg_cidr_ips)
618
+ ping_security_group = ensure_ping_group(instance[:network_interfaces].first, sg_cidr_ips)
619
+
620
+ client.modify_network_interface_attribute(
621
+ :network_interface_id => "#{instance[:network_interfaces].first[:network_interface_id]}",
622
+ :groups => [security_group.group_id, ping_security_group.group_id],
623
+ )
624
+ end
625
+
626
+ nil
627
+ end
628
+
590
629
  # Populate the hosts IP address from the EC2 dns_name
591
630
  #
592
631
  # @return [void]
@@ -692,13 +731,17 @@ module Beaker
692
731
  end
693
732
  backoff_sleep(tries)
694
733
  end
695
- host['user'] = 'root'
696
- host.close
734
+ host['user'] = 'admin'
697
735
  sha256 = Digest::SHA256.new
698
- password = sha256.hexdigest((1..50).map{(rand(86)+40).chr}.join.gsub(/\\/,'\&\&'))
699
- host['ssh'] = {:password => password}
700
- host.exec(Command.new("echo -e '#{password}\\n#{password}' | tmsh modify auth password admin"))
736
+ password = sha256.hexdigest((1..50).map{(rand(86)+40).chr}.join.gsub(/\\/,'\&\&')) + 'password!'
737
+ # disabling password policy to account for the enforcement level set
738
+ # and the generated password is sometimes too `01070366:3: Bad password (admin): BAD PASSWORD: \
739
+ # it is too simplistic/systematic`
740
+ host.exec(Command.new('modify auth password-policy policy-enforcement disabled'))
741
+ host.exec(Command.new("modify auth user admin password #{password}"))
701
742
  @logger.notify("f5: Configured admin password to be #{password}")
743
+ host.close
744
+ host['ssh'] = {:password => password}
702
745
  end
703
746
 
704
747
  # Enables root access for a host on an netscaler platform
@@ -730,7 +773,7 @@ module Beaker
730
773
  elsif host['platform'] =~ /windows/
731
774
  @logger.notify('aws-sdk: Change hostname on windows is not supported.')
732
775
  else
733
- next if host['platform'] =~ /netscaler/
776
+ next if host['platform'] =~ /f5-|netscaler/
734
777
  host.exec(Command.new("hostname #{host.name}"))
735
778
  if host['vmname'] =~ /^amazon/
736
779
  # Amazon Linux requires this to preserve host name changes across reboots.
@@ -751,7 +794,7 @@ module Beaker
751
794
  elsif host['platform'] =~ /windows/
752
795
  @logger.notify('aws-sdk: Change hostname on windows is not supported.')
753
796
  else
754
- next if host['platform'] =~ /netscaler/
797
+ next if host['platform'] =~ /ft-|netscaler/
755
798
  host.exec(Command.new("hostname #{host.hostname}"))
756
799
  if host['vmname'] =~ /^amazon/
757
800
  # See note above
@@ -119,6 +119,7 @@ module Beaker
119
119
  before :each do
120
120
  expect(aws).to receive(:launch_all_nodes)
121
121
  expect(aws).to receive(:add_tags)
122
+ expect(aws).to receive(:modify_network_interface)
122
123
  expect(aws).to receive(:populate_dns)
123
124
  expect(aws).to receive(:enable_root_on_hosts)
124
125
  expect(aws).to receive(:set_hostnames)
@@ -702,7 +703,7 @@ module Beaker
702
703
  allow( aws ).to receive( :backoff_sleep )
703
704
  sha_mock = Object.new
704
705
  allow( Digest::SHA256 ).to receive( :new ).and_return(sha_mock)
705
- expect( sha_mock ).to receive( :hexdigest ).once()
706
+ expect( sha_mock ).to receive( :hexdigest ).and_return('thistest').once()
706
707
  enable_root_f5
707
708
  end
708
709
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rishi Javia, Kevin Imber, Tony Vu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-21 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec