# need help in passing external variables using vars\_prompt

**URL:** <https://forum.ansible.com/t/need-help-in-passing-external-variables-using-vars-prompt/37679>\
**Category:** Ansible Project\
**Created:** [February 20, 2023, 5:29pm UTC](https://forum.ansible.com/t/need-help-in-passing-external-variables-using-vars-prompt/37679 "2023-02-20T17:29:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenady\_Inampudi](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@Kenady\_Inampudi](https://forum.ansible.com/u/Kenady_Inampudi)\
**Post date:** [February 20, 2023, 5:29pm UTC](https://forum.ansible.com/t/need-help-in-passing-external-variables-using-vars-prompt/37679/1 "2023-02-20T17:29:45Z")

</div>

need help in passing external variables using vars\_prompt

working example i have a list of servers in a vars\_file lparlist.yml

i need to use vars\_prompt so i can provide the server name without editing the playbook every time

working example

**inventory**  
cat inventory  
[hmc]  
hmc1  
hmc2

**vars\_file**  
cat lparlist.yml

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [February 20, 2023, 8:04pm UTC](https://forum.ansible.com/t/need-help-in-passing-external-variables-using-vars-prompt/37679/2 "2023-02-20T20:04:30Z")

</div>

You’re getting your “target” variable from vars\_prompt just fine. It’s a ‘unicode object’ (i.e. a string), so you can’t use its non-existent ‘ms’ attribute. If you really want to pull in the “target” host interactively, the easiest fix is to restructure your “lparlist.yml” file like this:

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [February 20, 2023, 8:23pm UTC](https://forum.ansible.com/t/need-help-in-passing-external-variables-using-vars-prompt/37679/3 "2023-02-20T20:23:11Z")

</div>

Another solution is to use the “vars” lookup with your vars\_prompt for “target” as you showed them above.

- name: Start a logical partition.  
powervm\_lpar\_instance:  
hmc\_host: “{{ lookup(‘vars’,target).hmc }}”  
hmc\_auth: “{{ curr\_hmc\_auth }}”  
system\_name: “{{ lookup(‘vars’,target).ms }}”  
vm\_name: “{{ target }}”  
action: poweron
