files_path setting for CFEngine
This commit is contained in:
parent
b279f222a2
commit
9b9ed2d2aa
|
@ -1,3 +1,5 @@
|
|||
require "pathname"
|
||||
|
||||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
|
@ -8,6 +10,7 @@ module VagrantPlugins
|
|||
attr_accessor :classes
|
||||
attr_accessor :deb_repo_file
|
||||
attr_accessor :deb_repo_line
|
||||
attr_accessor :files_path
|
||||
attr_accessor :force_bootstrap
|
||||
attr_accessor :install
|
||||
attr_accessor :mode
|
||||
|
@ -24,6 +27,7 @@ module VagrantPlugins
|
|||
@deb_repo_file = UNSET_VALUE
|
||||
@deb_repo_line = UNSET_VALUE
|
||||
@extra_agent_args = UNSET_VALUE
|
||||
@files_path = UNSET_VALUE
|
||||
@force_bootstrap = UNSET_VALUE
|
||||
@install = UNSET_VALUE
|
||||
@mode = UNSET_VALUE
|
||||
|
@ -50,6 +54,8 @@ module VagrantPlugins
|
|||
|
||||
@extra_agent_args = nil if @extra_agent_args == UNSET_VALUE
|
||||
|
||||
@files_path = nil if @files_path == UNSET_VALUE
|
||||
|
||||
@force_bootstrap = false if @force_bootstrap == UNSET_VALUE
|
||||
|
||||
@install = true if @install == UNSET_VALUE
|
||||
|
@ -91,6 +97,13 @@ module VagrantPlugins
|
|||
errors << I18n.t("vagrant.cfengine_config.classes_array")
|
||||
end
|
||||
|
||||
if @files_path
|
||||
expanded = Pathname.new(@files_path).expand_path(machine.env.root_path)
|
||||
if !expanded.directory?
|
||||
errors << I18n.t("vagrant.cfengine_config.files_path_not_directory")
|
||||
end
|
||||
end
|
||||
|
||||
if @run_file
|
||||
expanded = Pathname.new(@run_file).expand_path(machine.env.root_path)
|
||||
if !expanded.file?
|
||||
|
|
|
@ -10,6 +10,11 @@ module VagrantPlugins
|
|||
@logger.info("Checking for CFEngine installation...")
|
||||
handle_cfengine_installation
|
||||
|
||||
if @config.files_path
|
||||
@machine.ui.info(I18n.t("vagrant.cfengine_installing_files_path"))
|
||||
install_files(Pathname.new(@config.files_path).expand_path(@machine.env.root_path))
|
||||
end
|
||||
|
||||
handle_cfengine_bootstrap if @config.mode == :bootstrap
|
||||
|
||||
if @config.mode == :single_run
|
||||
|
@ -110,6 +115,17 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# This installs a set of files into the CFEngine folder within
|
||||
# the machine.
|
||||
#
|
||||
# @param [Pathname] local_path
|
||||
def install_files(local_path)
|
||||
@logger.debug("Copying local files to CFEngine: #{local_path}")
|
||||
@machine.communicate.sudo("rm -rf /tmp/cfengine-files")
|
||||
@machine.communicate.upload(local_path.to_s, "/tmp/cfengine-files")
|
||||
@machine.communicate.sudo("cp -R /tmp/cfengine-files/* /var/cfengine")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,8 @@ en:
|
|||
installed and attempt to continue.
|
||||
cfengine_installing: |-
|
||||
Installing CFEngine onto machine...
|
||||
cfengine_installing_files_path: |-
|
||||
Copying the 'files_path' files...
|
||||
cfengine_no_bootstrap: |-
|
||||
CFEngine doesn't require bootstrap. Not bootstrapping.
|
||||
cfengine_single_run: |-
|
||||
|
@ -20,6 +22,8 @@ en:
|
|||
cfengine_config:
|
||||
classes_array: |-
|
||||
The 'classes' configuration must be an array.
|
||||
files_path_not_directory: |-
|
||||
The 'files_path' must point to a valid directory.
|
||||
invalid_mode: |-
|
||||
The mode must be 'bootstrap' or 'single_run'
|
||||
policy_server_address: |-
|
||||
|
|
Loading…
Reference in New Issue