[英]Ansible : Add running EC2 instances to Auto-scaling group
我正在一個Ansible項目中,在該項目中我想將通過tag-Name找到的現有EC2實例添加到我的自動縮放組中。 我能夠通過AMI或終止舊實例來找到它。 但是我只是在尋找一種將它們添加到自動縮放組的方法,就像在Web管理控制台中一樣。 在我只需右鍵單擊實例的地方,選擇設置,將其附加到自動縮放組。 以下代碼全部在1個文件中。
查找EC2實例:
- hosts: localhost
connection: local
gather_facts: no
tasks:
- ec2_remote_facts:
region: eu-central-1
filters:
"tag:Name": Ubuntu_From_AMI
register: ec2found
- name: Add found instances to group
add_host: hostname="{{ item.public_ip_address }}" groups=ec2instances
with_items: "{{ ec2found.instances }}"
這是我添加自動縮放組的方式:
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Add auto-scaling groups.
ec2_asg:
name: magento_scaling_group
load_balancers: 'LB_NAME'
availability_zones: [ 'eu-central-1a', 'eu-central-1b', 'eu-central-1c' ]
launch_config_name: "{{ lc.name }}"
min_size: 0
max_size: 5
desired_capacity: 0
vpc_zone_identifier: [ 'subnet-e712ad8c', 'subnet-e12e8dac', 'subnet-28e91a55' ]
tags:
- environment: production
propagate_at_launch: no
可能嗎? 謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.