Class: Vagrant::Puppetfile::Evaluator::Puppet
- Defined in:
- lib/vagrant/puppetfile.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #available? ⇒ Boolean
- #forge(forge) ⇒ Object
-
#initialize(path, logger) ⇒ Puppet
constructor
A new instance of Puppet.
- #install(puppetfile) ⇒ Object
- #mod(name, version = :latest, options = {}) ⇒ Object
- #moduledir(moduledir) ⇒ Object
- #unsupported(option, method, *args) ⇒ Object
Methods inherited from Base
#command, #run, #validate, #with_clean_env
Constructor Details
#initialize(path, logger) ⇒ Puppet
Returns a new instance of Puppet.
249 250 251 252 |
# File 'lib/vagrant/puppetfile.rb', line 249 def initialize(path, logger) super @moduledir = 'modules' end |
Instance Method Details
#available? ⇒ Boolean
254 255 256 257 258 |
# File 'lib/vagrant/puppetfile.rb', line 254 def available? command('--version').last.success? rescue SystemCallError false end |
#forge(forge) ⇒ Object
277 278 279 |
# File 'lib/vagrant/puppetfile.rb', line 277 def forge(forge) @forge = forge end |
#install(puppetfile) ⇒ Object
260 261 262 263 264 |
# File 'lib/vagrant/puppetfile.rb', line 260 def install(puppetfile) validate(puppetfile) logger.detail("Notice: Evaluating #{puppetfile} ...") instance_eval(File.read(puppetfile)) end |
#mod(name, version = :latest, options = {}) ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/vagrant/puppetfile.rb', line 281 def mod(name, version = :latest, = {}) if version.is_a?(Hash) , version = version, :latest end unless .is_a?(Hash) and .empty? unsupported(, 'mod', name, version, ) end unless version.is_a?(String) or version == :latest unsupported(version, 'mod', name, version) end module_option = '--target-dir', @moduledir forge_option = '--module_repository', @forge if @forge.is_a? String version_option = '--version', version if version.is_a? String run('module', 'install', '--verbose', name, *module_option, *forge_option, *version_option) end |
#moduledir(moduledir) ⇒ Object
273 274 275 |
# File 'lib/vagrant/puppetfile.rb', line 273 def moduledir(moduledir) @moduledir = moduledir end |
#unsupported(option, method, *args) ⇒ Object
266 267 268 269 270 271 |
# File 'lib/vagrant/puppetfile.rb', line 266 def unsupported(option, method, *args) option = option.inspect args = args.map(&:inspect).join(', ') logger.error("Unsupported option #{option} in `#{method} #{args}'") fail InstallationError, path end |