|
|
@ -95,8 +95,15 @@ options:
|
|
|
|
required: False
|
|
|
|
required: False
|
|
|
|
default: null
|
|
|
|
default: null
|
|
|
|
aliases: []
|
|
|
|
aliases: []
|
|
|
|
|
|
|
|
instance_tags:
|
|
|
|
|
|
|
|
version_added: "1.0"
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- string of tags, in json format, to add to the new instance
|
|
|
|
|
|
|
|
required: False
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
aliases: []
|
|
|
|
examples:
|
|
|
|
examples:
|
|
|
|
- code: "local_action: ec2 keypair=admin instance_type=m1.large image=emi-40603AD1 wait=true group=webserver count=3"
|
|
|
|
- code: "local_action: ec2 keypair=admin instance_type=m1.large image=emi-40603AD1 wait=true group=webserver count=3 instance_tags='{"Name":"My Server"}'"
|
|
|
|
description: "Examples from Ansible Playbooks"
|
|
|
|
description: "Examples from Ansible Playbooks"
|
|
|
|
requirements: [ "boto" ]
|
|
|
|
requirements: [ "boto" ]
|
|
|
|
author: Seth Vidal, Tim Gerla, Lester Wade
|
|
|
|
author: Seth Vidal, Tim Gerla, Lester Wade
|
|
|
@ -126,6 +133,7 @@ def main():
|
|
|
|
ec2_secret_key = dict(aliases=['EC2_SECRET_KEY']),
|
|
|
|
ec2_secret_key = dict(aliases=['EC2_SECRET_KEY']),
|
|
|
|
ec2_access_key = dict(aliases=['EC2_ACCESS_KEY']),
|
|
|
|
ec2_access_key = dict(aliases=['EC2_ACCESS_KEY']),
|
|
|
|
user_data = dict(),
|
|
|
|
user_data = dict(),
|
|
|
|
|
|
|
|
instance_tags = dict(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -141,6 +149,7 @@ def main():
|
|
|
|
ec2_secret_key = module.params.get('ec2_secret_key')
|
|
|
|
ec2_secret_key = module.params.get('ec2_secret_key')
|
|
|
|
ec2_access_key = module.params.get('ec2_access_key')
|
|
|
|
ec2_access_key = module.params.get('ec2_access_key')
|
|
|
|
user_data = module.params.get('user_data')
|
|
|
|
user_data = module.params.get('user_data')
|
|
|
|
|
|
|
|
instance_tags = module.params.get('instance_tags')
|
|
|
|
|
|
|
|
|
|
|
|
# allow eucarc environment variables to be used if ansible vars aren't set
|
|
|
|
# allow eucarc environment variables to be used if ansible vars aren't set
|
|
|
|
if not ec2_url and 'EC2_URL' in os.environ:
|
|
|
|
if not ec2_url and 'EC2_URL' in os.environ:
|
|
|
@ -170,6 +179,12 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
instids = [ i.id for i in res.instances ]
|
|
|
|
instids = [ i.id for i in res.instances ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if instance_tags:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
ec2.create_tags(instids, module.from_json(instance_tags))
|
|
|
|
|
|
|
|
except boto.exception.EC2ResponseError as e:
|
|
|
|
|
|
|
|
module.fail_json(msg = "%s: %s" % (e.error_code, e.error_message))
|
|
|
|
|
|
|
|
|
|
|
|
res_list = res.connection.get_all_instances(instids)
|
|
|
|
res_list = res.connection.get_all_instances(instids)
|
|
|
|
this_res = res_list[0]
|
|
|
|
this_res = res_list[0]
|
|
|
|
if wait:
|
|
|
|
if wait:
|
|
|
|