Support ansible install on RedHat derivates and Fedora.

Fixes #6636
This commit is contained in:
Rickard von Essen 2015-12-07 15:44:20 +01:00
parent dde7f4697f
commit 9f3ebef810
4 changed files with 61 additions and 41 deletions

View File

@ -1,39 +0,0 @@
module VagrantPlugins
module Ansible
module Cap
module Guest
module EPEL # Extra Packages for Enterprise Linux (for RedHat-family distributions)
module AnsibleInstall
# This should work on recent Fedora releases, and any other members of the
# RedHat family which supports YUM and http://fedoraproject.org/wiki/EPEL
def self.ansible_install(machine)
configure_epel = <<INLINE_CRIPT
cat <<EOM >/etc/yum.repos.d/epel-bootstrap.repo
[epel]
name=Bootstrap EPEL
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-\$releasever&arch=\$basearch
failovermethod=priority
enabled=0
gpgcheck=0
EOM
yum --assumeyes --quiet --enablerepo=epel install epel-release
rm -f /etc/yum.repos.d/epel-bootstrap.repo
INLINE_CRIPT
ansible_is_installable = machine.communicate.execute("yum info ansible", :error_check => false)
if ansible_is_installable != 0
machine.communicate.sudo(configure_epel)
end
machine.communicate.sudo("yum --assumeyes --quiet --enablerepo=epel install ansible")
end
end
end
end
end
end
end

View File

@ -0,0 +1,25 @@
module VagrantPlugins
module Ansible
module Cap
module Guest
module Fedora
module AnsibleInstall
def self.ansible_install(machine)
if dnf?(machine)
machine.communicate.sudo("dnf -y install ansible")
else
machine.communicate.sudo("yum -y install ansible")
end
end
def self.dnf?(machine)
machine.communicate.test("/usr/bin/which -s dnf")
end
end
end
end
end
end
end

View File

@ -0,0 +1,29 @@
module VagrantPlugins
module Ansible
module Cap
module Guest
module RedHat
module AnsibleInstall
# This should work on recent Fedora releases, and any other members of the
# RedHat family which supports YUM and http://fedoraproject.org/wiki/EPEL
def self.ansible_install(machine)
epel = machine.communicate.execute("#{yum_dnf(machine)} 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("#{yum_dnf(machine)} -y --enablerepo=epel install ansible")
end
def self.yum_dnf(machine)
machine.communicate.test("/usr/bin/which -s dnf") ? "dnf" : "yum"
end
end
end
end
end
end
end

View File

@ -55,9 +55,14 @@ module VagrantPlugins
Cap::Guest::Ubuntu::AnsibleInstall
end
guest_capability(:fedora, :ansible_install) do
require_relative "cap/guest/fedora/ansible_install"
Cap::Guest::Fedora::AnsibleInstall
end
guest_capability(:redhat, :ansible_install) do
require_relative "cap/guest/epel/ansible_install"
Cap::Guest::EPEL::AnsibleInstall
require_relative "cap/guest/redhat/ansible_install"
Cap::Guest::RedHat::AnsibleInstall
end
guest_capability(:suse, :ansible_install) do