# help with variable lookup

**URL:** <https://forum.ansible.com/t/help-with-variable-lookup/32163>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [February 6, 2020, 10:13pm UTC](https://forum.ansible.com/t/help-with-variable-lookup/32163 "2020-02-06T22:13:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Bullen](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@Jason\_Bullen](https://forum.ansible.com/u/Jason_Bullen)\
**Post date:** [February 6, 2020, 10:13pm UTC](https://forum.ansible.com/t/help-with-variable-lookup/32163/1 "2020-02-06T22:13:18Z")

</div>

I’m a greenhorn…I have this problem where I want the user to input either dev or prod in an env prompt then I take that and access a dictionary to get its custom properties. it works fine if I hardcode {{ dev.ip }} but if I do a lookup it says variable dev.ip not found.  
Also, let me know if there is a better way. Only gotcha is this if for networking so the target is always localhost and then it does api calls.

- hosts: localhost  
gather\_facts: no  
vars\_prompt:
- name: username  
prompt: “Username”
- name: password  
prompt: “Password”
- name: env  
prompt: “Environment”  
vars:  
prod:  
ip: ‘1.1.1.1’  
dev:  
ip: ‘10.130.155.53’
- name: Query tenant customer-xyz  
aci\_tenant:  
host: “{{ lookup(‘vars’, env + ‘.ip’) }}”  
#host: “{{ dev.ip }}”  
username: “{{ username }}”  
password: “{{password}}”  
state: present  
validate\_certs: false  
register: my\_tenant

fatal: [localhost]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable.  
The error was: No variable found with this name: dev.ip\n\nThe error appears to be in ‘/var/lib/awx/projects/aci-dev/querytenant.yml’:  
line 19, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  
var: host\n - name: Query tenant customer-xyz\n ^ here\n”}
