aboutsummaryrefslogtreecommitdiff
path: root/kolla_ansible
diff options
context:
space:
mode:
authorMichal Arbet <michal.arbet@ultimum.io>2025-05-15 01:25:31 +0200
committerMichal Arbet <michal.arbet@ultimum.io>2025-05-20 23:01:51 +0200
commit9c41becc8d499167a48aa5ae77d3e1282964ad61 (patch)
tree2489e94226f7d2be84eb29065a6e039a1358a1b6 /kolla_ansible
parentdcafed414532c88b776ebe57743c84e57e330d39 (diff)
downloadkolla-ansible-9c41becc8d499167a48aa5ae77d3e1282964ad61.tar.gz
kolla-ansible-9c41becc8d499167a48aa5ae77d3e1282964ad61.zip
Standardize Python interpreter handling
This patch ensures that the system Python interpreter is always used during the `bootstrap-servers` phase by setting `ansible_python_interpreter=auto_silent` via `extra_vars`, while the `octavia-certificates` command now explicitly uses the same Python interpreter that was used to invoke the `kolla-ansible` CLI, ensuring compatibility with the local environment. Summary: - The `ansible_python_interpreter` is now dynamically defined in `group_vars/all.yml`, falling back to the system interpreter if no virtualenv is configured. - CLI commands now detect and respect user-specified `ansible_python_interpreter` values via `-e`, and avoid overriding them. - The `bootstrap-servers` command always uses the system Python interpreter by setting `ansible_python_interpreter=auto_silent`, ensuring a clean environment for virtualenv creation. - The `octavia-certificates` command uses the Python interpreter that invoked the `kolla-ansible` CLI, ensuring compatibility with locally installed packages (e.g. cryptography). This improves interpreter handling across commands, especially in environments with custom Python setups or virtual environments. Depends-On: https://review.opendev.org/c/openstack/ansible-collection-kolla/+/949767 Change-Id: I7dc6cf8eda3b1fd48d2000f18b4670a4ef4ce1b4
Diffstat (limited to 'kolla_ansible')
-rw-r--r--kolla_ansible/cli/commands.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/kolla_ansible/cli/commands.py b/kolla_ansible/cli/commands.py
index fbfcf02fe..7f9ecde6b 100644
--- a/kolla_ansible/cli/commands.py
+++ b/kolla_ansible/cli/commands.py
@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import sys
+
from cliff.command import Command
from kolla_ansible import ansible
@@ -63,6 +65,14 @@ class KollaAnsibleMixin:
return verbosity_args
def run_playbooks(self, parsed_args, *args, **kwargs):
+ # If the user knows what they're doing and explicitly sets
+ # ansible_python_interpreter, respect their choice and avoid
+ # overriding it by kolla-ansible.
+ extra = kwargs.get("extra_vars", {})
+ for var in getattr(parsed_args, "extra_vars", []) or []:
+ if var.startswith("ansible_python_interpreter="):
+ extra.pop("ansible_python_interpreter", None)
+ break
kwargs.update(self._get_verbosity_args())
return ansible.run_playbooks(parsed_args, *args, **kwargs)
@@ -153,6 +163,7 @@ class BootstrapServers(KollaAnsibleMixin, Command):
extra_vars = {}
extra_vars["kolla_action"] = "bootstrap-servers"
+ extra_vars["ansible_python_interpreter"] = "auto_silent"
playbooks = _choose_playbooks(parsed_args, "kolla-host")
@@ -199,7 +210,9 @@ class OctaviaCertificates(KollaAnsibleMixin, Command):
return parser
def take_action(self, parsed_args):
- extra_vars = {}
+ extra_vars = {
+ "ansible_python_interpreter": sys.executable
+ }
if hasattr(parsed_args, "check_expiry") \
and parsed_args.check_expiry is not None: