Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Malformed Ansible Version #2166

Closed
philip-elevated opened this issue May 26, 2021 · 11 comments
Closed

Malformed Ansible Version #2166

philip-elevated opened this issue May 26, 2021 · 11 comments
Labels

Comments

@philip-elevated
Copy link

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 2.2.16
VirtualBox 6.1.22r144080
ansible [core 2.11.1]
  config file = None
  configured module search path = ['/Users/chris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/chris/.ansible/collections:/usr/share/ansible/collections
  executable location = /Library/Frameworks/Python.framework/Versions/3.9/bin/ansible
  python version = 3.9.0 (v3.9.0:9cf6752276, Oct  5 2020, 11:29:23) [Clang 6.0 (clang-600.0.57)]
  jinja version = 3.0.1
  libyaml = True

Your OS

  • macOS (version)

Full console output

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /Users/chris/Sites/devdesktop/alliedtel-dev2/Vagrantfile
Line number: 0
Message: ArgumentError: Malformed version number string [core

Summary

I cannot seem to run vagrant up with newest version of Ansible. It appears as if the version number is displayed in brackets now?

@philip-elevated
Copy link
Author

I've tried using Ansible installed via pip3 as well as Ansible installed via HomeBrew.

@geerlingguy
Copy link
Owner

It looks like the error is showing you have an issue with the Vagrantfile?

Path: /Users/chris/Sites/devdesktop/alliedtel-dev2/Vagrantfile
Line number: 0
Message: ArgumentError: Malformed version number string [core

The first line there?

@philip-elevated
Copy link
Author

@geerlingguy - I'm using a Composer managed version of DrupalVM, so my Vagrantfile simply references that and custom config.

Vagrantfile:

# The absolute path to the root directory of the project.
ENV['DRUPALVM_PROJECT_ROOT'] = "#{__dir__}"

# The relative path from the project root to the VM config directory.
ENV['DRUPALVM_CONFIG_DIR'] = "settings"

# The relative path from the project root to the Drupal VM directory.
ENV['DRUPALVM_DIR'] = "vendor/geerlingguy/drupal-vm"

# Load the real Vagrantfile
load "#{__dir__}/#{ENV['DRUPALVM_DIR']}/Vagrantfile"

Custom config

##
# DrupalVM Overrides
# - 01 - Vagrant Settings
# - 02 - Drupal Settings
# - 03 - Installed Extras
# - 04 - PHP Settings
##

# 01 - Vagrant Settings
vagrant_project_name: ats
vagrant_ip: 192.168.87.87
vagrant_hostname: 'ats.dvm'
vagrant_machine_name: '{{ vagrant_project_name }}'
vagrant_synced_folders:
  - local_path: .
    destination: '/var/www/{{ vagrant_project_name }}'
    type: nfs
    create: true

# 02 - Drupal Settings
drupal_composer_install_dir: '/var/www/{{ vagrant_project_name }}'
drupal_build_composer_project: false
drupal_install_site: false
drupal_core_path: '{{ drupal_composer_install_dir }}/docroot'

# 03 - Installed Extras
installed_extras:
  - adminer
  - drush
  - mailhog
  - memcached
  - varnish
  - xdebug

# 04 - PHP Settings
php_version: "7.4"
php_memory_limit: "512M"

@phizev
Copy link
Contributor

phizev commented May 26, 2021

@geerlingguy I think Ansible has changed the way it outputs it's version string in the newest versions, and Vagrant does not properly parse it. A colleague had this error today, and used force_ansible_local: true as a workaround.

ansible 2.9.6
# Contrasted to the output above:
ansible [core 2.11.1]

@lorenswendsen
Copy link

I'm getting the same error as well. Didn't know if it was from Ansible or the Apple updates from Monday (May 24). I did update Ansible yesterday too, via Homebrew.

@phizev
Copy link
Contributor

phizev commented May 26, 2021

I have just had a look around, and I can't seem to find an existing bug report for this anywhere on an upstream project. I would expect more users will be affected as they upgrade/install ansible, I'd assume that this would affect Linux users too.

@geerlingguy
Copy link
Owner

Ah... then yes, this is a bug in the version comparison:

# Require that if installed, the ansible version meets the requirements.
def require_ansible_version(requirement)
return unless ansible_bin
req = Gem::Requirement.new(requirement)
return if req.satisfied_by?(Gem::Version.new(ansible_version))
raise_message "You must install an Ansible version #{requirement} to use this version of Drupal VM."
end

Also note that ansible-core may or may not be enough to get this thing working. For Ansible 2.9 to 3.0 or 4.0, you need to do a full pip uninstall ansible ansible-core ansible-base before reinstalling it, otherwise the dependencies get screwed up.

@geerlingguy
Copy link
Owner

A quick fix is to override the minimum ansible version (https://github.com/geerlingguy/drupal-vm/blob/master/default.config.yml#L53):

drupalvm_ansible_version_min: '2.1'

See if that works?

oxyc added a commit to oxyc/drupal-vm that referenced this issue May 27, 2021
@oxyc
Copy link
Collaborator

oxyc commented May 27, 2021

Could you try out #2167?

It should work for all version strings unless a random number was introduced before the version number.

ansible 2.1.3 # works
ansible 2.1.3-beta # works
ansible [core 2.13] # works
ansible 3 [core 3.13] # would not work

https://github.com/rubygems/rubygems/blob/v3.2.18/lib/rubygems/version.rb#L157

@Jake-Ryan
Copy link

Ran into this issue today after updating to vagrant 2.2.16, with ansible [core 2.11.0] on my host machine.
#2167 fixed the issue for me!

Cheers

geerlingguy added a commit that referenced this issue May 28, 2021
Issue #2166: Fix new ansible version output doesnt match regex
@geerlingguy
Copy link
Owner

Seems like that PR fixed it, thanks to @oxyc! I'll get this into the 6.0.4 release to be delivered...soonish.

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

No branches or pull requests

6 participants