i need example on "postcustomization ansible vmware example" for collection vmware.vmware_rest.vcenter_vm_guest_customization
mani611 opened this issue · 3 comments
mani611 commented
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
oldguardmd commented
I have a similar problem. No combination I have tried works. Seems like this might be a bug?
- name: Test Native Ansible module
vmware.vmware_rest.vcenter_vm_guest_customization:
vcenter_hostname: "{{ vcenter_hostname }}"
vcenter_password: "{{ lookup('ansible.builtin.env', 'ANSIBLE_PASSWORD') }}"
vcenter_username: "{{ vcenter_user }}"
vcenter_validate_certs: false
vm: "{{ cloud_init_vm_id.vm }}"
configuration_spec:
linux_config:
domain: "something.com"
hostname:
fixed_name: "{{ current_vm.name }}"
type: FIXED
interfaces:
- adapter:
ipv4:
type: "DHCP"
global_DNS_settings:
dns_suffix_list: []
dns_servers:
- 1.1.1.1