# vmware provisioning, finding information based on variables

**URL:** <https://forum.ansible.com/t/vmware-provisioning-finding-information-based-on-variables/26116>\
**Category:** Ansible Developer\
**Tags:** vmware, rhel, awx\
**Created:** [November 23, 2017, 11:46am UTC](https://forum.ansible.com/t/vmware-provisioning-finding-information-based-on-variables/26116 "2017-11-23T11:46:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkempster22uu](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@mkempster22uu](https://forum.ansible.com/u/mkempster22uu)\
**Post date:** [November 23, 2017, 11:46am UTC](https://forum.ansible.com/t/vmware-provisioning-finding-information-based-on-variables/26116/1 "2017-11-23T11:46:47Z")

</div>

I’ve setup a way to provision a RHEL VM from a template using the VMware\_guest module (shown below) I’m now trying to figure out away of shortening the AWX/Tower survey I have so that the user doesn’t need to add so much info. (We currently have a script that provisions that is very bespoke and can do stuff like find the VLAN name from the IP given probably from vSphere API etc.)

The first item I would like to shorten is using the IP submitted via the survey then using some method to match that to a VLAN name, whether that’s through vSphere API, or a Vars list or anything else i’m quite stuck.  
Does anyone have any ideas to do this or any other tasks to reduce the amount of info required?

Our current script only needs: cluster name, size of VM (1\_2 for 1 CPU, 2 GB memory), hostname, IP, folder to store in and vSphere credntials

Playbook:

- name: Create VM from template  
vmware\_guest:  
validate\_certs: False  
hostname: “{{ vcenter\_hostname }}”  
username: “{{ vcenter\_user }}”  
password: “{{ vcenter\_pass }}”  
cluster: “{{ cluster }}”  
folder: “{{ folder }}”  
datacenter: DCA  
name: “{{ vm\_name }}”  
template: “{{ vmtemplate }}”  
disk:
- size\_gb: 50  
type: thin  
datastore: “{{ datastore }}”  
networks:
- name: “{{ network }}”  
device\_type: vmxnet3  
ip: “{{ vm\_ip }}”  
netmask: “{{ netmask }}”  
gateway: “{{ gateway }}”  
hardware:  
num\_cpus: “{{ vm\_cpu }}”  
memory\_mb: “{{ vm\_memory }}”  
wait\_for\_ip\_address: True  
state: present  
register: newvm
