need help in passing external variables using vars_prompt

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

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:

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