Prompt variable working scope is inventory host scope or playbook scope?
Basically, variable is inventory host scope. But prompt vars seem not.
main.yml includes 1.yml and 2.yml.
1.yml creates prompt variable var1 and its target hosts are host1 and host2.
2.yml wants to use the var1 and its target host is host1.
I suppose 2.yml can get var1, but indeed not. Who can confirm it?
main.yml
---
- include: 1.yml
- include: 2.yml
1.yml
---
- name: test prompt
hosts: test
gather_facts: false
user: root
sudo: false
vars_prompt:
- name: "password"
prompt: "Please enter password"
private: yes
confirm: yes
tasks:
- action: debug msg="$password"
- action: shell echo -n $password
2.yml
---
- hosts: 192.168.126.143
user: root
sudo: false
tasks:
- action: shell echo -n $password
- action: template src=template.conf dest=/root/out.conf owner=root group=root mode=0644
template.conf
playbook execute result:
PLAY [test prompt] *********************
TASK: [debug msg="123"] *********************
ok: [192.168.126.143]
ok: [192.168.126.150]
TASK: [shell echo -n 123] *********************
changed: [192.168.126.150]
changed: [192.168.126.143]
PLAY [192.168.126.143] *********************
GATHERING FACTS *********************
ok: [192.168.126.143]
TASK: [shell echo -n $password] *********************
changed: [192.168.126.143]
TASK: [template src=template.conf dest=/root/out.conf owner=root group=root mode=0644] *********************
ok: [192.168.126.143]
PLAY RECAP *********************
192.168.126.143 : ok=5 changed=2 unreachable=0 failed=0
192.168.126.150 : ok=2 changed=1 unreachable=0 failed=0
In out.conf, there is nothing.