hashicorp / vagrant

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

Vagrant, ansible galaxy does not support git #11971

Open k6Q28k5w5eWuRuuzTg9j7GrKCbjt7 opened 4 years ago

k6Q28k5w5eWuRuuzTg9j7GrKCbjt7 commented 4 years ago

Vagrant version

Vagrant 2.2.10

Host operating system

Arch Linux 64bit

Guest operating system

debian/10

Vagrantfile

# # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
  config.vm.provider :virtualbox do |vb|
    vb.gui = false
    vb.memory = 1536
    vb.cpus = 1
    vb.customize ["modifyvm", :id, "--audio", "none"]
  end
  config.vm.define "vmname", autostart: true do |inst|
    inst.vm.hostname = "vmname"
    inst.vm.provision :ansible_local do |ansible|
      ansible.compatibility_mode = "2.0"
      ansible.playbook = "provisioning/fix.yaml"
    end
    inst.vm.provision :ansible_local do |ansible|
      ansible.compatibility_mode = "2.0"
      ansible.galaxy_role_file = 'provisioning/requirements.yaml'
      ansible.galaxy_roles_path = '/home/vagrant/.ansible/roles'
      ansible.galaxy_command = 'ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path}'
      ansible.playbook = "provisioning/playbook.yaml"
    end
  end
end

Debug output


==> vmhost: Running provisioner: ansible_local...
    vmhost: Running ansible-galaxy...
[WARNING]: - galaxy.role was NOT installed successfully: could not
find/use git, it is required to continue with installing
https://github.com/user/project
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
Provide a link to a GitHub Gist containing the complete debug output:
https://www.vagrantup.com/docs/other/debugging.html. The debug output should
be very long. Do NOT paste the debug output in the issue, just paste the
link to the Gist.

Expected behavior

Ansible should install roles from galaxy. From the docs: "Note: By default, Vagrant will try to automatically install Ansible if it is not yet present on the guest machine."

One can never use the "galaxy_role_file" option without first provisioning a fix first. Whats the purpose of the option if the fix leads to more code than what the option tries to solve?

A simple patch could be to automatically add git when a "galaxy_role_file" is set (dependency). When its available as an option, I expect it to work.

Actual behavior

Error thrown, role is not installed. Galaxy is invoked right after ansible_local is installed which will always break unless explicit intervention.

Steps to reproduce

  1. Set ansible_local as provisioner
  2. Set some galaxy role in requirements.txt
  3. Vagrant up

References

soapy1 commented 4 years ago

Hey there, as specified in the referenced issue, installing git is not something that the ansible provisioner does. To resolve this, please use a box that already has git installed, or use a shell provisioner to install git.

One can never use the "galaxy_role_file" option without first provisioning a fix first.

One way to resolve this is to use a box that already has git installed

Whats the purpose of the option if the fix leads to more code than what the option tries to solve?

I see where you are coming from here. Part of the point here is to make things easier for the user.

@gildegoma @chrisroberts any thoughts on making Vagrant check for git when using ansible galaxy?