unable to run a python script from localhost via ansible
<p>I have my structure as :</p>

<pre><code>playbooks_only 
    |
    |- read_replica_boto3.yml
    |- roles
         |
         |-read_replica_boto3
                 |-defaults
                 |-tasks--&gt;&gt; main.yml                      
                 |-files--&gt;&gt; - rds_read_replica_ops.py
                             - sample.yml
</code></pre>

<p>I need to run the rds_read_replica_ops.py , i wrote the following :</p>

<pre><code>- name: Create a cross-region replica using boto3 script
  command:  python rds_read_replica_ops.py sample.yml
  args:
    chdir: '"{{ role_path }}"/files'
</code></pre>

<p>But this can't find the file and says:</p>

<pre><code>sg: cannot change to directory '/home/blah/recovery/playbooks_only/"/home/blah/recovery/playbooks_only/roles/read_replica_boto3"/files': path does not exist

FATAL: all hosts have already failed -- aborting
</code></pre>

<p>You have a typo in this line:</p>

<pre><code>    chdir: '"{{ role_path }}"/files'
</code></pre>

<p>You shouldn't surround variables with quotes. Instead, change the line to:</p>

<pre><code>    chdir: '{{ role_path }}/files'
</code></pre>

<p>And that should work!</p>

python ansible ansible-playbook