Working With Ansible Prompts | Automation Using Ansible | DevOps Tool
Channel: The Unix Mantra
Date: 2019-05-25

Welcome to TheUnixMantra

In this video I have demonstrated the use of vars_prompt ansible feature. 

Reference Used: https://docs.ansible.com/ansible/latest/user_guide/playbooks_prompts.html

Playbook/Play:
---
- name: Play to demonstrate vars prompt feature
  hosts: vm1.theunixmantra.com
  gather_facts: no
  become: true
  vars_prompt:
     - name: username
       prompt: "Enter username:"
       private: no

     - name: user_password
       prompt: "Enter Password:"
       private: yes
       encrypt: sha512_crypt
       confirm: yes

  tasks:
     - name: Create user {{ username }}
       user:
         name: "{{ username }}"
         password: "{{ user_password }}"
...