如何使用 ansible 为 ec2 卷中的启动卷设置终止时删除



对于附加到 ec2 实例的新卷,设置终止时删除似乎很容易,但我如何在引导卷上设置它?

您是在谈论在创建实例期间在根/引导卷上设置此选项吗,如果是这样,下面是示例代码:

- name: Create EC2 Instance(s)
ec2:
region: "{{ vpc_region }}"
group: "{{ ec2_security_group_name }}"
keypair: "{{ ec2_key_name }}"
instance_type: "{{ ec2_instance_type }}"
image: "{{ ami_find_result.results[0].ami_id }}"
vpc_subnet_id: "{{ subnet_id }}"
assign_public_ip: yes
wait: True
wait_timeout: 600
user_data: |
#!/bin/sh
sudo apt-get install nginx -y
instance_tags:
Name: "{{ vpc_name }}-{{ SERVER_ROLE }}"
Environment: "{{ ENVIRONMENT }}"
Server_Role: "{{ SERVER_ROLE }}"
volumes:
- device_name: /dev/sda1
volume_type: gp2
volume_size: "{{ ec2_volume_size }}"
delete_on_termination: yes

有关详细信息,请查看此链接 希望对您有所帮助

最新更新