使用ansible从aws快照还原实例

时间:2016-05-09 17:43:45

标签: amazon-web-services ansible snapshot

我拍了一张实例快照。我只是想用ansible恢复它。 请提供任何解决方案,我的ansible版本是1.9.4。

1 个答案:

答案 0 :(得分:1)

您可以使用ec2_vol模块: http://docs.ansible.com/ansible/ec2_vol_module.html

注意:请密切关注它支持的选项及其添加的版本。

- name: Detach the old volume 
ec2_vol: 
region: "{{ aws_region }}" 
id: "{{ get_id.volume_id }}" 
instance: None 
register: detach_vol 

- name: Creating a Volume from a snapshot 
ec2_vol: 
snapshot: "{{snap_id}}" 
region: "{{ aws_region }}" 
volume_size: 40 
instance: "{{ instance_id }}" 
register: ec2_vol 
tags: attach 

- name: Attach the Created volume to an instance 
ec2_vol: 
instance: "{{ instance_id }}" 
id: "{{ ec2_vol.volume_id }}" 
device_name: /dev/sda1 
delete_on_termination: yes