1

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
4
  • 1
    Try changing this line: chdir: '{{ role_path }}/files' Commented Sep 26, 2016 at 12:46
  • what do u mean ? what i should be placing there? Commented Sep 26, 2016 at 12:47
  • 1
    Delete the double quotes " surrounding {{ role_path }} Commented Sep 26, 2016 at 12:48
  • oh cool okay , got it Commented Sep 26, 2016 at 12:49

1 Answer 1

2

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!

Sign up to request clarification or add additional context in comments.

3 Comments

nice , just a question more. How should i wait for my python script to get it executed
I'm not sure I understand what you mean, but this task sshould cd to the files directory, execute the file, and wait until it finishes
yes but then it doesn't pics the variable that i mapped from default/main.yml to files/sample.yml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.