---
- hosts: localhost
become: yes
gather_facts: no
tasks:
- name: delete file
ignore_errors: yes
file:
state: present
path: /root/ansible/inventory
vars_prompt:
- name: server_name
prompt: "Enter the server name:"
private: false
tasks:
- name: Add user input to file
lineinfile:
path: /root/ansible/inventory
line: "{{ server_name }}"
force: no
delegate_to: localhost
但是我想用角色,我不能用
vars_prompt
ansible 不会拿