Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify PYTHONPATH via Ansible for supervisorctl managed Python application

I am provisioning a server with a Django Stack via Ansible and getting the app from bitbucket, I am using https://github.com/jcalazan/ansible-django-stack, but I have had to tweak it a bit in order to make it work with a private bitbucket repo.

Now it's authenticating correctly but giving me the following error

failed: [default] => {"failed": true} msg: youtubeadl: ERROR (not running) youtubeadl: ERROR (abnormal termination)

When performing this task:

- name: Restart Supervisor
  supervisorctl: name={{ application_name }} state=restarted

Reading gunicorn ERROR (abnormal termination), I would like to add the project to the PYTHONPATH, any ideas how to approach this with an Ansible task, or am I missing something?

Thanks

like image 815
Alfonso Embid-Desmet Avatar asked Mar 16 '23 22:03

Alfonso Embid-Desmet


1 Answers

PYTHONPATH is just another environment variable, so you can use the best practices explained in the FAQ. If it's only needed for the one task, it'd look something like:

- name: Restart Supervisor
  supervisorctl: name={{ application_name }} state=restarted
  environment:
      PYTHONPATH: "{{ ansible_env.PYTHONPATH }}:/my/path"
like image 136
edunham Avatar answered Apr 25 '23 10:04

edunham