title: Run several commands with Ansible
body: <p>I am using ansible 1.9 and want to run two commands. I have tried several variations:</p>
  
  <pre><code>- name: npm build
    command: npm run build
    args:
      chdir: "{{ app_dir }}"
  
  - name: clean up
    shell: sed_index.sh
    args:
      chdir: "{{ app_dir }}"
  </code></pre>
  
  <p>On running I get the following error:</p>
  
  <pre><code>"stderr": "/bin/sh: 1: npm: not found"
  </code></pre>
  
  <p>However </p>
  
  <pre><code>npm run build
  </code></pre>
  
  <p>works fine when I log in to the server and run it in the app_dir.</p>
  
  <p>I also tried:</p>
  
  <pre><code>- name: npm install and clean
    command: "{{ item }} chdir={{ app_dir }}"
      with_items:
        - npm run build
        - sed_index.sh
  </code></pre>
  
  <p>Again I get a npm not found error.</p>
  
  <p>If I comment out the npm run build command I get an error when running the sed_index script on the 'cd dist' command below, saying 'dist' not found.</p>
  
  <p>sed_index.sh</p>
  
  <pre><code>#!/usr/bin/env bash
  cd dist
  sed -i 's|=static/css/font-awesome.min.css rel=stylesheet&gt;|=/app/static/css/font-awesome.min.css rel=stylesheet&gt;|g' index.html
  </code></pre>
  
  <p>Any ideas?</p>