Merge pull request #5880 from willthames/ec2_modules_refactor

Create a common EC2 connection argument spec for EC2 modules
reviewable/pr18780/r1
jctanner 11 years ago
commit a5b6b6ec54

@ -808,13 +808,12 @@ def startstop_instances(module, ec2, instance_ids):
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec = dict( argument_spec.update(dict(
key_name = dict(aliases = ['keypair']), key_name = dict(aliases = ['keypair']),
id = dict(), id = dict(),
group = dict(type='list'), group = dict(type='list'),
group_id = dict(type='list'), group_id = dict(type='list'),
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
zone = dict(aliases=['aws_zone', 'ec2_zone']), zone = dict(aliases=['aws_zone', 'ec2_zone']),
instance_type = dict(aliases=['type']), instance_type = dict(aliases=['type']),
image = dict(), image = dict(),
@ -824,9 +823,6 @@ def main():
ramdisk = dict(), ramdisk = dict(),
wait = dict(type='bool', default=False), wait = dict(type='bool', default=False),
wait_timeout = dict(default=300), wait_timeout = dict(default=300),
ec2_url = dict(),
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
placement_group = dict(), placement_group = dict(),
user_data = dict(), user_data = dict(),
instance_tags = dict(type='dict'), instance_tags = dict(type='dict'),
@ -839,6 +835,7 @@ def main():
volumes = dict(type='list'), volumes = dict(type='list'),
) )
) )
module = AnsibleModule(argument_spec=argument_spec)
ec2 = ec2_connect(module) ec2 = ec2_connect(module)

@ -252,11 +252,8 @@ def deregister_image(module, ec2):
sys.exit(0) sys.exit(0)
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec = dict( argument_spec.update(dict(
ec2_url = dict(),
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
instance_id = dict(), instance_id = dict(),
image_id = dict(), image_id = dict(),
delete_snapshot = dict(), delete_snapshot = dict(),
@ -266,9 +263,9 @@ def main():
description = dict(default=""), description = dict(default=""),
no_reboot = dict(default=False, type="bool"), no_reboot = dict(default=False, type="bool"),
state = dict(default='present'), state = dict(default='present'),
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS)
) )
) )
module = AnsibleModule(argument_spec=argument_spec)
ec2 = ec2_connect(module) ec2 = ec2_connect(module)

@ -209,18 +209,18 @@ def find_instance(ec2, instance_id, module):
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec = dict( argument_spec.update(dict(
instance_id = dict(required=False), instance_id = dict(required=False),
public_ip = dict(required=False, aliases= ['ip']), public_ip = dict(required=False, aliases= ['ip']),
state = dict(required=False, default='present', state = dict(required=False, default='present',
choices=['present', 'absent']), choices=['present', 'absent']),
ec2_url = dict(required=False, aliases=['EC2_URL']),
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
region = dict(required=False, aliases=['ec2_region']),
in_vpc = dict(required=False, choices=BOOLEANS, default=False), in_vpc = dict(required=False, choices=BOOLEANS, default=False),
), )
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True supports_check_mode=True
) )

@ -107,18 +107,17 @@ def addRulesToLookup(rules, prefix, dict):
grant.group_id, grant.cidr_ip)] = rule grant.group_id, grant.cidr_ip)] = rule
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec=dict( argument_spec.update(dict(
name=dict(required=True), name=dict(required=True),
description=dict(required=True), description=dict(required=True),
vpc_id=dict(), vpc_id=dict(),
rules=dict(), rules=dict(),
ec2_url=dict(aliases=['EC2_URL']),
ec2_secret_key=dict(aliases=['EC2_SECRET_KEY', 'aws_secret_key'], no_log=True),
ec2_access_key=dict(aliases=['EC2_ACCESS_KEY', 'aws_access_key']),
region=dict(choices=AWS_REGIONS),
state = dict(default='present', choices=['present', 'absent']), state = dict(default='present', choices=['present', 'absent']),
), )
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True, supports_check_mode=True,
) )

@ -97,16 +97,15 @@ except ImportError:
sys.exit(1) sys.exit(1)
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec=dict( argument_spec.update(dict(
name=dict(required=True), name=dict(required=True),
key_material=dict(required=False), key_material=dict(required=False),
ec2_url=dict(aliases=['EC2_URL']),
ec2_secret_key=dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
ec2_access_key=dict(aliases=['aws_access_key', 'access_key']),
region=dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
state = dict(default='present', choices=['present', 'absent']), state = dict(default='present', choices=['present', 'absent']),
), )
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True, supports_check_mode=True,
) )

@ -103,17 +103,14 @@ except ImportError:
sys.exit(1) sys.exit(1)
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec = dict( argument_spec.update(dict(
resource = dict(required=True), resource = dict(required=True),
tags = dict(required=True), tags = dict(required=True),
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
state = dict(default='present', choices=['present', 'absent']), state = dict(default='present', choices=['present', 'absent']),
ec2_url = dict(aliases=['EC2_URL']),
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
) )
) )
module = AnsibleModule(argument_spec=argument_spec)
resource = module.params.get('resource') resource = module.params.get('resource')
tags = module.params['tags'] tags = module.params['tags']

@ -139,20 +139,17 @@ except ImportError:
sys.exit(1) sys.exit(1)
def main(): def main():
module = AnsibleModule( argument_spec = ec2_argument_spec()
argument_spec = dict( argument_spec.update(dict(
instance = dict(), instance = dict(),
volume_size = dict(required=True), volume_size = dict(required=True),
iops = dict(), iops = dict(),
device_name = dict(), device_name = dict(),
region = dict(aliases=['aws_region', 'ec2_region'], choices=AWS_REGIONS),
zone = dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']), zone = dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']),
ec2_url = dict(),
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
snapshot = dict(), snapshot = dict(),
) )
) )
module = AnsibleModule(argument_spec=argument_spec)
instance = module.params.get('instance') instance = module.params.get('instance')
volume_size = module.params.get('volume_size') volume_size = module.params.get('volume_size')

Loading…
Cancel
Save