provisioners/puppet: manifests path can be in the VM [GH-1805]
This commit is contained in:
parent
d7b74ca8b9
commit
25a8491465
|
@ -48,6 +48,7 @@ IMPROVEMENTS:
|
||||||
- provisioners/ansible: allow files for extra vars [GH-2366]
|
- provisioners/ansible: allow files for extra vars [GH-2366]
|
||||||
- provisioners/puppet: client cert and private key can now be specified
|
- provisioners/puppet: client cert and private key can now be specified
|
||||||
for the puppet server provisioner. [GH-902]
|
for the puppet server provisioner. [GH-902]
|
||||||
|
- provisioners/puppet: the manifests path can be in the VM. [GH-1805]
|
||||||
- provisioners/shell: Added `keep_color` option to not automatically color
|
- provisioners/shell: Added `keep_color` option to not automatically color
|
||||||
output based on stdout/stderr. [GH-2505]
|
output based on stdout/stderr. [GH-2505]
|
||||||
- provisioners/shell: Arguments can now be an array of args. [GH-1949]
|
- provisioners/shell: Arguments can now be an array of args. [GH-1949]
|
||||||
|
|
|
@ -29,21 +29,24 @@ module VagrantPlugins
|
||||||
def finalize!
|
def finalize!
|
||||||
super
|
super
|
||||||
|
|
||||||
|
if @manifests_path == UNSET_VALUE
|
||||||
|
@manifests_path = [:host, "manifests"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if @manifests_path && !@manifests_path.is_a?(Array)
|
||||||
|
@manifests_path = [:host, @manifests_path]
|
||||||
|
end
|
||||||
|
|
||||||
|
@manifests_path[0] = @manifests_path[0].to_sym
|
||||||
|
|
||||||
@hiera_config_path = nil if @hiera_config_path == UNSET_VALUE
|
@hiera_config_path = nil if @hiera_config_path == UNSET_VALUE
|
||||||
@manifest_file = "default.pp" if @manifest_file == UNSET_VALUE
|
@manifest_file = "default.pp" if @manifest_file == UNSET_VALUE
|
||||||
@manifests_path = "manifests" if @manifests_path == UNSET_VALUE
|
|
||||||
@module_path = nil if @module_path == UNSET_VALUE
|
@module_path = nil if @module_path == UNSET_VALUE
|
||||||
@temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE
|
@temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE
|
||||||
@working_directory = nil if @working_directory == UNSET_VALUE
|
@working_directory = nil if @working_directory == UNSET_VALUE
|
||||||
@nfs = false if @nfs == UNSET_VALUE
|
@nfs = false if @nfs == UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the manifests path expanded relative to the root path of the
|
|
||||||
# environment.
|
|
||||||
def expanded_manifests_path(root_path)
|
|
||||||
Pathname.new(manifests_path).expand_path(root_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns the module paths as an array of paths expanded relative to the
|
# Returns the module paths as an array of paths expanded relative to the
|
||||||
# root path.
|
# root path.
|
||||||
def expanded_module_paths(root_path)
|
def expanded_module_paths(root_path)
|
||||||
|
@ -62,20 +65,22 @@ module VagrantPlugins
|
||||||
errors = _detected_errors
|
errors = _detected_errors
|
||||||
|
|
||||||
# Calculate the manifests and module paths based on env
|
# Calculate the manifests and module paths based on env
|
||||||
this_expanded_manifests_path = expanded_manifests_path(machine.env.root_path)
|
|
||||||
this_expanded_module_paths = expanded_module_paths(machine.env.root_path)
|
this_expanded_module_paths = expanded_module_paths(machine.env.root_path)
|
||||||
|
|
||||||
# Manifests path/file validation
|
# Manifests path/file validation
|
||||||
if !this_expanded_manifests_path.directory?
|
if manifests_path[0].to_sym == :host
|
||||||
|
expanded_path = File.expand_path(manifests_path[1], machine.env.root_path)
|
||||||
|
if expanded_path.directory?
|
||||||
errors << I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
|
errors << I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
|
||||||
:path => this_expanded_manifests_path)
|
:path => this_expanded_manifests_path)
|
||||||
else
|
else
|
||||||
expanded_manifest_file = this_expanded_manifests_path.join(manifest_file)
|
expanded_manifest_file = expanded_path.join(manifest_file)
|
||||||
if !expanded_manifest_file.file?
|
if !expanded_manifest_file.file?
|
||||||
errors << I18n.t("vagrant.provisioners.puppet.manifest_missing",
|
errors << I18n.t("vagrant.provisioners.puppet.manifest_missing",
|
||||||
:manifest => expanded_manifest_file.to_s)
|
:manifest => expanded_manifest_file.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Module paths validation
|
# Module paths validation
|
||||||
this_expanded_module_paths.each do |path|
|
this_expanded_module_paths.each do |path|
|
||||||
|
|
|
@ -17,7 +17,6 @@ module VagrantPlugins
|
||||||
def configure(root_config)
|
def configure(root_config)
|
||||||
# Calculate the paths we're going to use based on the environment
|
# Calculate the paths we're going to use based on the environment
|
||||||
root_path = @machine.env.root_path
|
root_path = @machine.env.root_path
|
||||||
@expanded_manifests_path = @config.expanded_manifests_path(root_path)
|
|
||||||
@expanded_module_paths = @config.expanded_module_paths(root_path)
|
@expanded_module_paths = @config.expanded_module_paths(root_path)
|
||||||
@manifest_file = File.join(manifests_guest_path, @config.manifest_file)
|
@manifest_file = File.join(manifests_guest_path, @config.manifest_file)
|
||||||
|
|
||||||
|
@ -32,8 +31,11 @@ module VagrantPlugins
|
||||||
folder_opts[:owner] = "root" if !folder_opts[:nfs]
|
folder_opts[:owner] = "root" if !folder_opts[:nfs]
|
||||||
|
|
||||||
# Share the manifests directory with the guest
|
# Share the manifests directory with the guest
|
||||||
|
if @config.manifests_path[0].to_sym == :host
|
||||||
root_config.vm.synced_folder(
|
root_config.vm.synced_folder(
|
||||||
@expanded_manifests_path, manifests_guest_path, folder_opts)
|
File.expand_path(@config.manifests_path[1], root_path),
|
||||||
|
manifests_guest_path, folder_opts)
|
||||||
|
end
|
||||||
|
|
||||||
# Share the module paths
|
# Share the module paths
|
||||||
@module_paths.each do |from, to|
|
@module_paths.each do |from, to|
|
||||||
|
@ -62,7 +64,8 @@ module VagrantPlugins
|
||||||
# Upload Hiera configuration if we have it
|
# Upload Hiera configuration if we have it
|
||||||
@hiera_config_path = nil
|
@hiera_config_path = nil
|
||||||
if config.hiera_config_path
|
if config.hiera_config_path
|
||||||
local_hiera_path = File.expand_path(config.hiera_config_path, @machine.env.root_path)
|
local_hiera_path = File.expand_path(config.hiera_config_path,
|
||||||
|
@machine.env.root_path)
|
||||||
@hiera_config_path = File.join(config.temp_dir, "hiera.yaml")
|
@hiera_config_path = File.join(config.temp_dir, "hiera.yaml")
|
||||||
@machine.communicate.upload(local_hiera_path, @hiera_config_path)
|
@machine.communicate.upload(local_hiera_path, @hiera_config_path)
|
||||||
end
|
end
|
||||||
|
@ -71,7 +74,13 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def manifests_guest_path
|
def manifests_guest_path
|
||||||
|
if config.manifests_path[0] == :host
|
||||||
|
# The path is on the host, so point to where it is shared
|
||||||
File.join(config.temp_dir, "manifests")
|
File.join(config.temp_dir, "manifests")
|
||||||
|
else
|
||||||
|
# The path is on the VM, so just point directly to it
|
||||||
|
config.manifests_path[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_binary(binary)
|
def verify_binary(binary)
|
||||||
|
|
|
@ -64,6 +64,23 @@ end
|
||||||
The path can be relative or absolute. If it is relative, it is relative
|
The path can be relative or absolute. If it is relative, it is relative
|
||||||
to the project root.
|
to the project root.
|
||||||
|
|
||||||
|
You can also specify a manifests path that is on the remote machine
|
||||||
|
already, perhaps put in place by a shell provisioner. In this case, Vagrant
|
||||||
|
won't attempt to upload the manifests directory. To specify a remote
|
||||||
|
manifests path, use the following syntax:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provision "puppet" do |puppet|
|
||||||
|
puppet.manifests_path = ["vm", "/path/to/manifests"]
|
||||||
|
puppet.manifest_file = "default.pp"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
It is a somewhat odd syntax, but the tuple (two-element array) says
|
||||||
|
that the path is located in the "vm" at "/path/to/manifests".
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
Vagrant also supports provisioning with [Puppet modules](http://docs.puppetlabs.com/guides/modules.html).
|
Vagrant also supports provisioning with [Puppet modules](http://docs.puppetlabs.com/guides/modules.html).
|
||||||
|
|
Loading…
Reference in New Issue