I’m creating a new vm with ansible. I used vmware_guest here. I have added the iso file when creating vm. After creating, I turned on the power. But I can’t intervene to install the operating system.
How can I install the new vm operating system (linux, windows) that I created with Ansible?
> - name: Create a virtual machine
> vmware_guest:
> hostname: "{{ vcenter_hostname }}"
> username: "{{ vcenter_username }}"
> password: "{{ vcenter_password }}"
> datacenter: "{{ datacenter }}"
> validate_certs: no
> folder: /Ansible-Test
> name: "{{vm_name}}"
> state: poweredon
> guest_id: "{{isletim_sistemi}}"
> cluster: CLUSTER
> disk:
> - size_gb: "{{disk_boyutu}}"
> type: eagerzeroedthick
> autoselect_datastore: true
> hardware:
> memory_mb: "{{ram}}"
> num_cpus: "{{cpu}}"
> scsi: paravirtual
> cdrom:
> type: iso
> iso_path: "{{iso}}"
> networks:
> - name: "{{vlan}}"
> device_type: vmxnet3
> wait_for_ip_address: no
> delegate_to: localhost
> register: deploy_vm
The picture above shows the result of creating vm. I want to install the operating system by interfering with the next section.
I want to install centos 7, but I cannot intervene in the installation process.
Is this possible?
I want to work with this method, not with the template. I am familiar with creating templates.
ansible 2.7.10
Pyvmomi
vsphere 6.7
2
Answers
Ansible can do that from a template, which you seem to already be familiar with, but I’m not aware of any methods which would allow you to build a VM from scratch.
You need to create a custom ISO file for the operating system. Eg. Binding kickstart file with RHEL operating system so that there will not be able to manual intervention during the booting process.