我使用 Ansible 来启动 EC2 实例并向其部署服务。我想将已与现有 EC2 实例关联的弹性 IP 重新关联到新实例,并尽可能减少停机时间。我是否正确,这仅适用于 Ansible ec2_eip
模块的两个步骤?
- 取消与旧实例的关联(状态不存在)
- 关联到新的(状态存在)
没有办法像 ec2-associate-address
CLI 命令的allow-reassociation
选项那样一步完成,对吧?
我刚刚提出了一个拉取请求,可能会对您有所帮助。
此 PR 添加了 2 个模块:boto3
和 boto3_wait
。它允许您调用任何 Boto 3 客户端操作。
你可以这样使用它:
- name: Re-associate Elastic IP
boto3:
name: ec2
region: us-east-1
operation: associate_address
parameters:
AllowReassociation: yes
InstanceId: i-xxxxxxxxxxxxxxxxx
AllocationId: eipalloc-xxxxxxxx
如果您对此功能感到不安,请随时对 PR 进行投票。 :)