title: ansible - read file, then randomly select entry
body: <p>I'm using Ansible 2.9.10.  I am trying to read a file in which consists of a list of items. I then want to choose 3 random items from this list.  I've tried several things (noted below) but cannot seem to figure this out.
  The file itemList is a list of items, one per line:</p>
  <pre><code>hammer
  saw
  wood
  .....
  </code></pre>
  <p>In the playbook I have:</p>
  <pre class="lang-yaml prettyprint-override"><code>vars:
    file_contents: &quot;{{ lookup('file', 'itemList') }}&quot;
  
  # Printing file contents returns &quot;widget\hammer\nsaw\nwood&quot;..... etc. 
  - name: Print file contents
    debug:
      msg: &quot;File contents are {{ file_contents }}&quot;
  
  # Now try to select one random item from file_contents
  - name: Select one random item
    debug:
      msg: &quot;item is {{ item }}&quot;
    with_random_choice: &quot;{{ file_contents }}&quot;
  </code></pre>
  <p>What am I missing?  It seems as though I am making it harder than it seems.  TIA</p>