【发布时间】:2020-07-18 09:12:23
【问题描述】:
我刚刚开始在我的一些项目中使用 Ansible。对于测试脚本,我使用 ansible 创建了 57 个 ec2 实例。 所有这些实例都具有相同的安全组,使用 ansible 通过实例 id 终止它们将是一项繁琐的任务。有没有办法根据一些常见因素(如安全组或密钥对)使用 ansible 终止这些实例。我可以终止所有具有相同安全组或具有相同密钥对的实例,但它们的实例 ID 没有使用 ansible?
这是我用来创建这些实例的代码 sn-p。
---
- name: Launching the AWS instance
hosts: localhost
tasks:
- name: Launching the AWS instance
ec2:
key_name: Ansible
region: ap-south-1
instance_type: t2.micro
image: ami-0620d12a9cf777c87
group: Akshay_ansible
count: 57
aws_access_key: XXXXXXXXXXXXXXXXXXXX
aws_secret_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
【问题讨论】:
标签: amazon-web-services amazon-ec2 ansible yaml