Updated as per @ryansb comments. The EC2 inventory script will now fail
with a useful message when boto3 is not installed and the user is trying
to read RDS cluster information.
When making calls to AWS EC2 api with DescribeTags actiion and if the
number of filter values is greater than or equal to 200, it results in
400 bad request reply and the error message is:
"Error connecting to AWS backend.\n The maximum number of filter values specified on a single call is 200".
The change is so that we call get_all_tags with maximum 199 filter
values one at a time until all are consumed.
EC2 inventory scripts reads configuration from an INI file. The `instance_filters` option controls which EC2 instances are retrieved for inventory. Filling this option and running the inventory script with Python 3 crashes with the following error:
```python
Traceback (most recent call last):
File "./contrib/inventory/ec2.py", line 1328, in <module>
Ec2Inventory()
File "./contrib/inventory/ec2.py", line 163, in __init__
self.read_settings()
File "./contrib/inventory/ec2.py", line 393, in read_settings
for instance_filter in config.get('ec2', 'instance_filters', '').split(','):
TypeError: get() takes 3 positional arguments but 4 were given
```
The problem is the last parameter of config.get() call, because `fallback` keyword argument is not specified.
The fix handles epmpty `instance_filers` in case of Python 2&3
If enabled, this will convert tags of the form "a,b,c" to a list and use
the results to create additional inventory groups.
This is based on PR #8676 by nickpeck (but not a straight rebase—both
the code and the nomenclature have been changed here).
Closes#8676
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)
Introduces destination_format and destination_format_tags
to allow the construction of host names based on one or
more ec2 tags and a python format string.
https://github.com/ansible/ansible/issues/10840
before
RDS: `ERROR: Inventory script (ec2.py) had an execution error: Forbidden`
EC2: `ERROR: Inventory script (ec2.py) had an execution error: Error connecting to AWS backend.
You are not authorized to perform this operation.`
after
RDS: `ERROR: Inventory script (ec2.py) had an execution error: ERROR: "Forbidden", while: getting RDS instances`
EC2: `ERROR: Inventory script (ec2.py) had an execution error: ERROR: "Error connecting to AWS backend.
You are not authorized to perform this operation.", while: getting EC2 instances`
renamed plugins to contrib (they are not really plugins)
rewrote README.md to reflect new usage
added new dir to setup.py so it gets copied with installation, in views
of making using inventory scripts easier in teh future