Ansible vmware vm configuration parameters

47 views
Skip to first unread message

ppktm

unread,
Jul 5, 2023, 1:24:01 PM7/5/23
to Ansible Project
Hello,

I am using ovf to deploy a new vm. Is it also possible to set VM configuration parameters using ansible community.vmware ? After a vm is provisioned , I need to add and set new configuration parameter such as: guestinfo.ipaddress = 192.168.0.2

Thanks!
ppktm.

Atul Nasir

unread,
Aug 19, 2023, 2:10:57 PM8/19/23
to Ansible Project
Setting VM Configuration Parameters During Provisioning:

---
- name: Deploy VM with Guestinfo Parameter
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Deploy VM
      community.vmware.vm_vm_drs_rule:
        validate_certs: no
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        cluster_name: "{{ cluster_name }}"
        datacenter_name: "{{ datacenter_name }}"
        state: poweredon
        name: my_vm
        template: my_template
        networks:
          - name: my_network
        customization_spec: my_customization_spec
        guestinfo:
          ipaddress: 192.168.0.2

Setting VM Configuration Parameters After Provisioning:
---
- name: Set VM Configuration Parameter After Provisioning
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Get VM Facts
      community.vmware.vm_vm_facts:
        validate_certs: no
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        name: my_vm
      register: vm_facts

    - name: Set Guestinfo Parameter
      community.vmware.vm_vm_info:
        validate_certs: no
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        state: poweredon
        vm_id: "{{ vm_facts.instance.id }}"
        guestinfo:
          ipaddress: 192.168.0.2

Reply all
Reply to author
Forward
0 new messages