provisioners/ansible_local: Fix Fedora/RedHat "default" installation mode

With bb9dba56ac, I introduced a pitiful
regression in "rpm-based" Ansible installation (via yum or dnf).

This fix is part of GH-6654
This commit is contained in:
Gilles Cornu 2016-06-09 19:16:47 +02:00
parent 14c997317a
commit 6ee8bb6a84
2 changed files with 13 additions and 6 deletions

View File

@ -9,18 +9,22 @@ module VagrantPlugins
module AnsibleInstall
def self.ansible_install(machine, install_mode, ansible_version)
rpm_package_manager = Facts::rpm_package_manager(machine)
if install_mode == :pip
pip_setup machine
Pip::pip_install machine, "ansible", ansible_version
else
machine.communicate.sudo "#{Facts::rpm_package_manager} -y install ansible"
machine.communicate.sudo "#{rpm_package_manager} -y install ansible"
end
end
private
def self.pip_setup(machine)
machine.communicate.sudo "#{Facts::rpm_package_manager(machine)} install -y curl gcc gmp-devel libffi-devel openssl-devel python-crypto python-devel python-dnf python-setuptools redhat-rpm-config"
rpm_package_manager = Facts::rpm_package_manager(machine)
machine.communicate.sudo "#{rpm_package_manager} install -y curl gcc gmp-devel libffi-devel openssl-devel python-crypto python-devel python-dnf python-setuptools redhat-rpm-config"
Pip::get_pip machine
end

View File

@ -20,16 +20,19 @@ module VagrantPlugins
private
def self.ansible_rpm_install(machine)
epel = machine.communicate.execute "#{yum_dnf(machine)} repolist epel | grep -q epel", error_check: false
rpm_package_manager = Facts::rpm_package_manager(machine)
epel = machine.communicate.execute "#{rpm_package_manager} repolist epel | grep -q epel", error_check: false
if epel != 0
machine.communicate.sudo 'sudo rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n \'s/.*el\([0-9]\).*/\1/p\'`.noarch.rpm'
end
machine.communicate.sudo "#{Facts::rpm_package_manager} -y --enablerepo=epel install ansible"
machine.communicate.sudo "#{rpm_package_manager} -y --enablerepo=epel install ansible"
end
def self.pip_setup(machine)
machine.communicate.sudo("#{Facts::rpm_package_manager(machine)} install -y curl gcc libffi-devel openssl-devel python-crypto python-devel python-setuptools")
rpm_package_manager = Facts::rpm_package_manager(machine)
machine.communicate.sudo("#{rpm_package_manager} -y install curl gcc libffi-devel openssl-devel python-crypto python-devel python-setuptools")
Pip::get_pip machine
end