Support installing CFEngine on RedHat

This commit is contained in:
Mitchell Hashimoto 2013-04-08 13:09:52 -07:00
parent 9599d8a45d
commit 8f9a5671de
3 changed files with 44 additions and 3 deletions

View File

@ -0,0 +1,24 @@
require "log4r"
module VagrantPlugins
module CFEngine
module Cap
module RedHat
module CFEngineInstall
def self.cfengine_install(machine, config)
logger = Log4r::Logger.new("vagrant::plugins::cfengine::cap_redhat_cfengine_install")
machine.communicate.tap do |comm|
logger.info("Adding the CFEngine repository to #{config.yum_repo_file}")
comm.sudo("mkdir -p #{File.dirname(config.yum_repo_file)} && (echo '[cfengine-repository]'; echo 'name=CFEngine Community Yum Repository'; echo 'baseurl=#{config.yum_repo_url}'; echo 'enabled=1'; echo 'gpgcheck=1') > #{config.yum_repo_file}")
logger.info("Installing CFEngine Community Yum Repository GPG KEY from #{config.repo_gpg_key_url}")
comm.sudo("GPGFILE=$(mktemp) && wget -O $GPGFILE #{config.repo_gpg_key_url} && rpm --import $GPGFILE; rm -f $GPGFILE")
comm.sudo("yum -y install cfengine-community")
end
end
end
end
end
end
end

View File

@ -7,12 +7,16 @@ module VagrantPlugins
attr_accessor :deb_repo_file attr_accessor :deb_repo_file
attr_accessor :deb_repo_line attr_accessor :deb_repo_line
attr_accessor :repo_gpg_key_url attr_accessor :repo_gpg_key_url
attr_accessor :yum_repo_file
attr_accessor :yum_repo_url
def initialize def initialize
@deb_repo_file = UNSET_VALUE @deb_repo_file = UNSET_VALUE
@deb_repo_line = UNSET_VALUE @deb_repo_line = UNSET_VALUE
@install = UNSET_VALUE @install = UNSET_VALUE
@repo_gpg_key_url = UNSET_VALUE @repo_gpg_key_url = UNSET_VALUE
@yum_repo_file = UNSET_VALUE
@yum_repo_url = UNSET_VALUE
end end
def finalize! def finalize!
@ -30,6 +34,14 @@ module VagrantPlugins
if @repo_gpg_key_url == UNSET_VALUE if @repo_gpg_key_url == UNSET_VALUE
@repo_gpg_key_url = "http://cfengine.com/pub/gpg.key" @repo_gpg_key_url = "http://cfengine.com/pub/gpg.key"
end end
if @yum_repo_file == UNSET_VALUE
@yum_repo_file = "/etc/yum.repos.d/cfengine-community.repo"
end
if @yum_repo_url == UNSET_VALUE
@yum_repo_url = "http://cfengine.com/pub/yum/"
end
end end
end end
end end

View File

@ -23,6 +23,11 @@ module VagrantPlugins
Cap::Linux::CFEngineInstalled Cap::Linux::CFEngineInstalled
end end
guest_capability("redhat", "cfengine_install") do
require_relative "cap/redhat/cfengine_install"
Cap::RedHat::CFEngineInstall
end
provisioner(:cfengine) do provisioner(:cfengine) do
require_relative "provisioner" require_relative "provisioner"
Provisioner Provisioner