Add synced_folder_opts to puppet provisioner #10345
Provide the possibility to configure the synced folders created by the puppet provisioner with options supported by any of the existing synced folder plugins. Deprecate synced_folder_type and synced_folder_args.
This commit is contained in:
parent
6b7063ef05
commit
8b7a467811
plugins/provisioners/puppet
test/unit/plugins/provisioners/puppet/config
website/source/docs/provisioning
|
@ -17,8 +17,7 @@ module VagrantPlugins
|
|||
attr_accessor :environment_variables
|
||||
attr_accessor :module_path
|
||||
attr_accessor :options
|
||||
attr_accessor :synced_folder_type
|
||||
attr_accessor :synced_folder_args
|
||||
attr_accessor :synced_folder_opts
|
||||
attr_accessor :temp_dir
|
||||
attr_accessor :working_directory
|
||||
|
||||
|
@ -35,22 +34,30 @@ module VagrantPlugins
|
|||
@module_path = UNSET_VALUE
|
||||
@options = []
|
||||
@facter = {}
|
||||
@synced_folder_type = UNSET_VALUE
|
||||
@synced_folder_opts = {}
|
||||
@temp_dir = UNSET_VALUE
|
||||
@working_directory = UNSET_VALUE
|
||||
@structured_facts = UNSET_VALUE
|
||||
end
|
||||
|
||||
def nfs=(value)
|
||||
puts "DEPRECATION: The 'nfs' setting for the Puppet provisioner is"
|
||||
puts "deprecated. Please use the 'synced_folder_type' setting instead."
|
||||
puts "The 'nfs' setting will be removed in the next version of Vagrant."
|
||||
def synced_folder_type=(value)
|
||||
puts "DEPRECATION: The 'synced_folder_type' setting for the Puppet provisioner is"
|
||||
puts "deprecated. Please use the 'synced_folder_opts' setting instead."
|
||||
puts "The 'synced_folder_type' setting will be removed in the next version of Vagrant."
|
||||
|
||||
if value
|
||||
@synced_folder_type = "nfs"
|
||||
else
|
||||
@synced_folder_type = nil
|
||||
end
|
||||
@synced_folder_type = value
|
||||
end
|
||||
|
||||
def synced_folder_args=(value)
|
||||
puts "DEPRECATION: The 'synced_folder_args' setting for the Puppet provisioner is"
|
||||
puts "deprecated. Please use the 'synced_folder_opts' setting instead."
|
||||
puts "The 'synced_folder_args' setting will be removed in the next version of Vagrant."
|
||||
|
||||
@synced_folder_args = value
|
||||
end
|
||||
|
||||
def synced_folder_opts(**opts)
|
||||
@synced_folder_opts = @synced_folder_opts.merge!(opts)
|
||||
end
|
||||
|
||||
def merge(other)
|
||||
|
@ -95,10 +102,15 @@ module VagrantPlugins
|
|||
@environment_variables = {}
|
||||
end
|
||||
|
||||
if @synced_folder_opts.eql?({})
|
||||
@synced_folder_opts[:type] = @synced_folder_type if @synced_folder_type
|
||||
@synced_folder_opts[:owner] = "root" if !@synced_folder_type
|
||||
@synced_folder_opts[:args] = @synced_folder_args if @synced_folder_args
|
||||
@synced_folder_opts[:nfs__quiet] = true
|
||||
end
|
||||
|
||||
@binary_path = nil if @binary_path == UNSET_VALUE
|
||||
@module_path = nil if @module_path == UNSET_VALUE
|
||||
@synced_folder_type = nil if @synced_folder_type == UNSET_VALUE
|
||||
@synced_folder_args = nil if @synced_folder_args == UNSET_VALUE
|
||||
@temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE
|
||||
@working_directory = nil if @working_directory == UNSET_VALUE
|
||||
@structured_facts = nil if @structured_facts == UNSET_VALUE
|
||||
|
|
|
@ -28,18 +28,12 @@ module VagrantPlugins
|
|||
@module_paths << [path, File.join(config.temp_dir, "modules-#{key}")]
|
||||
end
|
||||
|
||||
folder_opts = {}
|
||||
folder_opts[:type] = @config.synced_folder_type if @config.synced_folder_type
|
||||
folder_opts[:owner] = "root" if !@config.synced_folder_type
|
||||
folder_opts[:args] = @config.synced_folder_args if @config.synced_folder_args
|
||||
folder_opts[:nfs__quiet] = true
|
||||
|
||||
if @config.environment_path.is_a?(Array)
|
||||
# Share the environments directory with the guest
|
||||
if @config.environment_path[0].to_sym == :host
|
||||
root_config.vm.synced_folder(
|
||||
File.expand_path(@config.environment_path[1], root_path),
|
||||
environments_guest_path, folder_opts)
|
||||
environments_guest_path, @config.synced_folder_opts)
|
||||
end
|
||||
end
|
||||
if @config.manifest_file
|
||||
|
@ -48,13 +42,13 @@ module VagrantPlugins
|
|||
if @config.manifests_path[0].to_sym == :host
|
||||
root_config.vm.synced_folder(
|
||||
File.expand_path(@config.manifests_path[1], root_path),
|
||||
manifests_guest_path, folder_opts)
|
||||
manifests_guest_path, @config.synced_folder_opts)
|
||||
end
|
||||
end
|
||||
|
||||
# Share the module paths
|
||||
@module_paths.each do |from, to|
|
||||
root_config.vm.synced_folder(from, to, folder_opts)
|
||||
root_config.vm.synced_folder(from, to, @config.synced_folder_opts)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
require File.expand_path("../../../../../base", __FILE__)
|
||||
|
||||
require Vagrant.source_root.join("plugins/provisioners/puppet/config/puppet")
|
||||
|
||||
describe VagrantPlugins::Puppet::Config::Puppet do
|
||||
include_context "unit"
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
let(:machine) { double("machine") }
|
||||
|
||||
def expect_puts_deprecation_msg(setting)
|
||||
expect($stdout).to receive(:puts).with(/DEPRECATION: The '#{setting}'/)
|
||||
expect($stdout).to receive(:puts).with(/.*/)
|
||||
expect($stdout).to receive(:puts).with(/.*/)
|
||||
end
|
||||
|
||||
describe "#finalize!" do
|
||||
context "synced_folder_opts is not given" do
|
||||
it "sets defaults when no other options are given" do
|
||||
subject.finalize!
|
||||
expect(subject.synced_folder_opts).to \
|
||||
eql({:owner => "root", :nfs__quiet => true})
|
||||
end
|
||||
it "sets defaults when synced_folder_args is given" do
|
||||
expect_puts_deprecation_msg("synced_folder_args")
|
||||
subject.synced_folder_args = %w[foo]
|
||||
subject.finalize!
|
||||
expect(subject.synced_folder_opts).to \
|
||||
eql({:owner => "root", :args => %w[foo], :nfs__quiet => true})
|
||||
end
|
||||
it "sets defaults when synced_folder_type is given" do
|
||||
expect_puts_deprecation_msg("synced_folder_type")
|
||||
subject.synced_folder_type = "foo"
|
||||
subject.finalize!
|
||||
expect(subject.synced_folder_opts).to \
|
||||
eql({:type => "foo", :nfs__quiet => true})
|
||||
end
|
||||
it "sets defaults when synced_folder_type and synced_folder_args is given" do
|
||||
expect_puts_deprecation_msg("synced_folder_type")
|
||||
expect_puts_deprecation_msg("synced_folder_args")
|
||||
subject.synced_folder_type = "foo"
|
||||
subject.synced_folder_args = %w[foo]
|
||||
subject.finalize!
|
||||
expect(subject.synced_folder_opts).to \
|
||||
eql({:type => "foo", :args => %w[foo], :nfs__quiet => true})
|
||||
end
|
||||
end
|
||||
|
||||
context "synced_folder_opts is given" do
|
||||
it "ignores synced_folder_type and synced_folder_args" do
|
||||
expect_puts_deprecation_msg("synced_folder_type")
|
||||
expect_puts_deprecation_msg("synced_folder_args")
|
||||
subject.synced_folder_type = "foo"
|
||||
subject.synced_folder_args = %w[foo]
|
||||
subject.synced_folder_opts :foo => true, :bar => "baz"
|
||||
subject.finalize!
|
||||
expect(subject.synced_folder_opts).to \
|
||||
eql({:foo => true, :bar => "baz"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -58,14 +58,19 @@ available below this section.
|
|||
* `options` (array of strings) - Additionally options to pass to the
|
||||
Puppet executable when running Puppet.
|
||||
|
||||
* `synced_folder_type` (string) - The type of synced folders to use when
|
||||
sharing the data required for the provisioner to work properly. By default
|
||||
this will use the default synced folder type. For example, you can set this
|
||||
to "nfs" to use NFS synced folders.
|
||||
* `synced_folder_type` (string) - **Deprecated** (use `synced_folder_opts` instead)
|
||||
The type of synced folders to use when sharing the data required for the provisioner
|
||||
to work properly. By default this will use the default synced folder type.
|
||||
For example, you can set this to "nfs" to use NFS synced folders.
|
||||
|
||||
* `synced_folder_args` (array) - Arguments that are passed to the folder sync.
|
||||
For example ['-a', '--delete', '--exclude=fixtures'] for the rsync sync
|
||||
command.
|
||||
* `synced_folder_args` (array) - **Deprecated** (use `synced_folder_opts` instead)
|
||||
Arguments that are passed to the folder sync.
|
||||
For example ['-a', '--delete', '--exclude=fixtures'] for the rsync sync command.
|
||||
|
||||
* `synced_folder_opts` (hash) - Options to apply when creating synced folders required
|
||||
for the provisioner to work properly. If not specified, this will use the default
|
||||
synced folder options. All [synced folder types](/synced-folders/basic_usage.html)
|
||||
and their relevant options are supported.
|
||||
|
||||
* `temp_dir` (string) - The directory where all the data associated with
|
||||
the Puppet run (manifest files, modules, etc.) will be stored on the
|
||||
|
|
Loading…
Reference in New Issue