Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ec2 inventory to use a boto profile #5987

Closed
wants to merge 1 commit into from

Conversation

willthames
Copy link
Contributor

Issue Type:

Feature Pull Request

Ansible Version:

Based on:
ansible 1.5 (devel 6f405c8) last updated 2014/02/13 18:12:39 (GMT +1000)

Environment:

N/A

Summary:

This allows the EC2 inventory plugin to be used with
the same configuration against different EC2 accounts

Added documentation on profiles to EC2 dynamic inventory doc

Only tries to use profiles if --profile argument is given
to maintain compatibility will boto < 2.24.

Works around a minor bug in boto where if you try and use
a security token with a profile it fails (boto/boto#2100)

@pas256
Copy link
Contributor

pas256 commented Feb 28, 2014

This is great, as it is using Boto to handle multiple AWS accounts. I prefer this over #5156 to accomplish the same goal.

@willthames Can you add one ansible-playbook example to the doc about how to use it? I know you have an example of calling the script directly, but just take it that one extra step for people new to this.

@jalaziz
Copy link
Contributor

jalaziz commented Feb 28, 2014

@willthames I'd also suggest adding support for setting the profile via an environment variable (similar to the EC2_INI_PATH environment variable). This would allow you to use ec2.py directly as your inventory script.

I know there was talk about allowing inventory scripts to accept arguments, but I do not believe this has been implemented yet (or has it?).

@jctanner
Copy link
Contributor

@willthames please post an example usage of ansible-playbook with this patch per @pas256's suggestion.

@willthames
Copy link
Contributor Author

Incorporated @pas256's suggestion and also @jalaziz's suggestion (with additional documentation on how best to use EC2_PROFILE.

@jctanner
Copy link
Contributor

@willthames unfortunately i don't think quoting the script and the param is going to work for the case where users have a mix of scripts and ini files in a directory and then pass the dirname to -i ...

Have you tried testing that?

@willthames
Copy link
Contributor Author

@jctanner - no, that almost certainly won't and shouldn't work!

If you're using Multiple Inventory sources (cool feature btw, wasn't aware of it until your comment prompted me to look into it) then you should probably use the environment variable as you won't be calling a specific script. Glad I just fixed it to allow environment variable!

@mpdehaan
Copy link
Contributor

Note when merging/testing we need to indicate in the docs that those options are only available in 1.6.

@willthames willthames closed this Mar 16, 2014
@willthames willthames reopened this Mar 16, 2014
@mpdehaan mpdehaan added the P2 label Mar 19, 2014
@jctanner
Copy link
Contributor

@willthames do you want to take a look at fixing the merge conflicts so we can test and merge this?

This allows the EC2 inventory plugin to be used with
the same configuration against different EC2 accounts

Profile can be passed using --profile variable or using
EC2_PROFILE environment variable e.g.

```
EC2_PROFILE=prod ansible-playbook -i ec2.py playbook.yml
```

Added documentation on profiles to EC2 dynamic inventory doc

Only tries to use profiles if --profile argument is given
or EC2_PROFILE is set to maintain compatibility will boto < 2.24.

Works around a minor bug in boto where if you try and use
a security token with a profile it fails (boto/boto#2100)

Allow inventory scripts to take additional arguments - e.g.
```
ansible-playbook -i 'ec2.py --profile prod' playbook.yml
```
@willthames
Copy link
Contributor Author

@jctanner - merge conflicts fixed.

@mpdehaan mpdehaan added P3 and removed P2 labels Apr 17, 2014
@willthames
Copy link
Contributor Author

@jctanner can the needs_revision label be removed please?

@mpdehaan
Copy link
Contributor

Hi Will,

James unfortunately does not work for us any longer, but you are correct in that we are no longer waiting for edits on this one. Thank you!

@bcoca
Copy link
Member

bcoca commented Dec 15, 2014

I was going to ask for a rebase, but as others have mentioned before in the ticket, could you change this from being a command line switch to an environment variable?

@jalaziz
Copy link
Contributor

jalaziz commented Dec 15, 2014

@bcoca I have a rebase with some changes here: #9130

There are a couple things that still need improvement. I'll try to get to it soon.

@willthames
Copy link
Contributor Author

@bcoca as documented, it already takes an environment variable as an alternative to the command line parameter.

@bcoca
Copy link
Member

bcoca commented Dec 15, 2014

@willthames sorry, I was unclear, can you just drop the command line switch? in any case this needs a rebase, but as @jalaziz mentions he has an overlapping PR should I close this in favor of that one?

@willthames
Copy link
Contributor Author

@bcoca it's not too hard to fix this one but #9130 is doing a good job of tracking some of the edge cases - probably makes more sense to focus on getting that one right as it aligns with more modern boto capabilities.

@bcoca
Copy link
Member

bcoca commented Dec 16, 2014

OK, closing this ticket then as discussed above.

@bcoca bcoca closed this Dec 16, 2014
jalaziz added a commit to jalaziz/ansible that referenced this pull request Jul 26, 2015
Fixes merge conflicts and standardizes option naming
vazhnov added a commit to vazhnov/fork_ansible_contrib_inventory_ec2.py that referenced this pull request Oct 2, 2015
…e7890e66f3ec9224f01871ee0e7268e581c74ae6
@willthames willthames deleted the ec2_inventory_profile branch October 21, 2015 23:26
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 4, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cloud feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants