我正在使用ansible和vmware_guest
模块来启动VM。
具体来说,我是从模板创建VM的,就像这样:
- name: Deploy VM from template
vmware_guest:
annotation: "{{ lookup('template', './templates/annotations.j2') }}"
hostname: '{{ deploy_vsphere_host }}'
username: '{{ deploy_vsphere_user }}'
password: '{{ deploy_vsphere_password }}'
validate_certs: no
datacenter: '{{ deploy_vsphere_datacenter }}'
esxi_hostname: '{{ deploy_vsphere_cluster }}'
folder: '{{ deploy_vsphere_folder }}'
name: '{{ inventory_hostname }}'
guest_id: '{{ guest_id }}'
disk:
- size_gb: '{{ disk_size }}'
type: thin
datastore: '{{ deploy_vsphere_datastore }}'
networks:
- name: '{{ guest_network }}'
start_connected: true
allow_guest_control: true
ip: "{{ ansible_host }}"
netmask: '{{ guest_netmask }}'
gateway: '{{ guest_gateway }}'
dns_servers:
- '{{ guest_dns_server }}'
hardware:
memory_mb: '{{ guest_memory }}'
num_cpus: '{{ guest_vcpu }}'
customization:
dns_servers:
- '{{ guest_dns_server }}'
domain : '{{ guest_domain_name }}'
hostname: '{{ inventory_hostname }}'
template: '{{ guest_template }}'
wait_for_ip_address: yes
wait_for_customization: yes
state: "{{ state }}"
delegate_to: localhost
但是,磁盘不会自动安装。
例如,我正在使用{{ disk_size }}
添加1000GB磁盘。 SSH到虚拟机时,会得到以下详细信息:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 1000G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 15G 0 part
├─centos-root 253:0 0 13.4G 0 lvm /
└─centos-swap 253:1 0 1.6G 0 lvm
sr0 11:0 1 1024M 0 rom
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 12G 2.3G 84% /
devtmpfs 12G 0 12G 0% /dev
tmpfs 12G 0 12G 0% /dev/shm
tmpfs 12G 2.3M 12G 1% /run
tmpfs 12G 0 12G 0% /sys/fs/cgroup
/dev/sda1 1014M 189M 826M 19% /boot
tmpfs 2.4G 0 2.4G 0% /run/user/1000
Disk /dev/sda: 1073.7 GB, 1073741824000 bytes, 2097152000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a708c
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 33554431 15727616 8e Linux LVM
Disk /dev/mapper/centos-root: 14.4 GB, 14382268416 bytes, 28090368 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 1719 MB, 1719664640 bytes, 3358720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
/dev/mapper/centos-root: UUID="1f352c63-6b7d-4005-89ce-a0dbc149d2e0" TYPE="xfs"
/dev/sda2: UUID="KvUYqI-biVh-jl4C-yi2F-ZPtK-Fokq-1CHzwH" TYPE="LVM2_member"
/dev/sda1: UUID="cdaaa519-be25-4ada-badb-28edbfae5750" TYPE="xfs"
/dev/mapper/centos-swap: UUID="c614ac9a-665f-4a0c-bd13-31c377db3c43" TYPE="swap"
使用Ansible挂载和使用1000gb磁盘的最佳方法是什么?
答案 0 :(得分:0)
我认为vmware_guest_disk模块可以帮助您。