title: How to get variables from ansible result
body: <p>I have a shell script whose output is an echo of the following format<br>
  <code>&lt;variable_1&gt;;&lt;variable_2&gt;;&lt;variable_3&gt;</code> etc</p>
  
  <p>I want to use these variables and run a mysql query to update a DB like so<br>
  <code>mysql -u&lt;user&gt; -p&lt;password&gt; -h&lt;host&gt; -e'insert into test_table values ("variable_1","variable_2","variable_3")'</code></p>
  
  <p>My ansible playbook looks like this. </p>
  
  <pre><code>---
  - hosts: infoServers
    sudo: yes
    gather_facts: no
    tasks:
    - name: gather info
      script: get_hostdata.sh
      register: result
    - name: print result
      local_action: command mysql -uuser -ppassword -h192.168.101.10 ansible_db -e'insert into test_table values ("{{ item[0] }}","{{ item[1] }}","{{ item[3] }});'
      with_items: [ result.stdout.split(';')[0], result.stdout.split(';')[1], result.stdout.split(';')[2] ]
  </code></pre>
  
  <p>ERROR: Syntax Error while loading YAML script, test_variables.yml</p>
  
  <p>Basically i want to be able to use the output of a shell command, split it into some variables and be able to use those in further ansible actions.
  Can you please guide me on how to access the variables correctly?</p>
  
  <p>Thank you</p>