[Answered ]-Running a Python function from Ansible script

2👍

There’s --command switch for shell django-admin command.

So you can try in Ansible:

- name: Fetch data
  command: "django-admin shell --command='from tmp_file import feth_data; fetch_data()'"
  args:
    chdir: /path/to/tmp_file

Leave a comment