title: Ansible - apply variable in SQL query
body: <pre><code>- hosts: localhost
    vars_prompt:
    - name: " username"
      prompt: "What is merchant name?"
      private: no
      register: reg_name
    - name: "password"
      prompt:  "Enter password"
      private: yes
      encrypt: "sha256_crypt"
      confirm: yes
      salt_size: 16
      register: s
    tasks:
      - debug:
          var: password
        register: s
      - debug: var=s
  
  - name: update db
        shell : echo -n "insert into database (id, createdDate, updatedDate, username, sharedSecretHash) values (7, strftime('%s', 'now'), strftime('%s', 'now'), "{{ reg_name.stdout }}", "{{ s.stdout }}");" | sqlite3 /tmp/test.db
  
  
  FAILED! =&gt; {"msg": "The task includes an option with an undefined variable. The error was: 'reg_name' is undefined\n\nThe error appears to have been in '/home/ansible/prompt.yml': line 33, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: update db\n      ^ here\n\nexception type: &lt;class 'ansible.errors.AnsibleUndefinedVariable'&gt;\nexception: 'merchantname' is undefined"}
  fatal: [10.1.1.1: FAILED! =&gt; {"msg": "The task includes an option with an undefined variable. The error was: 'reg_ name' is undefined\n\The error appears to have been in '/home/ansible/prompt.yml': line 33, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: update db\n      ^ here\n\nexception type: &lt;class 'ansible.errors.AnsibleUndefinedVariable'&gt;\nexception: 'merchantname' is undefined"}
  </code></pre>
  
  <p>I registered variables with reg_name.stdout for username and s.stdout for password  and trying to apply it in sql query, it throws error - var undefined. Please suggest.</p>