vmware.vmware_rest icon indicating copy to clipboard operation
vmware.vmware_rest copied to clipboard

i need example on "postcustomization ansible vmware example" for collection vmware.vmware_rest.vcenter_vm_guest_customization

Open mani611 opened this issue 4 months ago • 1 comments

This is really a cool functionality, i would appreciate if you can provide the example of post customization script execution. My current script look like this

- name: Customize the VM
  vmware.vmware_rest.vcenter_vm_guest_customization:
    vcenter_hostname: "{{ vcenter_hostname }}"
    vcenter_username: "{{ vcenter_username }}"
    vcenter_password: "{{ vcenter_password }}"
    vcenter_validate_certs : false
    vm: '{{ vm_info.id }}'
    configuration_spec:
      linux_config:
        domain: test
        hostname:
          fixed_name: test
          type: FIXED
        #script_text: |
        #  #!/bin/bash
        # yum update -y
    interfaces:
    - adapter:
        ipv4:
          type: STATIC
          gateways:
          - 1.1.11,1
          ip_address: 1.1.14.65
          prefix: 24
    global_DNS_settings:

need example how do i use post customization script. example is used in below code but not working. I believe example is missing in redhat documentation.

- name: Customize the VM
  vmware.vmware_rest.vcenter_vm_guest_customization:
    vcenter_hostname: "{{ vcenter_hostname }}"
    vcenter_username: "{{ vcenter_username }}"
    vcenter_password: "{{ vcenter_password }}"
    vcenter_validate_certs : false
    vm: '{{ vm_info.id }}'
    configuration_spec:
      linux_config:
        script_text: postcustomization
        #!/bin/sh
        if [ x$1 = x"precustomization" ]; then
            echo "Do Precustomization tasks"
        elif [ x$1 = x"postcustomization" ]; then
            echo "Do Postcustomization tasks"
            yum update -y
        fi
    interfaces:
    - adapter:
        ipv4:
          type: STATIC
          gateways:
          - 10,10,10,1
          ip_address: 10.10.10.13
          prefix: 24
    global_DNS_settings:
      dns_suffix_list: []
      dns_servers:
      - 10.10.10.10
  register: post_customization_info
- name: Print customization  status
  debug:
    var: post_customization_info

mani611 avatar Feb 09 '24 08:02 mani611