【问题标题】:Add multiple cdroms to a vm in vsphere using ansible使用 ansible 将多个 cdrom 添加到 vsphere 中的 vm
【发布时间】:2019-01-04 13:55:13
【问题描述】:

我正在使用 Ansible 在 sphere 上创建 vm。这个 vm 的要求之一是它有两个 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】:

    在 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
    

    【讨论】:

      猜你喜欢
      • 2014-07-22
      • 1970-01-01
      • 2016-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多