Make custom Gather facts run with default python for kayobe-target-venv

Fixes an issue introduced in I7cfb600eec268749ea1315112fe3a9429ab3ab8e.

This change make custom 'Gather facts' task for kayobe-target-venv run
with ``ansible_python_interpreter = /usr/bin/python3``.
This is to ensure custom 'Gather facts' can be run even when there was
no ansible facts gathered before.

Closes-Bug: #2112201
Change-Id: I2409428e7b929bec32c2b0034e82b4d03b343567
This commit is contained in:
Seunghun Lee
2025-05-30 17:03:44 +01:00
parent 2305e75c94
commit 9554ddd2d3

View File

@@ -21,14 +21,21 @@
- not ansible_python_interpreter.startswith('/bin')
- not ansible_python_interpreter.startswith('/usr/bin')
- block:
- name: Gather facts
setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
when: not ansible_facts
register: gather_facts
- name: Gather facts
setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
when:
- ansible_facts is undefined or not ansible_facts
- kayobe_virtualenv is defined
register: gather_facts
# Before any facts are gathered, ansible doesn't know about
# python virtualenv.
# Use default python3 to be safe for this task.
vars:
ansible_python_interpreter: /usr/bin/python3
- block:
- name: Ensure the Python venv package is installed on Debian family systems
package:
name: python3-venv