Commit Graph

67 Commits (16c2207d21dd0f2d1829d9797097ee7528bce07b)

Author SHA1 Message Date
Matt Martz d3249e7875 pep8 fixes for contrib (#24344) 7 years ago
Elijah Lynn c7ae6b9fd5 [cloud][inventory] Get tags for RDS instances. (#23989)
* Get tags for RDS instances.

Boto3 only at this time.

Relates to #11569, #14464.

* Add a check for boto3

* Fix HAS_BOTO3 error
7 years ago
Toshio Kuratomi 6bad4e57bd Migrate most uses of if type() to if isinstance()
Also convert those checks to use abcs instead of dict and list.

Make a sentinel class for strategies to report when they've reache the end
8 years ago
Steve Kuznetsov 6318229bc4 Only read EC2 `regions_exclude` list if necessary (#18720)
When specifying a literal whitelist of AWS EC2 regions in the dynamic
inventory configuration file, it should not be necessary to also include
a literal blacklist, especially as the blacklist is not honored in this
case anyway. By reading the literal blacklist only when necessary, it is
possible for a user to provide a more minimal EC2 configuration file.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
8 years ago
Rune T. Sorensen 6804d69557 [cloud][contrib] IAM role support for EC2 dynamic inventory (#15196)
* EC2 inventory can now connect using an IAM role

* Fix comment indentation

* Make sure that Ec2Inventory.iam_role is always defined

* Add missing import
8 years ago
William Holroyd 4ca7726e75 Fix Elasticcache issue where ec2 script would fail on finding lack of primary endpoint address on Redis cluster (#20190) 8 years ago
Alex Trevino 0d060a185f Allow ec2.py to be imported (#21637) 8 years ago
rafstef 8acb6417cb [cloud][inventory] Let ec2.py be renamed and search for a matching .ini file (#21567)
With this proposed PR, we want to make the use of many ec2 dynamic inventory files more flexible.
We are using multiple AWS accounts. We want to use different ini file (one for every account) and only one ec2.py.
8 years ago
Ryan S. Brown 3c25a39b3e [cloud][aws] Use binary read for inventory cache file 8 years ago
Alex Trevino 413dfa7273 [cloud][aws] Use `with` statement for file rw in EC2 dynamic inventory (#21390)
* Use with statement when doing rw on files

* Deserialize file-like object directly instead of a string

For python 2/3 compatibility reasons, per PR feedback.
8 years ago
Jonathan McCall 047ed2728c Pass boto_profile to get_route53_records (#14354)
* Pass boto_profile to get_route53_records

* Add conditional around r53_conn to check for boto_profile
8 years ago
Ian White 80bc7048bd Feature: adding route53_hostnames option to set the hostnames from route 53 (#20909)
* adding route53_hostnames option to set the hostnames from route 53

* checking whether the route53_hostnames option is present as suggested by @s-hertel

* setting route53_hostnames to None when config option not present

* skip the to_safe only when using route53_hostnames option, as suggested by @ryansb

* skipping the to_safe strip only for the hostnames that came from route53 as suggested by @ryansb
8 years ago
gregorydulin cf424f0413 [cloud] Add group_by_instance_state to EC2 Dynamic Inventory (#20430) 8 years ago
Ilya Kalinin 259b05dd8e [cloud] Add stack_filters option to EC2 inventory script 8 years ago
Matt Martz 5942de603d Legacy pep8 clean fixes for contrib and hacking (#21081) 8 years ago
Matt Clay e401b4e424 PEP 8 fix. 8 years ago
Naoya Nakazawa 31db1bcd34 ec2.py support region auto (#15427) 8 years ago
Will Thames d6ea400efb Improve boto profile handling for EC2 inventory (#20280)
Ensure command line profile argument and AWS_PROFILE environment variable
overrides config file
Remove unnecessary `lambda` function
Fix cache file path construction to be more pythonic (and windows-ready)
8 years ago
Matt Clay cb76200c7d PEP 8 E111 & E114 cleanup. (#20838) 8 years ago
Matt Clay d0d1158c5e PEP 8 cleanup. (#20789)
* PEP 8 E703 cleanup.
* PEP 8 E701 cleanup.
* PEP 8 E711 cleanup.
* PEP 8 W191 and E101 cleanup.
8 years ago
Matthew Wedgwood 3ab388f6dd Add account ID grouping and attribute to ease multi-account management 8 years ago
Carlos E. Garcia 0b8011436d minor spelling changes 8 years ago
Tony Kinsley 73da2663a3 Resolves #18312 python3 support for ec2.py 8 years ago
Khushil Dep 08db04ccb6
Changes as per @abadger 8 years ago
Khushil Dep 054e640fba
Add enumeration of block devices to ec2_block_devices 8 years ago
Ryan S. Brown 0783c172d7 Paginate DB cluster responses in AWS RDS dynamic inventory 8 years ago
Ryan S. Brown 59e499f8f0 Respect profiles & credentials for boto3 inventory
Using boto3 directly wasn't properly using profiles set in the `ec2.ini`
file, this change uses the `module_utils` boto3_conn instead.
8 years ago
Tom Paine 418f91d0e2 Fail softly when boto3 is not installed
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.
8 years ago
Tom Paine bb5a1f7440 Add RDS cluster info to EC2 dynamic inventory
Add db_clusters to the ec2 inventory. Show tags. Only show clusters
matching tags in the `.ini`. Set `include_rds_clusters = True` option to
enable RDS cluster inventory collection.

Example inventory output:

```
{
  "db_clusters": {
    "ryansb-cluster-test": {
      "AllocatedStorage": 1,
      "AvailabilityZones": [
        "us-west-2a",
        "us-west-2b",
        "us-west-2c"
      ],
      "BackupRetentionPeriod": 1,
      "DBClusterIdentifier": "ryansb-cluster-test",
      "DBClusterMembers": [
        {
          "DBClusterParameterGroupStatus": "in-sync",
          "DBInstanceIdentifier": "ryansb-test",
          "IsClusterWriter": true,
          "PromotionTier": 1
        },
        {
          "DBClusterParameterGroupStatus": "in-sync",
          "DBInstanceIdentifier": "ryansb-test-us-west-2b",
          "IsClusterWriter": false,
          "PromotionTier": 1
        }
      ],
      "DBClusterParameterGroup": "default.aurora5.6",
      "DBSubnetGroup": "default",
      "DatabaseName": "mydb",
      "DbClusterResourceId": "cluster-OB6H7JQURFKFD4BYNHG5HSRLBA",
      "Endpoint": "ryansb-cluster-test.cluster-c9ntgaejgqln.us-west-2.rds.amazonaws.com",
      "Engine": "aurora",
      "EngineVersion": "5.6.10a",
      "MasterUsername": "admin",
      "Port": 3306,
      "PreferredBackupWindow": "06:09-06:39",
      "PreferredMaintenanceWindow": "mon:11:22-mon:11:52",
      "ReadReplicaIdentifiers": [],
      "Status": "available",
      "StorageEncrypted": false,
      "VpcSecurityGroups": [
        {
          "Status": "active",
          "VpcSecurityGroupId": "sg-47eaea20"
        }
      ]
    }
  },
  "rds": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com",
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "rds_aurora": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com",
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "rds_parameter_group_default_aurora5_6": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com",
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "ryansb-test": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "ryansb-test-us-west-2b": [
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "type_db_r3_large": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com",
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "us-west-2": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com",
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "us-west-2a": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "us-west-2b": [
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ],
  "vpc_id_vpc_3ca34459": [
    "ryansb_test_c9ntgaejgqln_us_west_2_rds_amazonaws_com",
    "ryansb_test_us_west_2b_c9ntgaejgqln_us_west_2_rds_amazonaws_com"
  ]
}
```
8 years ago
bqbn 3498b840c9 Fixes #16095: Maximumly 199 filter values (#16184)
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.
8 years ago
Adam Chainz 064ed63843 Fix ec2 inventory for potentially inconsistent data (#12642) 8 years ago
Victor Costan 8d3da09eae contrib/inventory/ec2.py can read AWS credentials from ec2.ini (#15378) 8 years ago
Jorge Nerín 3a3e69f830 Fix substituting dots for underscores when using ips (#15578)
ec2.py was substituting the dots on ip addresses when not using hostnames like:
  "ec2": [
    "10_10_1_1", 

now it's:
  "ec2": [
    "10.10.1.1",
9 years ago
Owen Tuz 3b8d753121 Avoid cache conflicts when using multiple AWS accounts 9 years ago
James Cammarata c9da48d5ba Merge branch 'destination_format' of https://github.com/a13m/ansible into a13m-destination_format 9 years ago
Brian Coca e1ee2ed5a5 Merge pull request #13550 from KrzysiekJ/connect_to_region-wrap
Use wrapped connect_to_region everywhere in ec2.py
9 years ago
Brian Coca eceabec71f page rds instances
fix #14861
9 years ago
Abhijit Menon-Sen ad0e707f97 Merge pull request #7395 from hkariti/ec2_hostname_variable
Add hostname_variable to ec2 inventory script
9 years ago
Hagai Kariti 8a17da299f Clean up lines with only whitespaces in ec2.py 9 years ago
Hagai Kariti 53756af546 Added hostname_variable to ec2 inventory 9 years ago
Abhijit Menon-Sen f0af07a5f4 Merge pull request #14761 from enbritely/fix-ec2-inventory
Fix AWS EC2 inventory script instance_filters read
9 years ago
Joe 21ba6e9ce8 Do not use name `tag` for intance filter 9 years ago
Joe 5975296770 Fix AWS EC2 external inventory script config read
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
9 years ago
Brian Coca 37eac4592e added back --profile to keep backwards compat
this was broken by #12548
9 years ago
Krzysztof Jurewicz 73160e65e5 Use wrapped connect_to_region everywhere in ec2.py 9 years ago
Abhijit Menon-Sen e6a9b2cae5 Add an expand_csv_tags setting to ec2.ini
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
9 years ago
Brian Coca b2a9111b22 reversed the logic on new setting to control - replacment in groups as
it was wrong
fixes #13122
9 years ago
Matthew Jones faeccb4e61 Fix ec2 infinitely nested groups
The ec2 inventory module will incorrectly place parent groups as child
groups of themselves, this fixes that.
9 years ago
Brian Coca 2b8633cec0 Merge pull request #12855 from bcoca/ec2_inv_dash_group
make - replacement in group names optional
9 years ago
Brian Coca aac20aa076 removed unused exception vars 9 years ago