-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vagrant_init.rb
executable file
·38 lines (30 loc) · 1.19 KB
/
.vagrant_init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env ruby
##########################################################################
# vagrant_init.rb
# @author Sebastien Varrette <[email protected]>
# Time-stamp: <Lun 2015-03-30 22:42 svarrette>
#
# @description
#
# Copyright (c) 2014 Sebastien Varrette <[email protected]>
# . http://varrette.gforge.uni.lu
##############################################################################
require 'json'
require 'falkorlib'
include FalkorLib::Common
# Load metadata
basedir = File.directory?('/vagrant') ? '/vagrant' : Dir.pwd
jsonfile = File.join( basedir, 'metadata.json')
error "Unable to find the metadata.json" unless File.exists?(jsonfile)
metadata = JSON.parse( IO.read( jsonfile ) )
name = metadata["name"].gsub(/^[^\/-]+[\/-]/,'')
metadata["dependencies"].each do |dep|
lib = dep["name"]
run %{ puppet module install #{lib} }
end
modulepath=`puppet config print modulepath`.chomp
moduledir=modulepath.split(':').first
puts "Module path: #{modulepath}"
puts "Moduledir: #{moduledir}"
info "set symlink to the '#{basedir}' module for local developments"
run %{ ln -s #{basedir} #{moduledir}/#{name} } unless File.exists?("#{moduledir}/#{name}")