title: Ansible: How to 'read_csv' into a dynamic variable name?
body: <p>I'm trying to read from a list of CSV files (fileglob) and the files have a standard naming convention. Just wanted to read the CSV files using <code>read_csv</code> and <code>register</code>/<code>set_fact</code> them to the filename, which should be the variable name.</p>
  <p>The files are</p>
  <pre><code>apples.csv
  pears.csv
  grapes.csv
  </code></pre>
  <p>What I've tried, (its close but not correct)</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: &quot;Read into dynamic variables&quot;
    read_csv:
      path: &quot;{{ item }}&quot;
    with_fileglob:
      - &quot;/tmp/fruits/*.csv&quot;
    fruit_name: &quot;{{ item | basename | regex_replace('.csv') }}&quot;
    register: &quot;fruit_{{ fruit_name }}&quot;
  </code></pre>
  <p>So ideally want to get the contents of each CSV to be part of variable, e.g. <code>fruit_apples</code> which can be later re-used in other plays.</p>