From 67917353b7fea332481ad2271e9fd53514c08e28 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 8 Apr 2013 14:47:11 -0700 Subject: [PATCH] Add support for policy hub bootstrapping --- plugins/provisioners/cfengine/config.rb | 4 ++++ plugins/provisioners/cfengine/provisioner.rb | 8 ++++++++ templates/locales/en.yml | 2 ++ 3 files changed, 14 insertions(+) diff --git a/plugins/provisioners/cfengine/config.rb b/plugins/provisioners/cfengine/config.rb index a209c5257..a0a67f37f 100644 --- a/plugins/provisioners/cfengine/config.rb +++ b/plugins/provisioners/cfengine/config.rb @@ -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 diff --git a/plugins/provisioners/cfengine/provisioner.rb b/plugins/provisioners/cfengine/provisioner.rb index 0b18b1ccd..9e89d126a 100644 --- a/plugins/provisioners/cfengine/provisioner.rb +++ b/plugins/provisioners/cfengine/provisioner.rb @@ -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 diff --git a/templates/locales/en.yml b/templates/locales/en.yml index bb03cb9dd..fde268dc2 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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