Skip to content

Instantly share code, notes, and snippets.

@gregswift
Last active December 18, 2017 02:00
Show Gist options
  • Save gregswift/84a5ba3c303c0c35f9d3 to your computer and use it in GitHub Desktop.
Save gregswift/84a5ba3c303c0c35f9d3 to your computer and use it in GitHub Desktop.
Sourcing puppet modules from yaml
require 'yaml'
mypath = File.expand_path(File.dirname(__FILE__))
# Load configuration from config.yml
conf = YAML::load_file("#{mypath}/Puppetfile.yml")
forge_conf = conf.fetch('forge', nil)
if forge_conf.nil?
forge = ""
else
forge, modules = forge_conf.first
modules.each { |m|
if m.is_a?(Hash)
name, version = m.first
if version == 'latest'
mod name, :latest
else
mod name, version
end
else
mod m
end
}
end
conf['git'].each { |org_uri, modules|
modules.each { |m|
if !(m.is_a?(Hash))
m = { m => 'master' }
end
repo, ref = m.first
name = repo.split('-', 2)[-1].gsub(/-/, '_')
git = "#{org_uri}/#{repo}.git"
mod name, :git => git, :ref => ref
}
}
forge:
"https://forgeapi.puppetlabs.com":
- bfraser/grafana
- bmurt/puppet_agent: 0.0.4
- camptocamp/augeas: latest
git:
"https://github.com":
- jenkinsci/puppet-jenkins: v1.5.0
- ripienaar/puppet-module-data: 0.0.4
- rackerlabs/puppet-repose: 1.6.0
"git@github.example.com:ops":
- puppet-profile_crm: 0.1.12
- puppet-profile_docker: 0.3.1
- puppet-profile_java_app_server: 0.1.1
- puppet-profile_jenkins: 1.4.0
- puppet-repo: 0.3.1
"git@github.example.com:config-management-modules":
- puppet-passwordsafe: 0.3.5
@cetanu
Copy link

cetanu commented Dec 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment