- name: Run Python Script with External Functions hosts: localhost gather_facts: no tasks: - name: Ensure required Python packages are installed pip: requirements: requirements.txt - name: Run the Python script command: python3 scripts/my_script.py register: script_output - name: Show script output debug: msg: "{{ script_output.stdout }}"