Method: PDQTest::Puppet.install_modules
- Defined in:
- lib/pdqtest/puppet.rb
.install_modules ⇒ Object
extract a Puppetfile from metadata.json and install modules using r10k
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/pdqtest/puppet.rb', line 322 def self.install_modules() json = JSON.parse(File.read(METADATA)) puppetfile = [] if json.has_key?("dependencies") json["dependencies"].each { |dependency| line = "mod '#{dependency['name']}'" if dependency.has_key?("version_requirement") # R10K supports specifc named version or 'latest', not the rich versions defined in metadata. To make this # work we will drop any version that specifies a range and just install the latest if dependency['version_requirement'].match?(/^\d/) line += ", '#{dependency['version_requirement']}'" end end puppetfile << line } end File.open(TMP_PUPPETFILE, "w") do |f| f.puts(puppetfile) end PDQTest::Emoji.("🐌", "I'm downloading The Internet, please hold...") cmd = "bundle exec r10k puppetfile install --verbose --moduledir ./spec/fixtures/modules --puppetfile #{TMP_PUPPETFILE}" status = system(cmd) if ! status Escort::Logger.error.error "Failed to run the R10K command: #{cmd}" end status end |