This is my playbook,
---
- hosts: alpha
vars:
company: vogo
tasks:
- name: debugging
debug:
msg: "{{ansible_hostname}}"
vars_prompt:
- name: "company"
prompt: "Where do you work"
private: no
- hosts: webservers
vars_prompt:
- name: "fathercompany"
prompt: "Where your father works"
private: no
tasks:
- name: test
debug:
msg: just testing "{{company2}}"
Here are the steps of execution flow when I run the playbook,
1 - prompt 1 (Where do you work)
2 - task debugging
3 - prompt 2 (Where your father works)
4 - task test
I have some questions.
First, When I run this playbook, the task "debugging" should run first and then the prompt should ask for the company name. But, when I run this playbook, at the very first step, it asks for "Where do you work ?". Why prompt first ? Am I missing some kind of paramater which I should have passed ?
Second, I have put 2 prompts here,
I want to use the prompt value company
, in the webservers
host block. But it gives me error when I try to do that.
Cannot I use the prompt value from one host block into another ?
Third,
How can I use prompts in roles ?