Last active
August 29, 2015 14:17
-
-
Save acidprime/940f75d82e7acb21babc to your computer and use it in GitHub Desktop.
This is a Puppetfile that will automatically download all supported+approved modules from the forge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'puppet_forge' | |
# Example of a module from an internal repo co-existing with forge modules. | |
#mod 'splunk', | |
# :git => 'https://internal.git.server/example/puppet-splunk.git', | |
# :commit => '3ca47046a86aef9fbfdf58cc7b418d8e7254ecb9' | |
@dependencies = [] | |
@approved = [] | |
@supported = [] | |
def populate_module_dependencies(forge_module) | |
forge_module.current_release.metadata['dependencies'].each do |dependency| | |
@dependencies << dependency['name'] | |
end | |
end | |
def add_modules() | |
modules = (@dependencies << @approved << @supported).flatten | |
modules.compact.uniq.each do |dependency| | |
mod dependency.sub('-','/') | |
end | |
end | |
def populate_supported_modules | |
PuppetForge::Module.where( supported: 'true' ).unpaginated.each do |supported| | |
@supported << "#{supported.owner.username}/#{supported.name}" | |
populate_module_dependencies supported | |
end | |
end | |
def populate_approved_modules | |
PuppetForge::Module.where( endorsements: 'approved' ).unpaginated.each do |approved| | |
@approved << "#{approved.owner.username}/#{approved.name}" | |
populate_module_dependencies approved | |
end | |
end | |
populate_supported_modules | |
populate_approved_modules | |
add_modules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can test this locally with the following:
gem install puppet_forge
gem install r10k
git clone [email protected]:/940f75d82e7acb21babc.git
cd 940f75d82e7acb21babc/
r10k puppetfile install -v debug
ls -l ./modules