First, take note that according documentation Job Templation - Extra Variables
When you pass survey variables, they are passed as extra variables (
extra_vars) ...
Then, the question becomes "How to use Ansible extra variables with Python scripts?" and minimmal examples could look like Run Python script with arguments in Ansible.
---
- hosts: localhost
become: false
gather_facts: false
vars:
survey_input: test
tasks:
- name: Create example Python script
copy:
dest: survey.py
content: |
#!/usr/bin/python
import sys
print("arguments:", len(sys.argv))
print("first argument:", str(sys.argv[1]))
- name: Run example Python script
script: survey.py {{ survey_input }}
register: results
- name: Show result
debug:
msg: "{{ results.stdout }}"
It will result into an output of
TASK [Show result] *****
ok: [localhost] =>
msg: |-
arguments: 2
first argument: test
Further Q&A
Which might be interesting and help in this Use Case