- Ansible 2 Cloud Automation Cookbook
- Aditya Patawari Vikas Aggarwal
- 205字
- 2021-06-24 18:43:39
How to do it...
To create an EBS volume, we can use an ec2_vol module. This will take the device name, the instance ID, the volume size, and the tag name as input parameters:
- name: Create EBS volume and attach to Instance
ec2_vol:
aws_access_key: "{{ access_key }}"
aws_secret_key: "{{ secret_key }}"
region: "{{ aws_region }}"
instance: "{{ item }}"
volume_size: 10
name: Public Instance 1
device_name: /dev/xvdf
with_items: "{{ ec2_public_instance.instance_ids }}"
register: ec2_vol
This task will create an EBS volume with the tag name as Public Instance 1 and size 10 GB. Once the EBS volume is ready, it will be attached to the EC2 instance we provided with the device name /dev/xvdf.
We should note here that in this task, name and device_name are two different parameters with their own significance. A name is used as a tag; whereas device_name is unique for a one-to-one mapping between an EC2 instance and EBS volume used by AWS EC2.
Also, we have used the same registered variable for the EC2 instance ID that we used in Elastic IPs. If the variable had details of more than one instance, then this task would have created the same number of volumes and would have mapped it one-to-one.
- 電氣自動化專業(yè)英語(第3版)
- Div+CSS 3.0網(wǎng)頁布局案例精粹
- Managing Mission:Critical Domains and DNS
- 基于LPC3250的嵌入式Linux系統(tǒng)開發(fā)
- 空間機(jī)器人遙操作系統(tǒng)及控制
- Windows 8應(yīng)用開發(fā)實(shí)戰(zhàn)
- CorelDRAW X4中文版平面設(shè)計50例
- 四向穿梭式自動化密集倉儲系統(tǒng)的設(shè)計與控制
- Lightning Fast Animation in Element 3D
- 軟件構(gòu)件技術(shù)
- 基于ARM9的小型機(jī)器人制作
- 案例解說Delphi典型控制應(yīng)用
- 企業(yè)級Web開發(fā)實(shí)戰(zhàn)
- Deep Learning Essentials
- Moodle 2.0 Course Conversion(Second Edition)