title: running an ansible local task in a remote playbook
body: <p>I'm trying to get this task to run locally (on the machine that is running the playbook) :</p>
  
  <pre><code>- name: get the local repo's branch name
    local_action: git branch | awk '/^\*/{print $2}'
    register: branchName
  </code></pre>
  
  <p>I tried plenty of variations with no success</p>
  
  <p>all other tasks are meant to run on the target host, which is why running the whole playbook local is not an option</p>
  
  <pre><code>TASK: [get the local repo's branch name] ************************************** 
  &lt;127.0.0.1&gt; REMOTE_MODULE git branch | awk '/^\*/{print $2}'
  &lt;127.0.0.1&gt; EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1407258765.57-75899426008172 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1407258765.57-75899426008172 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1407258765.57-75899426008172']
  &lt;127.0.0.1&gt; PUT /tmp/tmpQVocvw TO /home/max/.ansible/tmp/ansible-tmp-1407258765.57-75899426008172/git
  &lt;127.0.0.1&gt; EXEC ['/bin/sh', '-c', '/usr/bin/python /home/max/.ansible/tmp/ansible-tmp-1407258765.57-75899426008172/git; rm -rf /home/max/.ansible/tmp/ansible-tmp-1407258765.57-75899426008172/ &gt;/dev/null 2&gt;&amp;1']
  failed: [portal-dev] =&gt; {"failed": true}
  msg: this module requires key=value arguments (['branch', '|', 'awk', '/^\\*/{print $2}'])
  
  FATAL: all hosts have already failed -- aborting
  </code></pre>
  
  <h3>update:</h3>
  
  <p>I have followed bkan's suggestion (bellow), and got a bit further, but </p>
  
  <pre><code>  - name: get the local repo's branch name
      local_action: command git branch | (awk '/^\*/{print $2}')
      sudo: no
      register: branchName
  </code></pre>
  
  <p>now the git command gets launched but not correctly (see error below). </p>
  
  <p>note that this command runs perfectly as a "shell" but unfortunately there is no local_shell equivalent of local_action ...</p>
  
  <pre><code>failed: [portal-dev] =&gt; {"changed": true, "cmd": ["git", "branch", "|", "(awk", "/^\\*/{print $2})"], "delta": "0:00:00.002980", "end": "2014-08-05 18:00:01.293632", "rc": 129, "start": "2014-08-05 18:00:01.290652"}
  stderr: usage: git branch [options] [-r | -a] [--merged | --no-merged]
     or: git branch [options] [-l] [-f] &lt;branchname&gt; [&lt;start-point&gt;]
     or: git branch [options] [-r] (-d | -D) &lt;branchname&gt;...
     or: git branch [options] (-m | -M) [&lt;oldbranch&gt;] &lt;newbranch&gt;
  
  ...
  </code></pre>