ami_spec 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c700a6f5448ab25c9b1247276aa03da13a25e8b6ee11c99627c0001b980bb7d
4
- data.tar.gz: 162c0f91f251d700daecf145b80dc713d5f7770d6f718fd96276461c61497ab3
3
+ metadata.gz: e38763e4488b1a155d18a24baed8e9303c17a57cbd3de3ec1c37d31da9a4908d
4
+ data.tar.gz: e0053a027881e1a452ba2e17c5a003381329968ea7975e48568b7f5834977a13
5
5
  SHA512:
6
- metadata.gz: f202c83cce3214a851739e6eaa2564b8a8c85f3b865732196d11381a789a4e5ee15b44b381b1d0dddd41109614c0b1a1ba2aff58e9bfaacdb0f97a28be164c73
7
- data.tar.gz: db260f6ed177d0f6574d4e53a4d445c340806c5c81c95d1f5ba3173673fe698c7be11a0a4a68c0075698d31f7ea4d0807262574284b45f44f1200861807a9f6b
6
+ metadata.gz: 22823316544f28630b87df445f1e766994d6639adf2022331715fc454a35f8900f8124437aa42347a314f8b7c3049326efdea77d807db2acffcf73770907a988
7
+ data.tar.gz: 28080169c288b9da6d87f266aaa839e002e0a8940a96fd9bd5169a23ae0c03be9fda19211b7f903b36143ad3413efcfa79b0886134c6b7521758c58902c4a1d4
@@ -7,6 +7,7 @@ require 'ami_spec/server_spec'
7
7
  require 'ami_spec/server_spec_options'
8
8
  require 'ami_spec/wait_for_ssh'
9
9
  require 'ami_spec/wait_for_rc'
10
+ require 'ami_spec/wait_for_cloud_init'
10
11
  require 'optimist'
11
12
  require 'logger'
12
13
 
@@ -89,6 +90,7 @@ module AmiSpec
89
90
  ip_address = options[:aws_public_ip] ? instance.public_ip_address : instance.private_ip_address
90
91
  WaitForSSH.wait(ip_address, options[:ssh_user], options[:key_file], options[:ssh_retries])
91
92
  WaitForRC.wait(ip_address, options[:ssh_user], options[:key_file]) if options[:wait_for_rc]
93
+ WaitForCloudInit.wait(ip_address, options[:ssh_user], options[:key_file]) if options[:wait_for_cloud_init]
92
94
 
93
95
  server_spec_options = ServerSpecOptions.new(options.merge(instance: instance))
94
96
  results << ServerSpec.new(server_spec_options).run
@@ -119,30 +121,44 @@ module AmiSpec
119
121
 
120
122
  def self.invoke
121
123
  options = Optimist::options do
122
- opt :role, "The role to test, this should map to a directory in the spec folder", type: :string
123
- opt :ami, "The ami ID to run tests against", type: :string
124
- opt :role_ami_file, "A file containing comma separated roles and amis. i.e.\nweb_server,ami-id.",
125
- type: :string
126
- opt :specs, "The directory to find ServerSpecs", type: :string, required: true
127
- opt :subnet_id, "The subnet to start the instance in. If not provided a subnet will be chosen from the default VPC", type: :string
128
- opt :key_name, "The SSH key name to assign to instances. If not provided a temporary key pair will be generated in AWS",
129
- type: :string
130
- opt :key_file, "The SSH private key file associated to the key_name", type: :string
131
- opt :ssh_user, "The user to ssh to the instance as", type: :string, required: true
132
- opt :aws_region, "The AWS region, defaults to AWS_DEFAULT_REGION environment variable", type: :string
133
- opt :aws_instance_type, "The ec2 instance type, defaults to t2.micro", type: :string, default: 't2.micro'
134
- opt :aws_security_groups, "Security groups to associate to the launched instances. May be specified multiple times. If not provided a temporary security group will be generated in AWS",
135
- type: :string, default: nil, multi: true
136
- opt :allow_any_temporary_security_group, "The temporary security group will allow SSH connections from any IP address (0.0.0.0/0)"
137
- opt :aws_public_ip, "Launch instances with a public IP"
138
- opt :ssh_retries, "The number of times we should try sshing to the ec2 instance before giving up. Defaults to 30",
139
- type: :int, default: 30
140
- opt :tags, "Additional tags to add to launched instances in the form of comma separated key=value pairs. i.e. Name=AmiSpec", type: :string, default: ""
141
- opt :debug, "Don't terminate instances on exit"
142
- opt :buildkite, "Output section separators for buildkite"
143
- opt :wait_for_rc, "Wait for oldschool SystemV scripts to run before conducting tests. Currently only supports Ubuntu with upstart"
144
- opt :user_data_file, "File path for aws ec2 user data", type: :string, default: nil
145
- opt :iam_instance_profile_arn, "IAM instance profile to use", type: :string
124
+ opt :role,
125
+ 'The role to test, this should map to a directory in the spec folder',
126
+ type: :string, short: :r
127
+ opt :ami, 'The ami ID to run tests against', type: :string, short: :a
128
+ opt :role_ami_file,
129
+ 'A file containing comma separated roles and amis. i.e.
130
+ web_server,ami-id.',
131
+ type: :string, short: :o
132
+ opt :specs, 'The directory to find ServerSpecs',
133
+ type: :string, required: true, short: :s
134
+ opt :subnet_id,
135
+ 'The subnet to start the instance in. If not provided a subnet will be chosen from the default VPC',
136
+ type: :string, short: :u
137
+ opt :key_name, 'The SSH key name to assign to instances. If not provided a temporary key pair will be generated in AWS',
138
+ type: :string, short: :k
139
+ opt :key_file, 'The SSH private key file associated to the key_name', type: :string, short: :e
140
+ opt :ssh_user, 'The user to ssh to the instance as', type: :string, required: true, short: :h
141
+ opt :aws_region, 'The AWS region, defaults to AWS_DEFAULT_REGION environment variable',
142
+ type: :string, short: :w
143
+ opt :aws_instance_type, 'The ec2 instance type, defaults to t2.micro',
144
+ type: :string, default: 't2.micro', short: :i
145
+ opt :aws_security_groups,
146
+ 'Security groups to associate to the launched instances. May be specified multiple times. If not provided a temporary security group will be generated in AWS',
147
+ type: :string, default: nil, multi: true, short: :c
148
+ opt :allow_any_temporary_security_group, 'The temporary security group will allow SSH connections from any IP address (0.0.0.0/0)',
149
+ short: :n
150
+ opt :aws_public_ip, 'Launch instances with a public IP', short: :p
151
+ opt :ssh_retries, 'The number of times we should try sshing to the ec2 instance before giving up. Defaults to 30',
152
+ type: :int, default: 30, short: :t
153
+ opt :tags, 'Additional tags to add to launched instances in the form of comma separated key=value pairs. i.e. Name=AmiSpec',
154
+ type: :string, default: '', short: :g
155
+ opt :debug, "Don't terminate instances on exit", short: :d
156
+ opt :buildkite, 'Output section separators for buildkite', short: :b
157
+ opt :wait_for_rc, 'Wait for oldschool SystemV scripts to run before conducting tests. Currently only supports Ubuntu with upstart',
158
+ short: :f
159
+ opt :wait_for_cloud_init, 'Wait for Cloud Init to complete before running tests'
160
+ opt :user_data_file, 'File path for aws ec2 user data', type: :string, default: nil, short: :l
161
+ opt :iam_instance_profile_arn, 'IAM instance profile to use', type: :string, short: :m
146
162
  end
147
163
 
148
164
  if options[:role] && options[:ami]
@@ -1,3 +1,3 @@
1
1
  module AmiSpec
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.0'
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'net/ssh'
2
+
3
+ module AmiSpec
4
+ class WaitForCloudInit
5
+ def self.wait(ip_address, user, key, port=22)
6
+ Net::SSH.start(ip_address, user, keys: [key], :verify_host_key => :never, port: port) do |ssh|
7
+ ssh.exec! '/usr/bin/cloud-init status --wait'
8
+ end
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ami_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Robinson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-06 00:00:00.000000000 Z
12
+ date: 2020-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-ec2
@@ -128,6 +128,7 @@ files:
128
128
  - lib/ami_spec/server_spec.rb
129
129
  - lib/ami_spec/server_spec_options.rb
130
130
  - lib/ami_spec/version.rb
131
+ - lib/ami_spec/wait_for_cloud_init.rb
131
132
  - lib/ami_spec/wait_for_rc.rb
132
133
  - lib/ami_spec/wait_for_ssh.rb
133
134
  homepage: https://github.com/envato/ami-spec