V
V
VITYA-XY12020-04-18 20:02:18
Amazon Web Services
VITYA-XY1, 2020-04-18 20:02:18

How to use ansible ad-hoc with AWS EC2 by Name tag?

Hello

Please explain how you need to configure ansible to work with ec2 by tag. Rantsche used the Dynamic Inventory script ec2.py for this purpose. Which has recently been deprecated.
And at the moment, the aws_ec2 plugin is somehow used.
IMHO: There is no information on how this plugin is connected in the offdock .
Google so far found an article on how to switch from using ec2.py to aws_ec2. Created a file:
aws_ec2.yml:

plugin: aws_ec2
regions:
  - eu-west-1


On startup:
ansible all -i ./aws_ec2.yml -m ping
I get the error:

[WARNING]:  * Failed to parse /home/user/aws_ec2.yml with auto plugin: Insufficient boto credentials found. Please provide them in your inventory configuration file or
set them as environment variables.
[WARNING]:  * Failed to parse /home/user/aws_ec2.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /home/user/aws_ec2.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved
to provide a port.
[WARNING]: Unable to parse /home/user/aws_ec2.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


1) What did I set up wrong?
- in what file and how to transfer cradles from AWS or a profile?
2) Is it possible to pass the tag Name to the variable further in the ad-hoc command?
3) Am I using the wrong tool to work with AWS? (while using ansible when maintening baremetal, it is very convenient when there is a stable inventory).

I would be grateful for an example, without "go to Google and look for it."

Thanks

UPDATE:
What is it for:
well, for example, I need to quickly change the config with handles, or restart the service, or collect info or write a playbook.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2020-04-18
@VITYA-XY1

  1. Без кредов плагин не запустится, а без него файл будет невалидным инвентарём (о чём и написано в логе). Перечитывать описание первого параметра плагина до просветленияxtipaef1n9km1s50xurbtbpvrzi.png
  2. Для каждого хоста тэги передаются в переменную tags
  3. Инструмент - тот.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question