- Ansible 2 Cloud Automation Cookbook
- Aditya Patawari Vikas Aggarwal
- 188字
- 2021-06-24 18:43:39
How to do it…
- 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
- 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.
推薦閱讀
- Visualforce Development Cookbook(Second Edition)
- 協(xié)作機(jī)器人技術(shù)及應(yīng)用
- Photoshop CS3圖層、通道、蒙版深度剖析寶典
- 數(shù)據(jù)通信與計(jì)算機(jī)網(wǎng)絡(luò)
- CompTIA Linux+ Certification Guide
- 精通數(shù)據(jù)科學(xué):從線性回歸到深度學(xué)習(xí)
- Visual FoxPro程序設(shè)計(jì)
- INSTANT Heat Maps in R:How-to
- R Machine Learning Projects
- Python文本分析
- Unreal Development Kit Game Design Cookbook
- 機(jī)器人制作入門(第4版)
- 穿越計(jì)算機(jī)的迷霧
- 企業(yè)級Web開發(fā)實(shí)戰(zhàn)
- Win 7二十一