lib/ami_spec.rb in ami_spec-0.2.0 vs lib/ami_spec.rb in ami_spec-0.3.0
- old
+ new
@@ -34,10 +34,12 @@
# Should the instances get a public IP address
# ssh_user::
# The username to SSH to the AMI with.
# ssh_retries::
# Set the maximum number of ssh retries while waiting for the instance to boot.
+ # tags:::
+ # Additional tags to add to launched instances in the form of comma separated key=value pairs
# debug::
# Don't terminate the instances on exit
# == Returns:
# Boolean - The result of all the server specs.
def self.run(options)
@@ -94,10 +96,11 @@
opt :aws_security_groups, "Security groups to associate to the launched instances. May be specified multiple times",
type: :strings, default: nil
opt :aws_public_ip, "Launch instances with a public IP"
opt :ssh_retries, "The number of times we should try sshing to the ec2 instance before giving up. Defaults to 30",
type: :int, default: 30
+ 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: ""
opt :debug, "Don't terminate instances on exit"
opt :wait_for_rc, "Wait for oldschool SystemV scripts to run before conducting tests. Currently only supports Ubuntu with upstart"
end
if options[:role] && options[:ami]
@@ -111,8 +114,16 @@
options.delete(:role_ami_file)
else
fail "You must specify either role and ami or role_ami_file"
end
+ options[:tags] = parse_tags(options[:tags])
+
exit run(options)
+ end
+
+ def self.parse_tags(tags)
+ tag_pairs = tags.split(',')
+ tag_key_values = tag_pairs.collect{ |pair| pair.split('=')}.flatten
+ Hash[*tag_key_values]
end
end