我寫了一本簡單的書籍master.yml,主要功能是查找角色並輸入一個作爲第二個劇本的輸入。但是,儘管我使用了var_prompt角色,但它並不提示變量。var_prompt可以包含在角色中嗎?
--- #master.yml
- name: show roles.
hosts: nodes
connection: ssh
gather_facts: no
tasks:
- include: showroles.yml
- name: createdb and map roles.
hosts: nodes
connection: ssh
gather_facts: no
roles:
- vars_prompt_role
tasks:
- include: createdb.yml
我的目錄結構如下:
/playbooks/createdbandmaprole/
[[email protected] createdbandmaprole]$ ls
createdb.yml hosts master.yml roles script.sql.j2 showroles.yml
[[email protected] createdbandmaprole]$cd roles
[[email protected] roles]$ ls
var_prompt_role
[[email protected] roles]$ cd var_prompt_role/
[[email protected] var_prompt_role]$ ls
defaults handlers library main.yml meta tasks vars
[[email protected] var_prompt_role]$ vim main.yml
vars_prompt:
- name: "database"
prompt: "enter the name of database"
private: no
- name: "role"
prompt: "enter the name of role"
private: no
- name: "ad_group"
prompt: "enter the AD_Group"
private: no
[[email protected] createdbandmaprole]$ ansible-playbook master.yml -i hosts --check
,但它不會提示瓦爾
標題中的問題與內容有什麼關係? – techraf