vars和vars_prompt的位置要和hosts同级

---
-
  hosts: centos6
  vars_prompt:
    -
      name: key
      prompt: "please input one value"
      private: yes
  vars:
    key: vars_key
  tasks:
    -
      name: show hostname
      shell: hostname
      register: info
    -
      name: show debug
      debug: msg="the hostname is {{ info['stdout'] }},the key is {{key}}"

你可能感兴趣的:(vars和vars_prompt的位置要和hosts同级)