官术网_书友最值得收藏!

How to do it…

  1. We can create an AMI of an existing EC2 Instance using an ec2_ami module. In this task we will be creating an AMI from the existing instance which, we created in one of the previous tasks. This task will require the instance id, the option to reboot the instance while creating the image, the name, and the tags for the image to be created as input parameters:
- name: Create AMI of Public Instance Created
ec2_ami:
aws_access_key: "{{ access_key }}"
aws_secret_key: "{{ secret_key }}"
region: "{{ aws_region }}"
instance_id: "{{ item }}"
wait: yes
name: first_ami
no_reboot: yes
tags:
Name: First AMI
with_items:
- "{{ ec2_public_instance.instance_ids }}"
register: image
  1. While creating an AMI for running an EC2 instance, we can select not to reboot that instance. If we are sure that the state of that instance will be consistent while creating AMI, we can use no_reboot as yes; otherwise the image created for that instance will not be in the same state we wanted it to be.

We have used here the same EC2 registered variable, used in various previous tasks to pass instance ID's.

主站蜘蛛池模板: 南丹县| 高雄县| 汝阳县| 墨竹工卡县| 上杭县| 丰顺县| 桦川县| 闵行区| 工布江达县| 自治县| 彭泽县| 蒲城县| 山东省| 永州市| 钟山县| 新乐市| 泽库县| 安西县| 卢龙县| 樟树市| 哈密市| 枞阳县| 莎车县| 大冶市| 曲松县| 永年县| 邵东县| 鹤壁市| 布尔津县| 溧水县| 梨树县| 额济纳旗| 英德市| 镇安县| 郴州市| 灵台县| 清水河县| 鞍山市| 汉寿县| 横峰县| 平舆县|