使用ansible将多个cdrom添加到vSphere中的vm

问题描述 投票:1回答:1

我正在使用Ansible在球上创建虚拟机。该虚拟机的要求之一是,它具有两个CD驱动器,每个CD驱动器中都有一个磁盘。查看vmware_guestvsphere_guest模块,似乎您无法在一项任务中做到这一点,但是我遇到了blogs,它显示了在一个任务期间使用较旧的vsphere_guest模块创建的两个CD驱动器。尝试此操作,它给我一个错误。

任务:

  -name: create vm
    ...
    vm_hardware:
      memory_mb: 2096
      num_cpus: 2
      osid: centos64Guest
      scsi: paravirtual
      vm_cdrom:
        disk1:
          type: "iso"
          iso_path: "DATASTORE/ISO1.iso"
        disk2:
          type: "iso"
           iso_path: "DATASTORE/ISO2.iso"

错误:

fatal: [hostname -> localhost]: FAILED! => {"changed": false, "msg": "Error on {'disk2': {'type:': 'iso', iso_path': 'DATASTORE/ISO2.iso'}, 'disk1': {'type:': 'iso', iso_path': 'DATASTORE/ISO1.iso'}} definition. cdrom type needs to be specified.

DATASTORE是ISO所在的我的数据存储的名称

这使我相信我无法定义两个磁盘,因为它似乎正在vm_cdrom下寻找cd信息:

我也尝试过:

  -name: create vm
    ...
    vm_hardware:
      ...
      vm_cdrom:
        type: "iso"
        iso_path: "DATASTORE/ISO1.iso"
       vm_cdrom:
         type: "iso"
         iso_path: "DATASTORE/ISO2.iso"

但是(据推测)给我一个错误,指出已定义了两个vm_cdroms,它将使用最后一个值。

还有另一种方法来挂载两个CD吗?还是我SOL?

ansible vmware vsphere
1个回答
0
投票

[在2.9中添加。当前仅支持IDE。您需要创建一个列表,controller_type并映射controller_number和unit_number。

hardware:
        num_cpus: 2
....
cdrom:
        - controller_type: ide
          controller_number: 0
          unit_number: 0 
          iso_path: "DATASTORE/ISO1.iso"
          type: iso

        - controller_type: ide
          controller_number: 0
          unit_number: 1
          iso_path: "DATASTORE/ISO2.iso"
          type: iso
© www.soinside.com 2019 - 2024. All rights reserved.