From 7d0e161662e52343e8b9b79f4f291f9268f65ff4 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Wed, 5 Feb 2014 21:11:06 +1000 Subject: [PATCH 1/2] Work to allow security tokens and profiles to work with Ansible Allow security tokens and profiles to be used as arguments to the 'common' ec2 modules Mostly refactoring to provide two new methods, `get_aws_connection_info`, which results in a dict that can be passed through to the boto `connect_to_region` calls, and `connect_to_aws` that can pass that dict through to the `connect_to_region` method of the appropriate module. Tidied up some variable names Works around boto/boto#2100 profiles don't work with boto < 2.24, but this detects for that and fails with an appropriate message. It is designed to work if profile is not passed but boto < 2.24 is installed. Modifications to allow empty aws auth variables to be passed (this is useful if wanting to have the keys as an optional parameter in ec2 calls - if set, use this value, if not set, use boto config or env variables) Reworked validate_certs improvements to work with refactoring Added documentation for profile and security_token to affected modules --- cloud/ec2 | 14 ++++++++++++++ cloud/ec2_ami | 14 ++++++++++++++ cloud/ec2_eip | 14 ++++++++++++++ cloud/ec2_group | 14 ++++++++++++++ cloud/ec2_key | 14 ++++++++++++++ cloud/ec2_snapshot | 19 +++++++++++++++++-- cloud/ec2_tag | 14 ++++++++++++++ cloud/ec2_vol | 14 ++++++++++++++ 8 files changed, 115 insertions(+), 2 deletions(-) diff --git a/cloud/ec2 b/cloud/ec2 index e050611fcf8..54fc9eea467 100644 --- a/cloud/ec2 +++ b/cloud/ec2 @@ -220,6 +220,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] author: Seth Vidal, Tim Gerla, Lester Wade diff --git a/cloud/ec2_ami b/cloud/ec2_ami index 866f2caf767..94c1e864a85 100644 --- a/cloud/ec2_ami +++ b/cloud/ec2_ami @@ -109,6 +109,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] author: Evan Duffield diff --git a/cloud/ec2_eip b/cloud/ec2_eip index de041f42227..4d6d24eaa34 100644 --- a/cloud/ec2_eip +++ b/cloud/ec2_eip @@ -61,6 +61,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] author: Lorin Hochstein diff --git a/cloud/ec2_group b/cloud/ec2_group index bbbb0fc24e0..5d72c009acc 100644 --- a/cloud/ec2_group +++ b/cloud/ec2_group @@ -65,6 +65,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] ''' diff --git a/cloud/ec2_key b/cloud/ec2_key index 5e6950d2c8b..6523c70e95c 100644 --- a/cloud/ec2_key +++ b/cloud/ec2_key @@ -56,6 +56,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] author: Vincent Viallet diff --git a/cloud/ec2_snapshot b/cloud/ec2_snapshot index b5d9df3b525..81cf3554b3d 100644 --- a/cloud/ec2_snapshot +++ b/cloud/ec2_snapshot @@ -59,17 +59,32 @@ options: default: null aliases: [] instance_id: - description: + description: - instance that has a the required volume to snapshot mounted required: false default: null aliases: [] device_name: - description: + description: - device name of a mounted volume to be snapshotted required: false default: null aliases: [] + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" + requirements: [ "boto" ] author: Will Thames ''' diff --git a/cloud/ec2_tag b/cloud/ec2_tag index ca5a337646f..7e3e4776d0b 100644 --- a/cloud/ec2_tag +++ b/cloud/ec2_tag @@ -67,6 +67,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] author: Lester Wade diff --git a/cloud/ec2_vol b/cloud/ec2_vol index bdd2eae3822..fef476a2165 100644 --- a/cloud/ec2_vol +++ b/cloud/ec2_vol @@ -90,6 +90,20 @@ options: choices: ["yes", "no"] aliases: [] version_added: "1.5" + profile: + description: + - uses a boto profile. Only works with boto >= 2.24.0 + required: false + default: null + aliases: [] + version_added: "1.5" + security_token: + description: + - security token to authenticate against AWS + required: false + default: null + aliases: [] + version_added: "1.5" requirements: [ "boto" ] author: Lester Wade From 789a2915d1f26c2a1ca74d3cb3121f0a6db5a81c Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 11 Mar 2014 10:48:16 -0500 Subject: [PATCH 2/2] Updating profile/security_token version_added labels --- cloud/ec2 | 4 ++-- cloud/ec2_ami | 4 ++-- cloud/ec2_eip | 4 ++-- cloud/ec2_group | 4 ++-- cloud/ec2_key | 4 ++-- cloud/ec2_snapshot | 4 ++-- cloud/ec2_tag | 4 ++-- cloud/ec2_vol | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cloud/ec2 b/cloud/ec2 index ba37c3cc3f0..23ec3eabffd 100644 --- a/cloud/ec2 +++ b/cloud/ec2 @@ -226,14 +226,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Seth Vidal, Tim Gerla, Lester Wade diff --git a/cloud/ec2_ami b/cloud/ec2_ami index 94c1e864a85..446c7417e01 100644 --- a/cloud/ec2_ami +++ b/cloud/ec2_ami @@ -115,14 +115,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Evan Duffield diff --git a/cloud/ec2_eip b/cloud/ec2_eip index 4d6d24eaa34..7eac9798417 100644 --- a/cloud/ec2_eip +++ b/cloud/ec2_eip @@ -67,14 +67,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Lorin Hochstein diff --git a/cloud/ec2_group b/cloud/ec2_group index 5d72c009acc..1dd463cc8d6 100644 --- a/cloud/ec2_group +++ b/cloud/ec2_group @@ -71,14 +71,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] ''' diff --git a/cloud/ec2_key b/cloud/ec2_key index 6523c70e95c..289deb6c9d6 100644 --- a/cloud/ec2_key +++ b/cloud/ec2_key @@ -62,14 +62,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Vincent Viallet diff --git a/cloud/ec2_snapshot b/cloud/ec2_snapshot index 81cf3554b3d..e637ebefa38 100644 --- a/cloud/ec2_snapshot +++ b/cloud/ec2_snapshot @@ -76,14 +76,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Will Thames diff --git a/cloud/ec2_tag b/cloud/ec2_tag index c9de5155853..92af644933e 100644 --- a/cloud/ec2_tag +++ b/cloud/ec2_tag @@ -73,14 +73,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Lester Wade diff --git a/cloud/ec2_vol b/cloud/ec2_vol index fef476a2165..faacc82da8f 100644 --- a/cloud/ec2_vol +++ b/cloud/ec2_vol @@ -96,14 +96,14 @@ options: required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" security_token: description: - security token to authenticate against AWS required: false default: null aliases: [] - version_added: "1.5" + version_added: "1.6" requirements: [ "boto" ] author: Lester Wade