Can not attach CM rom in Vmware

522 views
Skip to first unread message

Nick Vanadium

unread,
Oct 16, 2015, 12:12:32 PM10/16/15
to Ansible Project
Greetings all. Apologies if this is not the correct place to post this but I wasn't able to find anything related to this. 

So I have recently began playing with Ansible and I am trying to build some VMs in Vmware Sphere using the Ansible module. However I can't seem to be able to attach the CD rom to the VM with VMware. Below is the error I receive along with the syntax of my playbook. Any assistance would be much appreciated. 

My error:

PLAY [all] ********************************************************************

TASK: [vsphere_guest ] ********************************************************
failed: [EXAMPLE-Web01] => {"failed": true}
msg: unsupported parameter for module: vm_cdrom

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/home/ansible/create_vm.retry

EXAMPLE-Web01              : ok=0    changed=0    unreachable=0    failed=1

----------------------------------------------------------------------------------------------------------
My playbook:

- hosts: all
  gather_facts: false
  connection: local
  user: ansible
  sudo: true

  vars_prompt:
    - name: "vcenter_hostname"
      prompt: "Enter vcenter hostname"
      private: no
      default: "vsphere.mydomain.com"
    - name: "vcenter_user"
      prompt: "Enter vcenter username"
      private: no
    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
      private: yes

  vars:
    datacenter: 'My-Datacenter'
    esxi_host: 'esx1.mydomain.com'
    notes: 'Created by Ansible'
  tasks:
    - vsphere_guest:
        vcenter_hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        guest: "{{ inventory_hostname }}"
        state: powered_on
        vm_extra_config:
          notes: "{{ notes }}"
        vm_disk:
          disk1:
            size_gb: "{{ disk }}"
            type: thick
            datastore: "{{ datastore }}"
# Attach CD ROM to VM
        vm_cdrom:
            type: "iso"
            iso_path: "datastore1/iso/ansible-ks.iso"
        vm_nic:
          nic1:
            type: vmxnet3
            network: "{{ network }}"
            network_type: standard
        vm_hardware:
          memory_mb: "{{ memory }}"
          num_cpus: "{{ cpucount }}"
          osid: "{{ osid }}"
          scsi: paravirtual          
        esxi:
          datacenter: "{{ datacenter }}"
          hostname: "{{ esxi_host }}"
------------------------------------------------------------
Hosts defined

EXAMPLE-Web01 disk='8' datastore='datastore1' network='vlan1' memory='512' cpucount='2' osid='rhel6_64Guest'

Markus Ellers

unread,
Oct 18, 2015, 4:30:15 AM10/18/15
to Ansible Project
hi,

try making vm_cdrom a parameter under vm_hardware
       
vm_hardware:
  memory_mb: "{{ memory }}"
  num_cpus: "{{ cpucount }}"
  osid: "{{ osid }}"
  scsi: paravirtua
  vm_cdrom:
    type: "iso"
    iso_path: "datastore1/iso/ansible-ks.iso"


Nick Vanadium

unread,
Oct 20, 2015, 10:46:51 AM10/20/15
to Ansible Project
Dude, thank you so much. It worked! Of course I tried moving the entry everywhere else other than what you suggested lol. But yeah man you finally gave me some peace. 

Markus Ellers

unread,
Oct 20, 2015, 4:00:01 PM10/20/15
to Ansible Project
You're welcome. Sometimes all it takes is a fresh pair of eyes.

Asaf Moalem

unread,
Feb 11, 2016, 9:47:41 AM2/11/16
to Ansible Project
Hi,
Were you able to connect the cdrom? 
I get the cdrom mounted with the ISO, but not connected.

Thanks.
Asaf.

kesten broughton

unread,
Feb 11, 2016, 6:23:39 PM2/11/16
to Ansible Project
I saw the same problem and have not found a fix for it yet.

David P

unread,
Jun 19, 2017, 11:35:29 AM6/19/17
to Ansible Project
Me too - Still looking for a solution. If anyone knows how to connect it that would be really helpful, thanks!

Reply all
Reply to author
Forward
0 new messages