title: how to run local command via ansible-playbook
body: <p>I am trying to run some local command, iterating over inventory file and taking each hostname as an argument to the local command.</p>
  
  <p>Eg: I wanted to run a command "knife node create {{ hostname }}" in my local machine(laptop). The playbook is:</p>
  
  <pre><code>- name: Prep node
    hosts: 127.0.0.1
    connection: local
    gather_facts: no
    tasks:
    - name: node create
      command: "knife node create {{ hostname | quote }}"
  </code></pre>
  
  <p>and my inventory file looks like:</p>
  
  <pre><code>[qa-hosts]
  10.10.10.11 hostname=example-server-1
  </code></pre>
  
  <p>Ofcourse, it wont work as the inventory has 'qa-hosts' and the play is for '127.0.0.1', as I wanted the play to run from my local machine.</p>
  
  <p>Would anyone help me with an idea how to get it done. Basically, I want get the variable 'hostname' and pass it to above play block.</p>