我试图vars_prompt
在 Ansible 中使用取自事实(或之前定义的变量)的默认值。该剧本旨在用作初始配置的临时剧本。
我的剧本:
---
- 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 }}"
Run Code Online (Sandbox Code Playgroud)
当前结果:
please enter the name for the target [{{ ansible_hostname }}]:
ERROR! 'ansible_hostname' is undefined
Run Code Online (Sandbox Code Playgroud)
预期结果(假设ansible_hostname=server01
:
please enter the name for the target [server01]:
Run Code Online (Sandbox Code Playgroud)
在Ansible中可以实现吗?
ansible ×1