{"record":{"id":"b132635296c6383b","repo":"hashicorp/vagrant","slug":"the-requested-ansible-version-required-version-b13263","errorCode":null,"errorMessage":"The requested Ansible version (%{required_version}) was not found on the %{system}.\nPlease check the Ansible installation on your Vagrant %{system} system (currently: %{current_version}),\nor adapt the provisioner `version` option in your Vagrantfile.\nSee https://docs.vagrantup.com/v2/provisioning/ansible_common.html#version\nfor more information.","messagePattern":"The requested Ansible version \\(%(.+?)\\) was not found on the %(.+?)\\.\nPlease check the Ansible installation on your Vagrant %(.+?) system \\(currently: %(.+?)\\),\nor adapt the provisioner `version` option in your Vagrantfile\\.\nSee https://docs\\.vagrantup\\.com/v2/provisioning/ansible_common\\.html#version\nfor more information\\.","errorType":"exception","errorClass":"VagrantPlugins::Ansible::Errors.AnsibleVersionMismatch","httpStatus":null,"severity":"error","filePath":"plugins/provisioners/ansible/provisioner/host.rb","lineNumber":53,"sourceCode":"        VAGRANT_ARG_SEPARATOR = 'VAGRANT_ARG_SEP'\n\n        def warn_for_unsupported_platform\n          if Vagrant::Util::Platform.windows?\n            @machine.env.ui.warn(I18n.t(\"vagrant.provisioners.ansible.windows_not_supported_for_control_machine\") + \"\\n\")\n          end\n        end\n\n        def check_ansible_version_and_compatibility\n          # This step will also fetch the Ansible version data into related instance variables\n          set_and_check_compatibility_mode\n\n          # Skip this check when not required, nor possible\n          if !@gathered_version || config.version.empty? || config.version.to_s.to_sym == :latest\n            return\n          end\n\n          if config.version != @gathered_version\n            raise Ansible::Errors::AnsibleVersionMismatch,\n              system: @control_machine,\n              required_version: config.version,\n              current_version: @gathered_version\n          end\n        end\n\n        def prepare_command_arguments\n          # Connect with native OpenSSH client\n          # Other modes (e.g. paramiko) are not officially supported,\n          # but can be enabled via raw_arguments option.\n          @command_arguments << \"--connection=ssh\"\n\n          # Increase the SSH connection timeout, as the Ansible default value (10 seconds)\n          # is a bit demanding for some overloaded developer boxes. This is particularly\n          # helpful when additional virtual networks are configured, as their availability\n          # is not controlled during vagrant boot process.\n          @command_arguments << \"--timeout=30\"\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/provisioners/ansible/provisioner/host.rb#L35-L71","documentation":"For host-mode ansible provisioning, after resolving compatibility mode Vagrant compares config.version (when set and not :latest) with the ansible version detected on the host (via python importlib.metadata). Any difference raises AnsibleVersionMismatch. This guards against silently running playbooks with a different ansible than the Vagrantfile was written against.","triggerScenarios":"check_ansible_version_and_compatibility during `vagrant provision`/`up`: @gathered_version present, config.version non-empty and != :latest, and config.version != @gathered_version — e.g. version \"2.9.9\" pinned while the host has 2.9.27, or version pinned for guest-style installs while the host manages its own ansible.","commonSituations":"Team members with different host ansible versions sharing a pinned Vagrantfile; host ansible upgraded by brew/pip between runs; multiple pythons — vagrant probes one interpreter while PATH's `ansible` comes from another.","solutions":["Change `ansible.version` to the host's actual version, or set it to \"latest\" (host mode relies on the host install)","Or install exactly the pinned version on the host (pipx/pip: `pipx install ansible==<version>`)","Check which copy is detected: `python3 -c \"import importlib.metadata; print(importlib.metadata.version('ansible'))\"` with vagrant's environment","Coordinate the pin across the team via a shared requirements file for the host"],"exampleFix":"# Vagrantfile — before (host runs 8.6.1)\nansible.version = \"2.9.9\"\n# after\nansible.version = \"latest\"","handlingStrategy":"validation","validationCode":"installed = `python3 -c \"import importlib.metadata; print(importlib.metadata.version('ansible'))\" 2>/dev/null`.to_s\nrequired = '2.9.9' # the value you plan to set in the Vagrantfile\nabort 'host ansible != pinned version' unless required == 'latest' || required == installed.sub('ansible ', '')","typeGuard":"def host_ansible_version_matches?(required)\n  v = `python3 -c \"import importlib.metadata; print(importlib.metadata.version('ansible'))\" 2>/dev/null`.to_s.strip\n  required.to_s == 'latest' || required.to_s == v\nend","tryCatchPattern":null,"preventionTips":["Pin host ansible via pipx/venv in a bootstrap script rather than assuming a system version","Or leave ansible.version unset/\"latest\" for host-mode provisioning"],"tags":["ansible","provisioner","host","version-mismatch"],"backgroundTag":"ansible-version-mismatch","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}