ami_spec 1.7.0 → 1.8.1
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 +4 -4
- data/README.md +2 -1
- data/lib/ami_spec/aws_instance.rb +8 -1
- data/lib/ami_spec/aws_instance_options.rb +2 -0
- data/lib/ami_spec/version.rb +1 -1
- data/lib/ami_spec.rb +16 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52b2bb6051e9962f16d4743d539763034bdf6e5ae33154852bbd335fe0a1b26b
|
4
|
+
data.tar.gz: 3b8876510c793c28911dab088fa35f003a0f15862c869bda17092db38e266929
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '06228534001d96065a6bc5937533e4e00a250d821ce264259cc792d41165639d0142e04e4dfa0374cd934fc9b0786fa80c76deb577e96649519017a28a23a4c1'
|
7
|
+
data.tar.gz: 3aff902fd3205ce1704dbddb09eda7b5a02ce960cc253e944c04473e5101624d8459c31b3bb69400ac20565745647dfbb178f1c23b2f6fc2f259bc7fc50c02a8
|
data/README.md
CHANGED
@@ -54,7 +54,8 @@ Options:
|
|
54
54
|
group will be generated in AWS
|
55
55
|
-n, --allow-any-temporary-security-group The temporary security group will allow SSH connections
|
56
56
|
from any IP address (0.0.0.0/0), otherwise allow the subnet's block
|
57
|
-
-p, --aws-public-ip Launch instances with a public IP
|
57
|
+
-p, --aws-public-ip Launch instances with a public IP and use that IP for SSH
|
58
|
+
-q, --associate-public-ip Launch instances with a public IP and use the Private IP for SSH
|
58
59
|
-t, --ssh-retries=<i> The number of times we should try sshing to the ec2 instance
|
59
60
|
before giving up. Defaults to 30 (default: 30)
|
60
61
|
-g, --tags=<s> Additional tags to add to launched instances in the form of
|
@@ -19,27 +19,34 @@ module AmiSpec
|
|
19
19
|
@key_name = options.fetch(:key_name)
|
20
20
|
@instance_type = options.fetch(:aws_instance_type)
|
21
21
|
@public_ip = options.fetch(:aws_public_ip)
|
22
|
+
@associate_public_ip = options.fetch(:associate_public_ip)
|
22
23
|
@region = options.fetch(:aws_region)
|
23
24
|
@security_group_ids = options.fetch(:aws_security_groups)
|
24
25
|
@tags = ec2ify_tags(options.fetch(:tags))
|
25
26
|
@user_data_file = options.fetch(:user_data_file, nil)
|
26
27
|
@iam_instance_profile_arn = options.fetch(:iam_instance_profile_arn, nil)
|
28
|
+
@logger = options.fetch(:logger)
|
27
29
|
end
|
28
30
|
|
29
31
|
def_delegators :@instance, :instance_id, :tags, :private_ip_address, :public_ip_address
|
30
32
|
|
31
33
|
def start
|
34
|
+
@logger.info "Creating AWS EC2 instance for #{@ami}"
|
32
35
|
client = Aws::EC2::Client.new(client_options)
|
33
36
|
placeholder_instance = client.run_instances(instances_options).instances.first
|
34
37
|
|
35
38
|
@instance = Aws::EC2::Instance.new(placeholder_instance.instance_id, client_options)
|
39
|
+
@logger.info "Waiting for AWS EC2 instance to start: #{@instance.id}"
|
36
40
|
@instance.wait_until_running
|
37
41
|
tag_instance
|
42
|
+
@logger.info "AWS EC2 instance started: #{@instance.id}"
|
38
43
|
end
|
39
44
|
|
40
45
|
def terminate
|
46
|
+
@logger.info "Terminating AWS EC2 instance: #{@instance.id}"
|
41
47
|
@instance.terminate
|
42
48
|
@instance.wait_until_terminated
|
49
|
+
@logger.info "AWS EC2 instance terminated: #{@instance.id}"
|
43
50
|
end
|
44
51
|
|
45
52
|
private
|
@@ -61,7 +68,7 @@ module AmiSpec
|
|
61
68
|
key_name: @key_name,
|
62
69
|
network_interfaces: [{
|
63
70
|
device_index: 0,
|
64
|
-
associate_public_ip_address: @public_ip,
|
71
|
+
associate_public_ip_address: @public_ip || @associate_public_ip,
|
65
72
|
subnet_id: @subnet_id,
|
66
73
|
}]
|
67
74
|
}
|
data/lib/ami_spec/version.rb
CHANGED
data/lib/ami_spec.rb
CHANGED
@@ -38,7 +38,9 @@ module AmiSpec
|
|
38
38
|
# aws_instance_type::
|
39
39
|
# AWS ec2 instance type
|
40
40
|
# aws_public_ip::
|
41
|
-
# Should the instances get a public IP address
|
41
|
+
# Should the instances get a public IP address and use that IP for SSH
|
42
|
+
# associate_public_ip::
|
43
|
+
# Launch instances with a public IP but don't use that IP for SSH
|
42
44
|
# ssh_user::
|
43
45
|
# The username to SSH to the AMI with.
|
44
46
|
# ssh_retries::
|
@@ -81,17 +83,25 @@ module AmiSpec
|
|
81
83
|
|
82
84
|
instances = []
|
83
85
|
options[:amis].each_pair do |role, ami|
|
84
|
-
aws_instance_options = AwsInstanceOptions.new(options.merge(role: role, ami: ami))
|
86
|
+
aws_instance_options = AwsInstanceOptions.new(options.merge(role: role, ami: ami, logger: logger))
|
85
87
|
instances << AwsInstance.start(aws_instance_options)
|
86
88
|
end
|
87
89
|
|
88
90
|
results = []
|
89
91
|
instances.each do |instance|
|
90
92
|
ip_address = options[:aws_public_ip] ? instance.public_ip_address : instance.private_ip_address
|
93
|
+
logger.info("Waiting for SSH…")
|
91
94
|
WaitForSSH.wait(ip_address, options[:ssh_user], options[:key_file], options[:ssh_retries])
|
92
|
-
|
93
|
-
|
95
|
+
if options[:wait_for_rc]
|
96
|
+
logger.info("Waiting for RC…")
|
97
|
+
WaitForRC.wait(ip_address, options[:ssh_user], options[:key_file])
|
98
|
+
end
|
99
|
+
if options[:wait_for_cloud_init]
|
100
|
+
logger.info("Waiting for cloud init…")
|
101
|
+
WaitForCloudInit.wait(ip_address, options[:ssh_user], options[:key_file])
|
102
|
+
end
|
94
103
|
|
104
|
+
logger.info("Running serverspec…")
|
95
105
|
server_spec_options = ServerSpecOptions.new(options.merge(instance: instance))
|
96
106
|
results << ServerSpec.new(server_spec_options).run
|
97
107
|
end
|
@@ -147,7 +157,8 @@ web_server,ami-id.',
|
|
147
157
|
type: :string, default: nil, multi: true, short: :c
|
148
158
|
opt :allow_any_temporary_security_group, 'The temporary security group will allow SSH connections from any IP address (0.0.0.0/0)',
|
149
159
|
short: :n
|
150
|
-
opt :aws_public_ip, 'Launch instances with a public IP', short: :p
|
160
|
+
opt :aws_public_ip, 'Launch instances with a public IP and use that IP for SSH', short: :p
|
161
|
+
opt :associate_public_ip, "Launch instances with a public IP but don't use that IP for SSH", short: :q
|
151
162
|
opt :ssh_retries, 'The number of times we should try sshing to the ec2 instance before giving up. Defaults to 30',
|
152
163
|
type: :int, default: 30, short: :t
|
153
164
|
opt :tags, 'Additional tags to add to launched instances in the form of comma separated key=value pairs. i.e. Name=AmiSpec',
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ami_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Robinson
|
8
8
|
- Martin Jagusch
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-ec2
|
@@ -134,7 +134,7 @@ files:
|
|
134
134
|
homepage: https://github.com/envato/ami-spec
|
135
135
|
licenses: []
|
136
136
|
metadata: {}
|
137
|
-
post_install_message:
|
137
|
+
post_install_message:
|
138
138
|
rdoc_options: []
|
139
139
|
require_paths:
|
140
140
|
- lib
|
@@ -149,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
153
|
-
signing_key:
|
152
|
+
rubygems_version: 3.3.26
|
153
|
+
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Acceptance testing your AMIs
|
156
156
|
test_files: []
|