Add support for policy hub bootstrapping

This commit is contained in:
Mitchell Hashimoto 2013-04-08 14:47:11 -07:00
parent 5fb5a60bfa
commit 67917353b7
3 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,7 @@ require "vagrant"
module VagrantPlugins
module CFEngine
class Config < Vagrant.plugin("2", :config)
attr_accessor :am_policy_hub
attr_accessor :extra_agent_args
attr_accessor :classes
attr_accessor :deb_repo_file
@ -18,6 +19,7 @@ module VagrantPlugins
attr_accessor :yum_repo_url
def initialize
@am_policy_hub = UNSET_VALUE
@classes = UNSET_VALUE
@deb_repo_file = UNSET_VALUE
@deb_repo_line = UNSET_VALUE
@ -34,6 +36,8 @@ module VagrantPlugins
end
def finalize!
@am_policy_hub = false if @am_policy_hub == UNSET_VALUE
@classes = nil if @classes == UNSET_VALUE
if @deb_repo_file == UNSET_VALUE

View File

@ -79,6 +79,14 @@ module VagrantPlugins
policy_server: policy_server_address))
result = cfagent("--bootstrap --policy-server #{policy_server_address}", error_check: false)
raise Vagrant::Errors::CFEngineBootstrapFailed if result != 0
# Policy hubs need to do additional things before they're ready
# to accept agents. Force that run now...
if @config.am_policy_hub
@machine.ui.info(I18n.t("vagrant.cfengine_bootstrapping_policy_hub"))
cfagent("-KI -f /var/cfengine/masterfiles/failsafe.cf#{cfagent_classes_args}")
cfagent("-KI #{cfagent_classes_args}#{cfagent_extra_args}")
end
end
# This handles verifying the CFEngine installation, installing it

View File

@ -2,6 +2,8 @@ en:
vagrant:
cfengine_bootstrapping: |-
Bootstrapping CFEngine with policy server: %{policy_server}...
cfengine_bootstrapping_policy_hub: |-
Performing additional bootstrap for policy hubs...
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