Fix ansible major version extraction #13516
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on a test environment created with vagrant 2.4.1 and the ansible local provisioner I noticed that my provisioning was no longer working since ansible version
10
. See this issue for details.Error encountered
vagrant version
2.4.1
detects ansible version10.5.0
and then chooses ansible compatibility mode with version1.8
for some reason.Ansible then adds the no longer existing sudo flag and fails:
Root cause
Curious to the cause of this behavior I found a method that is extracting the ansible major version from a string. Now the regular expression apparently captures only the last digit of the first number before a dot. This is not exactly the intended behavior.
0
but it should resolve version10
This subsequently leads to vagrant dropping to a compatibility mode that fails the ansible playbook execution.
Since this is such a minor code change I thought a quick fix is highly appreciated. Looking forward to your thoughts and comments on this.