title: How do you set up a confirmation prompt before running a task in a playbook?
body: <p>I want to install MariaDB after confirming user. I have a role and one simple task: </p>
  
  <pre><code>- name: install MariaDB
    yum:
      name: MariaDB
      state: present
  </code></pre>
  
  <p>or if I want to use <code>include: MySQL.yml</code>, if the user wants to, this line executes, if not skip this include.</p>
  
  <pre><code>- name: install MariaDB
    yum:
      name: MariaDB
      state: present
  
  - include: MySQL.yml
  </code></pre>
  
  <p><strong>more explain</strong></p>
  
  <p>my hosts:</p>
  
  <pre><code>[dbs]
  192.168.0.10
  192.168.0.11
  192.168.0.12
  </code></pre>
  
  <p>Now, I want if the user enters no for answer prompt, MySQL.yml does not execute for any server.</p>
  
  <p>my code in role (<code>tasks/main.yml</code>): </p>
  
  <pre><code>---
  - pause:
     prompt: "Do you want to install mariadb (yes/no)?"
    register: my_pause
    delegate_to: localhost
  
  - include_tasks: mysql.yml
    when: hostvars['localhost'].my_pause.user_input | bool
  </code></pre>
  
  <p>and my output :</p>
  
  <pre><code>[root@anisble ansible]# ansible-playbook playbooks/test.yml 
  
  
  
  PLAY [dbs] 
  ********************************************************************
  
  TASK [Gathering Facts] ******************************************************************
  ok: [db1]
  ok: [db2]
  ok: [db3]
  
  TASK [ssh : pause] ******************************************************************************
  [ssh : pause]
  Do you want to install mariadb (yes/no)?:
  no
    ok: [db1 -&gt; localhost]
  
  TASK [ssh : include_tasks] ***********************************************************************************
  included: /etc/ansible/roles/ssh/tasks/mysql.yml for db1, db2, db3
  
  TASK [ssh : install mariadb] ******************************************************************************
  ok: [db3]
  ok: [db2]
  ok: [db1]
  
  PLAY RECAP *****************************************************************************
  db1                        : ok=4    changed=0    unreachable=0    failed=0   
  db2                        : ok=3    changed=0    unreachable=0    failed=0   
  db3                        : ok=3    changed=0    unreachable=0    failed=0  
  </code></pre>