简体   繁体   中英

unable to run a python script from localhost via ansible

I have my structure as :

playbooks_only 
    |
    |- read_replica_boto3.yml
    |- roles
         |
         |-read_replica_boto3
                 |-defaults
                 |-tasks-->> main.yml                      
                 |-files-->> - rds_read_replica_ops.py
                             - sample.yml

I need to run the rds_read_replica_ops.py , i wrote the following :

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

But this can't find the file and says:

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

You have a typo in this line:

    chdir: '"{{ role_path }}"/files'

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

    chdir: '{{ role_path }}/files'

And that should work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM