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

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

Instance Attribute Summary collapse

Attributes inherited from Config::Base

#top

Instance Method Summary collapse

Methods inherited from Config::Base

configures, #env, #instance_variables_hash, json_create, #set_options, #to_hash, #to_json

Constructor Details

#initializeConfig

Returns a new instance of Config.



17
18
19
20
21
22
23
# File 'lib/vagrant/provisioners/puppet.rb', line 17

def initialize
  @manifest_file = nil
  @manifests_path = "manifests"
  @module_path = nil
  @pp_path = "/tmp/vagrant-puppet"
  @options = []
end

Instance Attribute Details

#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

#computed_manifest_fileObject

Returns the manifest file if set otherwise returns the box name pp file which may or may not exist.



33
34
35
# File 'lib/vagrant/provisioners/puppet.rb', line 33

def computed_manifest_file
  manifest_file || "#{top.vm.box}.pp"
end

#expanded_manifests_pathObject

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



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

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

#expanded_module_pathsObject

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



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vagrant/provisioners/puppet.rb', line 39

def expanded_module_paths
  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(env.root_path)
  end
end

#validate(errors) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant/provisioners/puppet.rb', line 51

def validate(errors)
  super

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

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