Ansible aws_ec2 inventory plugin issue
Asked Answered
A

2

8

I am trying to get started using Ansible and the aws_ec2 plugin.

I have the following in my ./ansible.cfg file:

[inventory]
enable_plugins = aws_ec2

and the following in my ./inventory.yml file:

plugin: aws_ec2
aws_access_key_id: **********
aws_secret_access_key: **********
regions:
    - us-east-2

when I run ansible-inventory -i inventory.yml --graph I get the following error:

inventory.yml did not meet aws_ec2 requirements, check plugin documentation if this is unexpected

Aboral answered 6/2, 2019 at 22:16 Comment(1)
Can you run ansible-inventory -i inventory.yml -vvvv --list and see if it produces anything more informative?Tilghman
U
28

As of Ansible 2.7.6:

aws_ec2 inventory filename must end with 'aws_ec2.yml' or 'aws_ec2.yaml'

proof.

So rename your inventory.yml into inventory_aws_ec2.yml and you are good to go.

Ulcerous answered 7/2, 2019 at 7:41 Comment(3)
I wish the debugging info showed this error. All I was seeing when using -vvvv was: /app/aws_ec2.yml did not meet host_list requirements, check plugin documentation if this is unexpectedAboral
Holy crap that's annoying. I didn't see any mention of that in the docs either. Thank you!Creationism
It's in the docs, but it's a tiny mention that I missed at first. Look there: docs.ansible.com/ansible/latest/collections/amazon/aws/… says "Uses a YAML config file that ends with aws_ec2.{yml|yaml}".Embrace
I
0

Just change the name of the inventory file exactly as the plugin name. For example: a.yaml to aws_ec2.yaml

Ignaciaignacio answered 29/8, 2022 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.