i need to use vars_prompt so i can provide the server name without editing the playbook every time
inventorycat inventory
[hmc]
hmc1
hmc2
vars_filecat lparlist.yml
---
- lpar1:
hmc: hmc1
ms: ms1
- lpar2:
hmc: hmc2
ms: ms2
actual playbook:---
- name: Start a logical partition
hosts: "{{ lpar1.hmc }}"
collections:
- ibm.power_hmc
connection: local
vars_files:
- lparlist.yml
vars:
curr_hmc_auth:
username: username
password: password
tasks:
- name: Start a logical partition.
powervm_lpar_instance:
hmc_host: "{{ lpar1.hmc }}"
hmc_auth: "{{ curr_hmc_auth }}"
system_name: "{{
lpar1.ms }}"
vm_name: lpar1
action: poweron
outputPLAY [Start a logical partition] *******************************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [hmc1]
TASK [Start a logical partition.] ******************************************************************************************************************************************************************************
changed: [hmc1]
PLAY RECAP ********************************************************************************************************************************************************************************************************
hmc1 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
not working playbook---
- name: Start a logical partition
hosts: "{{ lpar1.hmc }}"
vars_prompt:
- name: target
prompt: Enter Server Name
private: false
collections:
- ibm.power_hmc
connection: local
vars_files:
- lparlist.yml
vars:
curr_hmc_auth:
username: username
password: password
tasks:
- name: Start a logical partition.
powervm_lpar_instance:
hmc_host: "{{ target.hmc }}"
hmc_auth: "{{ curr_hmc_auth }}"
system_name: "{{
target.ms }}"
vm_name: "{{ target }}"
action: poweron
outputPLAY [Start a logical partition] *******************************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [hmc1]
TASK [Start a logical partition.] ******************************************************************************************************************************************************************************
fatal: [hmc1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'unicode object' has no attribute 'ms'\n\nThe error appears to be in '/home/inampk48/hmc/p3/poweron.yml': line 17, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:"\n - name: Start a logical partition.\n ^ here\n"}
PLAY RECAP ********************************************************************************************************************************************************************************************************
hmc1 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0