Class: VagrantHiera::Config

Inherits:
Vagrant::Config::Base
  • Object
show all
Defined in:
lib/vagrant-hiera/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#apt_optsObject

Returns the value of attribute apt_opts.



11
12
13
# File 'lib/vagrant-hiera/config.rb', line 11

def apt_opts
  @apt_opts
end

#config_fileObject

Returns the value of attribute config_file.



6
7
8
# File 'lib/vagrant-hiera/config.rb', line 6

def config_file
  @config_file
end

#config_pathObject

Returns the value of attribute config_path.



4
5
6
# File 'lib/vagrant-hiera/config.rb', line 4

def config_path
  @config_path
end

#data_pathObject

Returns the value of attribute data_path.



7
8
9
# File 'lib/vagrant-hiera/config.rb', line 7

def data_path
  @data_path
end

#guest_config_pathObject

Returns the value of attribute guest_config_path.



5
6
7
# File 'lib/vagrant-hiera/config.rb', line 5

def guest_config_path
  @guest_config_path
end

#guest_data_pathObject

Returns the value of attribute guest_data_path.



8
9
10
# File 'lib/vagrant-hiera/config.rb', line 8

def guest_data_path
  @guest_data_path
end

#hiera_puppet_versionObject

Returns the value of attribute hiera_puppet_version.



13
14
15
# File 'lib/vagrant-hiera/config.rb', line 13

def hiera_puppet_version
  @hiera_puppet_version
end

#hiera_versionObject

Returns the value of attribute hiera_version.



14
15
16
# File 'lib/vagrant-hiera/config.rb', line 14

def hiera_version
  @hiera_version
end

#puppet_apt_sourceObject

Returns the value of attribute puppet_apt_source.



10
11
12
# File 'lib/vagrant-hiera/config.rb', line 10

def puppet_apt_source
  @puppet_apt_source
end

#puppet_versionObject

Returns the value of attribute puppet_version.



12
13
14
# File 'lib/vagrant-hiera/config.rb', line 12

def puppet_version
  @puppet_version
end

Instance Method Details

#install_puppet_heira?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/vagrant-hiera/config.rb', line 56

def install_puppet_heira?
  puppet_version.to_i < 3
end

#set?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/vagrant-hiera/config.rb', line 52

def set?
  config_path || config_file || data_path
end

#validate(env, errors) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vagrant-hiera/config.rb', line 60

def validate(env, errors)
  return unless set?

  errors.add("Config path can not be empty.") if config_path.nil?
  errors.add("Config file can not be empty.") if config_file.nil?
  errors.add("Data path can not be empty.") if data_path.nil?
  errors.add("Puppet version path can not be empty.") if puppet_version.nil?
  errors.add("Puppet apt source can not be empty.") if puppet_apt_source.nil?
  errors.add("Hiera puppet version can not be empty if puppet_version < 3.0.") if install_puppet_heira? && hiera_puppet_version.nil?
  errors.add("Hiera version can not be empty.") if hiera_version.nil?
  config = File.join("#{config_path}", "#{config_file}")
  errors.add("Config file not found at '#{config}'.") unless File.exists?(config)
  errors.add("Data directory not found at '#{data_path}'.") unless File.exists?("#{data_path}")
end