Starting work on CFEngine, installs on Debian
This commit is contained in:
parent
376eb0b327
commit
9599d8a45d
|
@ -135,6 +135,14 @@ module Vagrant
|
||||||
error_key(:failed, "vagrant.actions.box.verify")
|
error_key(:failed, "vagrant.actions.box.verify")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class CFEngineInstallFailed < VagrantError
|
||||||
|
error_key(:cfengine_install_failed)
|
||||||
|
end
|
||||||
|
|
||||||
|
class CFEngineNotInstalled < VagrantError
|
||||||
|
error_key(:cfengine_not_installed)
|
||||||
|
end
|
||||||
|
|
||||||
class CLIInvalidUsage < VagrantError
|
class CLIInvalidUsage < VagrantError
|
||||||
error_key(:cli_invalid_usage)
|
error_key(:cli_invalid_usage)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module CFEngine
|
||||||
|
module Cap
|
||||||
|
module Debian
|
||||||
|
module CFEngineInstall
|
||||||
|
def self.cfengine_install(machine, config)
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
comm.sudo("mkdir -p #{File.dirname(config.deb_repo_file)} && /bin/echo #{config.deb_repo_line} > #{config.deb_repo_file}")
|
||||||
|
comm.sudo("GPGFILE=`tempfile`; wget -O $GPGFILE #{config.repo_gpg_key_url} && apt-key add $GPGFILE; rm -f $GPGFILE")
|
||||||
|
|
||||||
|
comm.sudo("apt-get update")
|
||||||
|
comm.sudo("apt-get install -y cfengine-community")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module CFEngine
|
||||||
|
module Cap
|
||||||
|
module Linux
|
||||||
|
module CFEngineInstalled
|
||||||
|
def self.cfengine_installed(machine)
|
||||||
|
machine.communicate.test(
|
||||||
|
"test -d /var/cfengine && test -x /var/cfengine/bin/cf-agent", sudo: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,36 @@
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module CFEngine
|
||||||
|
class Config < Vagrant.plugin("2", :config)
|
||||||
|
attr_accessor :install
|
||||||
|
attr_accessor :deb_repo_file
|
||||||
|
attr_accessor :deb_repo_line
|
||||||
|
attr_accessor :repo_gpg_key_url
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@deb_repo_file = UNSET_VALUE
|
||||||
|
@deb_repo_line = UNSET_VALUE
|
||||||
|
@install = UNSET_VALUE
|
||||||
|
@repo_gpg_key_url = UNSET_VALUE
|
||||||
|
end
|
||||||
|
|
||||||
|
def finalize!
|
||||||
|
if @deb_repo_file == UNSET_VALUE
|
||||||
|
@deb_repo_file = "/etc/apt/sources.list.d/cfengine-community.list"
|
||||||
|
end
|
||||||
|
|
||||||
|
if @deb_repo_line == UNSET_VALUE
|
||||||
|
@deb_repo_line = "deb http://cfengine.com/pub/apt $(lsb_release -cs) main"
|
||||||
|
end
|
||||||
|
|
||||||
|
@install = true if @install == UNSET_VALUE
|
||||||
|
@install = @install.to_sym if @install.respond_to?(:to_sym)
|
||||||
|
|
||||||
|
if @repo_gpg_key_url == UNSET_VALUE
|
||||||
|
@repo_gpg_key_url = "http://cfengine.com/pub/gpg.key"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,32 @@
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module CFEngine
|
||||||
|
class Plugin < Vagrant.plugin("2")
|
||||||
|
name "CFEngine Provisioner"
|
||||||
|
description <<-DESC
|
||||||
|
Provisions machines with CFEngine.
|
||||||
|
DESC
|
||||||
|
|
||||||
|
config(:cfengine, :provisioner) do
|
||||||
|
require_relative "config"
|
||||||
|
Config
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("debian", "cfengine_install") do
|
||||||
|
require_relative "cap/debian/cfengine_install"
|
||||||
|
Cap::Debian::CFEngineInstall
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("linux", "cfengine_installed") do
|
||||||
|
require_relative "cap/linux/cfengine_installed"
|
||||||
|
Cap::Linux::CFEngineInstalled
|
||||||
|
end
|
||||||
|
|
||||||
|
provisioner(:cfengine) do
|
||||||
|
require_relative "provisioner"
|
||||||
|
Provisioner
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,35 @@
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module CFEngine
|
||||||
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||||
|
def provision
|
||||||
|
handle_cfengine_installation
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
# This handles verifying the CFEngine installation, installing it
|
||||||
|
# if it was requested, and so on. This method will raise exceptions
|
||||||
|
# if things are wrong.
|
||||||
|
def handle_cfengine_installation
|
||||||
|
if !@machine.guest.capability?(:cfengine_installed)
|
||||||
|
@machine.ui.warn(I18n.t("vagrant.cfengine_cant_detect"))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
installed = @machine.guest.capability(:cfengine_installed)
|
||||||
|
if !installed || @config.install == :force
|
||||||
|
raise Vagrant::Errors::CFEngineNotInstalled if !@config.install
|
||||||
|
|
||||||
|
@machine.ui.info(I18n.t("vagrant.cfengine_installing"))
|
||||||
|
@machine.guest.capability(:cfengine_install, @config)
|
||||||
|
|
||||||
|
if !@machine.guest.capability(:cfengine_installed)
|
||||||
|
raise Vagrant::Errors::CFEngineInstallFailed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,12 @@
|
||||||
en:
|
en:
|
||||||
vagrant:
|
vagrant:
|
||||||
|
cfengine_cant_detect: |-
|
||||||
|
Vagrant doesn't support detecting whether CFEngine is installed
|
||||||
|
for the guest OS running in the machine. Vagrant will assume it is
|
||||||
|
installed and attempt to continue.
|
||||||
|
cfengine_installing: |-
|
||||||
|
Installing CFEngine onto machine...
|
||||||
|
|
||||||
general:
|
general:
|
||||||
batch_unexpected_error: |-
|
batch_unexpected_error: |-
|
||||||
An unexpected error ocurred when executing the action on the
|
An unexpected error ocurred when executing the action on the
|
||||||
|
@ -99,6 +106,16 @@ en:
|
||||||
The box '%{name}' is still stored on disk in the Vagrant 1.0.x
|
The box '%{name}' is still stored on disk in the Vagrant 1.0.x
|
||||||
format. This box must be upgraded in order to work properly with
|
format. This box must be upgraded in order to work properly with
|
||||||
this version of Vagrant.
|
this version of Vagrant.
|
||||||
|
cfengine_install_failed: |-
|
||||||
|
After installing CFEngine, Vagrant still can't detect a proper
|
||||||
|
CFEngine installation. Please verify that CFEngine was properly
|
||||||
|
installed, as the installation may have failed.
|
||||||
|
cfengine_not_installed: |-
|
||||||
|
CFEngine appears to not be installed on the guest machine. Vagrant
|
||||||
|
can attempt to install CFEngine for you if you set the "install"
|
||||||
|
setting to "true", but this setting was not set. Please install
|
||||||
|
CFEngine on the guest machine or enable the "install" setting for
|
||||||
|
Vagrant to attempt to install it for you.
|
||||||
cli_invalid_options: |-
|
cli_invalid_options: |-
|
||||||
An invalid option was specified. The help for this command
|
An invalid option was specified. The help for this command
|
||||||
is available below.
|
is available below.
|
||||||
|
|
Loading…
Reference in New Issue