title: ANSIBLE_ROLES_PATH cannot assume to get correct role in bash script
body: <p>From <a href="https://stackoverflow.com/questions/38350674/ansible-can-i-execute-role-from-command-line">Ansible: Can I execute role from command line?</a> -</p>
  <pre><code>HOST_PATTERN=$1
  shift
  ROLE=$1
  shift
  
  echo &quot;To apply role \&quot;$ROLE\&quot; to host/group \&quot;$HOST_PATTERN\&quot;...&quot;
  
  export ANSIBLE_ROLES_PATH=&quot;$(pwd)/roles&quot;
  export ANSIBLE_RETRY_FILES_ENABLED=&quot;False&quot;
  
  ANSIBLE_ROLES_PATH=&quot;$(pwd)/roles&quot; ansible-playbook &quot;$@&quot; /dev/stdin &lt;&lt;END
  ---
  - hosts: $HOST_PATTERN
    roles:
      - $ROLE
  END
  </code></pre>
  <p>Problem is when I run with <code>./apply.sh all dev-role -i dev-inventory</code>, it cannot assume the correct role. When I run with <code>ansible-playbook -i dev-inventory site.yml --tags dev-role</code>, it's working.</p>
  <p>Below is error message</p>
  <pre><code>fatal: [my-api]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;checksum_dest&quot;: null, &quot;checksum_src&quot;: &quot;d3a0ae8f3b45a0a7906d1be7027302a8b5ee07a0&quot;, &quot;dest&quot;: &quot;/tmp/install-amazon2-td-agent4.sh&quot;, &quot;elapsed&quot;: 0, &quot;gid&quot;: 0, &quot;group&quot;: &quot;root&quot;, &quot;mode&quot;: &quot;0644&quot;, &quot;msg&quot;: &quot;Destination /tmp/install-amazon2-td-agent4.sh is not writable&quot;, &quot;owner&quot;: &quot;root&quot;, &quot;size&quot;: 838, &quot;src&quot;: &quot;/home/ec2-user/.ansible/tmp/ansible-tmp-1600788856.749975-487-237398580935180/tmpobyegc&quot;, &quot;state&quot;: &quot;file&quot;, &quot;uid&quot;: 0, &quot;url&quot;: &quot;https://toolbelt.treasuredata.com/sh/install-amazon2-td-agent4.sh&quot;}
  </code></pre>