Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double digits Ansible version match #13493

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robinmulder
Copy link

@robinmulder robinmulder commented Aug 26, 2024

Vagrant does an Ansible version check in the Ansible provisioner to determine which compatibility mode to use. The latest version of Ansible is Ansible 10 and this check fails in Vagrant when using Ansible 10.

% python3 -c "import importlib.metadata; print('ansible ' + importlib.metadata.version('ansible'))"
ansible 10.3.0

This is the first time that double digits are used in an Ansible major version. The regex that is used to determine the major version in Vagrant only checks a single digit. So in this case it matches to 0, which in turn will trigger compatibility mode 1.8 instead of 2.0. Compatibility mode 1.8 uses sudo in the command, instead of become which is needed by recent Ansible versions.

% vagrant provision
==> server01.exonetcloud.nl: Running provisioner: ansible...
    server01.exonetcloud.nl: Running ansible-playbook...
usage: ansible-playbook [-h] [--version] [-v] [--private-key PRIVATE_KEY_FILE]
                        [-u REMOTE_USER] [-c CONNECTION] [-T TIMEOUT]
                        [--ssh-common-args SSH_COMMON_ARGS]
                        [--sftp-extra-args SFTP_EXTRA_ARGS]
                        [--scp-extra-args SCP_EXTRA_ARGS]
                        [--ssh-extra-args SSH_EXTRA_ARGS]
                        [-k | --connection-password-file CONNECTION_PASSWORD_FILE]
                        [--force-handlers] [--flush-cache] [-b]
                        [--become-method BECOME_METHOD]
                        [--become-user BECOME_USER]
                        [-K | --become-password-file BECOME_PASSWORD_FILE]
                        [-t TAGS] [--skip-tags SKIP_TAGS] [-C] [-D]
                        [-i INVENTORY] [--list-hosts] [-l SUBSET]
                        [-e EXTRA_VARS] [--vault-id VAULT_IDS]
                        [-J | --vault-password-file VAULT_PASSWORD_FILES]
                        [-f FORKS] [-M MODULE_PATH] [--syntax-check]
                        [--list-tasks] [--list-tags] [--step]
                        [--start-at-task START_AT_TASK]
                        playbook [playbook ...]
ansible-playbook: error: unrecognized arguments: --sudo

This PR updates the regex to check all digits before the first dot, so the major version is set to 10 instead of 0 and the correct compatibility mode is selected.

Copy link

hashicorp-cla-app bot commented Aug 26, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@robinmulder
Copy link
Author

Not sure why there is a 2nd CLA message. I've signed the CLA as indicated by the first message and the status check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants