Module: Puppet::Moddeps
- Defined in:
- lib/puppet/moddeps.rb,
lib/puppet/moddeps/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
- @@default_module_path =
'/etc/puppet/modules'
Class Method Summary collapse
- .checkIfInstalled(file) ⇒ Object
- .getDeps(data) ⇒ Object
- .help ⇒ Object
- .installDeps(*puppet_module) ⇒ Object
- .installModules ⇒ Object
- .parseMetadata(puppet_module) ⇒ Object
Class Method Details
.checkIfInstalled(file) ⇒ Object
35 36 37 |
# File 'lib/puppet/moddeps.rb', line 35 def Moddeps.checkIfInstalled(file) File.directory?("#{@@default_module_path}/#{file}") end |
.getDeps(data) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet/moddeps.rb', line 45 def Moddeps.getDeps(data) dependencies = [] data['dependencies'].each do |dep| depname = dep["name"].sub '/', '-' dependencies.push( depname ) end return dependencies end |
.help ⇒ Object
30 31 32 33 |
# File 'lib/puppet/moddeps.rb', line 30 def Moddeps.help puts 'Usage: puppet-moddeps module' puts ' Call puppet-moddeps with the name of one installed module' end |
.installDeps(*puppet_module) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/puppet/moddeps.rb', line 10 def Moddeps.installDeps(*puppet_module) if ( puppet_module.size >=1 and puppet_module[0].is_a?(Array) ) args = puppet_module[0] else args = puppet_module end if ( args.size == 1 ) if Moddeps.checkIfInstalled(args[0]) Moddeps.parseMetadata(args[0]) Moddeps.installModules else puts "Can't find #{args[0]} in #{@@default_module_path}" end else Moddeps.help end end |
.installModules ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/puppet/moddeps.rb', line 55 def Moddeps.installModules if @deps.size > 0 @deps.each do |dep| if Moddeps.checkIfInstalled(dep) puts "#{dep} is already installed, skipping." else cmd = "/usr/bin/puppet module install #{dep}" puts "Running \"#{cmd}\"..." %x(#{cmd}) end end else puts 'No dependencies were marked for installation.' end end |