Class: Vagrant::Puppet::Scp::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/puppet/scp/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant/puppet/scp/config.rb', line 12

def initialize
  super

  @manifest_file = UNSET_VALUE
  @manifests_path = UNSET_VALUE
  @modules_path = UNSET_VALUE
  @guest_path = UNSET_VALUE
  @options = []
  @facter = {}
end

Instance Attribute Details

#facterObject

Returns the value of attribute facter.



10
11
12
# File 'lib/vagrant/puppet/scp/config.rb', line 10

def facter
  @facter
end

#guest_pathObject

Returns the value of attribute guest_path.



8
9
10
# File 'lib/vagrant/puppet/scp/config.rb', line 8

def guest_path
  @guest_path
end

#manifest_fileObject

Returns the value of attribute manifest_file.



5
6
7
# File 'lib/vagrant/puppet/scp/config.rb', line 5

def manifest_file
  @manifest_file
end

#manifests_pathObject

Returns the value of attribute manifests_path.



6
7
8
# File 'lib/vagrant/puppet/scp/config.rb', line 6

def manifests_path
  @manifests_path
end

#modules_pathObject

Returns the value of attribute modules_path.



7
8
9
# File 'lib/vagrant/puppet/scp/config.rb', line 7

def modules_path
  @modules_path
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/vagrant/puppet/scp/config.rb', line 9

def options
  @options
end

Instance Method Details

#expanded_manifests_path(root_path) ⇒ Object



32
33
34
# File 'lib/vagrant/puppet/scp/config.rb', line 32

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

#expanded_modules_path(root_path) ⇒ Object



36
37
38
# File 'lib/vagrant/puppet/scp/config.rb', line 36

def expanded_modules_path(root_path)
  Pathname.new(modules_path).expand_path(root_path)
end

#finalize!Object



23
24
25
26
27
28
29
30
# File 'lib/vagrant/puppet/scp/config.rb', line 23

def finalize!
  super

  @manifest_file = 'default.pp' if @manifest_file == UNSET_VALUE
  @manifests_path = 'manifests' if @manifests_path == UNSET_VALUE
  @modules_path = 'modules' if @modules_path == UNSET_VALUE
  @guest_path = '/etc/puppet' if @guest_path == UNSET_VALUE
end

#manifests_guest_pathObject



40
41
42
# File 'lib/vagrant/puppet/scp/config.rb', line 40

def manifests_guest_path
  File.join(guest_path, 'manifests')
end

#modules_guest_pathObject



44
45
46
# File 'lib/vagrant/puppet/scp/config.rb', line 44

def modules_guest_path
  File.join(guest_path, 'modules')
end

#validate(machine) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vagrant/puppet/scp/config.rb', line 48

def validate(machine)
  errors = []

  # Calculate the manifests and module paths based on env
  this_expanded_manifests_path = expanded_manifests_path(machine.env.root_path)
  this_expanded_modules_path = expanded_modules_path(machine.env.root_path)

  # Manifests path/file validation
  # TODO: Provide vagrant.provisioners.puppet_scp translations.
  if !this_expanded_manifests_path.directory?
    errors << 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 << I18n.t("vagrant.provisioners.puppet.manifest_missing",
                       :manifest => expanded_manifest_file.to_s)
    end
  end

  # Module paths validation
  if !this_expanded_modules_path.directory?
    errors << I18n.t("vagrant.provisioners.puppet.module_path_missing",
                     :path => path)
  end

  { "puppet_scp provisioner" => errors }
end