From 1f8ccaff5e131dbd6caeba26986943062404d1d5 Mon Sep 17 00:00:00 2001 From: Justin Cinkelj Date: Thu, 13 Apr 2023 10:51:40 +0200 Subject: [PATCH] Fix python interpreter for check_local_time.py script https://github.com/ScaleComputing/HyperCoreAnsibleCollection/actions/runs/4686722374/jobs/8305135195#step:9:48 Here ansible_python_interpreter was not defined. See also https://github.com/ansible/ansible/issues/21311 and https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html I missed before that ansible_python_interpreter is not always defined. We do not want to force user to tell us some valid python interpreter. Also, it would be possible that the only availble python is in venv or in /usr/local/bin (python docker images). ansible_playbook_python looks like a suitable fallback. It is interpreter on the controller node. Our script will always run there - we never ssh to HyperCore controller. Signed-off-by: Justin Cinkelj --- roles/check_local_time/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/check_local_time/tasks/main.yml b/roles/check_local_time/tasks/main.yml index facef7896..8e000f2ad 100644 --- a/roles/check_local_time/tasks/main.yml +++ b/roles/check_local_time/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Check if local time is in time interval (run check_local_time.py) ansible.builtin.script: - executable: "{{ ansible_python_interpreter }}" + executable: "{{ ansible_python_interpreter | default(ansible_playbook_python) }}" cmd: check_local_time.py "{{ time_zone }}" "{{ time_interval }}" register: local_time_output