title: Can I define variables in an ansible role/task file without a block?
body: <p>I have a role, which contains a file with tasks. A variable is used by all tasks in that file.</p>
  
  <pre><code>---
  vars:
    name: john
  
  - name: say hello
    debug:
      msg: "{{name}} says hello"
  
  - name: say goodbye
    debug:
      msg: "{{name}} says goodbye"
  </code></pre>
  
  <p>That doesn't work. But I can make it work by:</p>
  
  <ul>
  <li>moving everything into a <code>block</code></li>
  <li>using <code>set_fact</code>, but that leaks the variable to the entire playbook (not what I want)</li>
  </ul>
  
  <p><em>Can I somehow do this without a block?</em></p>
  
  <p>(I find the block-in-block-in-foo-in-bar messy, and sometimes I don't want to split into multiple files.)</p>