hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.21k stars 4.43k forks source link

provisioner/ansible: Fix ansible version gathering in host provisioner #13375

Closed patrickpoortman closed 2 months ago

patrickpoortman commented 6 months ago

When not forcing ansible.compatibility_mode, Vagrant tries to gather the Ansible version using the gather_ansible_version function.

This seems to be incorrectly quoted / escaped.

Fixes https://github.com/hashicorp/vagrant/issues/13234

The noted fix from the issue is being implemented in this PR.

Before:

 vagrant provision
==> hostname: Running provisioner: ansible...
Vagrant gathered an unknown Ansible version:

and falls back on the compatibility mode '1.8'.

after:

 vagrant provision
==> hostname: Running provisioner: ansible...
    hostname: Running ansible-playbook...

Tested with the following versions on MacOS; ansible [core 2.15.8] python version = 3.9.16 Vagrant 2.4.1 and Vagrant 2.4.0

Python 3.9.16 (main, Jun  6 2023, 11:35:35)
[Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib.metadata; print('ansible ' + importlib.metadata.version('ansible'))
ansible 8.7.0
>>> import importlib.metadata; print('ansible ' + importlib.metadata.version('ansible-core'))
ansible 2.15.8
hashicorp-cla commented 6 months ago

CLA assistant check
All committers have signed the CLA.