Using a variable as a default value in vars_prompt in Ansible
<p>I was trying to use <code>vars_prompt</code> in Ansible with default values taken from facts (or otherwise a previously defined variable). The playbook is intended be used as an ad-hoc one for initial provisioning.</p>

<p>My playbook:</p>

<pre><code>---
- hosts: server01
  gather_facts: True
  vars_prompt:
    - name: new_hostname
      prompt: please enter the name for the target
      default: "{{ ansible_hostname }}"
      private: no
  tasks:
    - debug: msg="{{ new_hostname }}"
</code></pre>

<p>Current result:</p>

<pre><code>please enter the name for the target [{{ ansible_hostname }}]:
ERROR! 'ansible_hostname' is undefined
</code></pre>

<p>Expected results (assuming <code>ansible_hostname=server01</code>:</p>

<pre><code>please enter the name for the target [server01]:
</code></pre>

<p>Is it possible to achieve in Ansible?</p>