title: Ansible - Read a file, extract specific line, extract a column and assign to variable
body: <p>I need some help with extracting a specific line from a file and then extracting a column,  assign it to a variable and then use that variable in the next task.</p>
  <p>I have the file with this format on the confluent broker server</p>
  <pre><code>Save the key. It cannot be retrieved later.
  +------------+----------------------------------------------+
  | Enc Key | omykeyvaluecontinuousstringgoeshereandmakelong= |
  +------------+----------------------------------------------+
  </code></pre>
  <p>I am trying to write Ansible task that will read the third line and then extract the key into  a variable which I need to export as an environment variable in the task.   In the next task I will be executing a confluent command as a shell command.</p>
  <p>I tried something like below, but it doesn't work - I get error</p>
  <pre><code>vars:
      ansible_ssh_extra_args: &quot;-o StrictHostKeyChecking=no&quot;
      ansible_host_key_checking: false
      contents: &quot;{{ lookup('file', '/etc/kafka/info.txt') }}&quot;
      contents2: &quot;{{ lookup('file', '/etc/kafka/info.txt').splitlines() }}&quot;
  
  - name: set fact
    set_fact:
      extract_key: &quot;{{ contents.split('\n')[2] }}&quot;
  
  - name: Display output
    debug: msg=&quot;{{ extract_key }}&quot;
  </code></pre>
  <p>And then extract the key value from extract_key variable</p>
  <p>How can I achieve this?</p>
  <p>Thank you</p>