# Setting custom advanced configuration parameters in VMware VM when deploying via Ansible

**URL:** <https://forum.ansible.com/t/setting-custom-advanced-configuration-parameters-in-vmware-vm-when-deploying-via-ansible/24686>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [June 8, 2017, 8:24pm UTC](https://forum.ansible.com/t/setting-custom-advanced-configuration-parameters-in-vmware-vm-when-deploying-via-ansible/24686 "2017-06-08T20:24:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![James5](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@James5](https://forum.ansible.com/u/James5)\
**Post date:** [June 8, 2017, 8:24pm UTC](https://forum.ansible.com/t/setting-custom-advanced-configuration-parameters-in-vmware-vm-when-deploying-via-ansible/24686/1 "2017-06-08T20:24:14Z")

</div>

I am trying to deploy a virtual machine via ansible and vcenter using the vmware\_guest module and I need to pass additional custom parameters to the VM (vmx file). I am using the custom values attribute to do this as it seems to be the correct way but I just cannot get it to work. It always complains about the contents of the (first) key field and ignores all additional options.

The aim is to pass a number of items:

machine.id = “Something”

serial0.present = TRUE

etc

into the vmx file of the created VM (doing it manually via the file itself or using the vcenter GUI works fine of course).

This is what I have in ansible:

- hosts: guestnames

gather\_facts: no

vars\_files:

- vars.yml

tasks:

- name: Create guests

vmware\_guest:

hostname: “{{ vcenter\_host }}”

username: “{{ vcenter\_username }}”

password: “{{ vcenter\_password }}”

validate\_certs: no

esxi\_hostname: “{{ esxi\_ip }}”

datacenter: datacenter

name: “{{ inventory\_hostname }}”

guest\_id: otherGuest64

state: poweredoff

template: my-template

customvalues:

- “key”: “machine.id”

“value”: “test”

- “key”: “serial0.present”

“value”: “TRUE”

disk:

- size\_gb: 5

type: thin

datastore: datastore1-{{hypervisorname}}

hardware:

memory\_mb: 4096

num\_cpus: 4

delegate\_to: localhost

register: deploy

- debug:

var: deploy

- name: Show facts

vmware\_guest\_facts:

hostname: “{{ vcenter\_host }}”

username: “{{ vcenter\_username }}”

password: “{{ vcenter\_password }}”

datacenter: datacenter

validate\_certs: no

name: “{{ inventory\_hostname }}”

delegate\_to: localhost

register: facts

- debug:

var: facts

And this is the output:

PLAYBOOK: start.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

1 plays in start.yml

PLAY [guestnames] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

META: ran handlers

TASK [Create guest] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [test16 → localhost]: FAILED! =\> {

“changed”: false,

“failed”: true,

“invocation”: {

“module\_args”: {

“annotation”: null,

“cluster”: null,

“customization”: {},

“customvalues”: [

{

“key”: “machine.id”,

“value”: “test”

},

{

“key”: “serial0.present”,

“value”: “TRUE”

}

],

“datacenter”: “datacenter”,

“disk”: [

{

“datastore”: “datastore1-robbins”,

“size\_gb”: 5,

“type”: “thin”

}

],

“esxi\_hostname”: “10.10.10.10”,

“folder”: “/vm”,

“force”: false,

“guest\_id”: “otherGuest64”,

“hardware”: {

“memory\_mb”: 4096,

“num\_cpus”: 4

},

“hostname”: “20.20.20.20”,

“is\_template”: false,

“name”: “test16”,

“name\_match”: “first”,

“networks”: ,

“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

“resource\_pool”: null,

“state”: “poweredoff”,

“template”: “my-template”,

“template\_src”: “my-template”,

“username”: “administrator@vsphere.local”,

“uuid”: null,

“validate\_certs”: false,

“wait\_for\_ip\_address”: false

}

},

“msg”: “Failed to set custom value for key=‘machine.id’ and value=‘test’. Error was: (vmodl.fault.InvalidArgument) {\n dynamicType = ,\n dynamicProperty = (vmodl.DynamicProperty) ,\n msg = ‘A specified parameter was not correct: key’,\n faultCause = ,\n faultMessage = (vmodl.LocalizableMessage) ,\n invalidProperty = u’key’\n}”

}

fatal: [test15 → localhost]: FAILED! =\> {

“changed”: false,

“failed”: true,

“invocation”: {

“module\_args”: {

“annotation”: null,

“cluster”: null,

“customization”: {},

“customvalues”: [

{

“key”: “machine.id”,

“value”: “test”

},

{

“key”: “serial0.present”,

“value”: “TRUE”

}

],

“datacenter”: “datacenter”,

“disk”: [

{

“datastore”: “datastore1-robbins”,

“size\_gb”: 5,

“type”: “thin”

}

],

“esxi\_hostname”: “10.10.10.10”,

“folder”: “/vm”,

“force”: false,

“guest\_id”: “otherGuest64”,

“hardware”: {

“memory\_mb”: 4096,

“num\_cpus”: 4

},

“hostname”: “20.20.20.20”,

“is\_template”: false,

“name”: “test15”,

“name\_match”: “first”,

“networks”: ,

“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

“resource\_pool”: null,

“state”: “poweredoff”,

“template”: “my-template”,

“template\_src”: “my-template”,

“username”: “administrator@vsphere.local”,

“uuid”: null,

“validate\_certs”: false,

“wait\_for\_ip\_address”: false

}

},

“msg”: “Failed to set custom value for key=‘machine.id’ and value=‘test’. Error was: (vmodl.fault.InvalidArgument) {\n dynamicType = ,\n dynamicProperty = (vmodl.DynamicProperty) ,\n msg = ‘A specified parameter was not correct: key’,\n faultCause = ,\n faultMessage = (vmodl.LocalizableMessage) ,\n invalidProperty = u’key’\n}”

}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

test15 : ok=0 changed=0 unreachable=0 failed=1

test16 : ok=0 changed=0 unreachable=0 failed=1

Any ideas?

---

<div class="post-metadata">

**Author:** ![Jackson\_Pollock](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@Jackson\_Pollock](https://forum.ansible.com/u/Jackson_Pollock)\
**Post date:** [October 23, 2017, 6:57pm UTC](https://forum.ansible.com/t/setting-custom-advanced-configuration-parameters-in-vmware-vm-when-deploying-via-ansible/24686/2 "2017-10-23T18:57:17Z")

</div>

I have exactly the same problem, was there every a fix?

thanks!
