Open mohammad0012 opened 1 year ago
You can try using module vcenter_vm_guest_customization_module
from vmware.vmware_rest
. VmGuestCustomizationSetSpec Data Structure support cloud-init spec.
Hi. I was able to set the metadata for cloud-init by writing as follows.
- name: Set the metadata and userdata for the virtual machine
community.vmware.vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
state: present
name: "{{ vm_name }}"
advanced_settings:
- key: guestinfo.metadata
value: "{{ lookup('template', 'metadata.j2') | b64encode }}"
- key: guestinfo.metadata.encoding
value: base64
- key: guestinfo.userdata
value: "{{ lookup('template', 'userdata.j2') | b64encode }}"
- key: guestinfo.userdata.encoding
value: base64
delegate_to: localhost
@hideakihal What does your metadata.j2 template look like? What format of data is it producing (yaml or json)?
Been bashing my head against this for too many hours... it's incredibly frustrating.
Hello, I cant find Ansible module to clone a new VM from template and using cloud init. I am trying to use this module https://github.com/ansible-collections/community.vmware/blob/fd203158eb8d67e4bf218b33fe98fd1afa922072/docs/community.vmware.vmware_guest_module.rst#L4