From 7d0e161662e52343e8b9b79f4f291f9268f65ff4 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Wed, 5 Feb 2014 21:11:06 +1000 Subject: [PATCH] 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