I have a playbook for building VMware VMs using the Ansible vmware_guest module. This module requires the RAM value to be a integer and in MB.
I have a template in Ansible Tower that allows me to pass the value for RAM as an integer and my playbook does the maths. I think this is based on Jinja maths. Here's the link I found for maths - How to use arithmetic when setting a variable value in Ansible?
This is the variable in my playbook memory_mb: "{{ VM_RAM * 1024 }}". When using Ansible Tower this works perfectly. A user can ask for 8GB of RAM and the playbook does the conversion from GB to MB.
I currently have a requirement to build VMs from an ad-hoc command. I believe the command below should work, but it seems the "VM_RAM" variable is being picked up as a string. Running the command gives me an error - "msg": "A specified parameter was not correct: configSpec.memoryMB".
ansible-playbook vm-build.yml --extra-vars '{"VM_name":"new-vm", "VM_HDD2":"10", "VM_CPU":"4", "VM_RAM":"8"}'
Can anyone see where I am mistaken, or have any suggestions? I should add, I don't want to do the conversion in the ad-hoc command. Can I force the ad-hoc command to use a integer?
Thanks.