Class: Vagrant::Provisioners::Puppet::Config

Inherits:
Config::Base show all
Defined in:
lib/vagrant/provisioners/puppet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Config::Base

#instance_variables_hash, json_create, #merge, #set_options, #to_hash, #to_json

Instance Attribute Details

#facterObject

Returns the value of attribute facter.



16
17
18
# File 'lib/vagrant/provisioners/puppet.rb', line 16

def facter
  @facter
end

#manifest_fileObject

Returns the value of attribute manifest_file.



11
12
13
# File 'lib/vagrant/provisioners/puppet.rb', line 11

def manifest_file
  @manifest_file
end

#manifests_pathObject

Returns the value of attribute manifests_path.



12
13
14
# File 'lib/vagrant/provisioners/puppet.rb', line 12

def manifests_path
  @manifests_path
end

#module_pathObject

Returns the value of attribute module_path.



13
14
15
# File 'lib/vagrant/provisioners/puppet.rb', line 13

def module_path
  @module_path
end

#optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/vagrant/provisioners/puppet.rb', line 15

def options
  @options
end

#pp_pathObject

Returns the value of attribute pp_path.



14
15
16
# File 'lib/vagrant/provisioners/puppet.rb', line 14

def pp_path
  @pp_path
end

Instance Method Details

#expanded_manifests_path(root_path) ⇒ Object

Returns the manifests path expanded relative to the root path of the environment.



26
27
28
# File 'lib/vagrant/provisioners/puppet.rb', line 26

def expanded_manifests_path(root_path)
  Pathname.new(manifests_path).expand_path(root_path)
end

#expanded_module_paths(root_path) ⇒ Object

Returns the module paths as an array of paths expanded relative to the root path.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vagrant/provisioners/puppet.rb', line 32

def expanded_module_paths(root_path)
  return [] if !module_path

  # Get all the paths and expand them relative to the root path, returning
  # the array of expanded paths
  paths = module_path
  paths = [paths] if !paths.is_a?(Array)
  paths.map do |path|
    Pathname.new(path).expand_path(root_path)
  end
end

#validate(env, errors) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vagrant/provisioners/puppet.rb', line 44

def validate(env, errors)
  # Calculate the manifests and module paths based on env
  this_expanded_manifests_path = expanded_manifests_path(env.root_path)
  this_expanded_module_paths = expanded_module_paths(env.root_path)

  # Manifests path/file validation
  if !this_expanded_manifests_path.directory?
    errors.add(I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
                      :path => this_expanded_manifests_path))
  else
    expanded_manifest_file = this_expanded_manifests_path.join(manifest_file)
    if !expanded_manifest_file.file?
      errors.add(I18n.t("vagrant.provisioners.puppet.manifest_missing",
                        :manifest => expanded_manifest_file.to_s))
    end
  end

  # Module paths validation
  this_expanded_module_paths.each do |path|
    if !path.directory?
      errors.add(I18n.t("vagrant.provisioners.puppet.module_path_missing", :path => path))
    end
  end
end