Module: Opsk::Thorable

Included in:
Bump, Clean, Deploy, Dockerize, GenerateChef, GeneratePuppet, Module, Package
Defined in:
lib/opskeleton/thorable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/opskeleton/thorable.rb', line 3

def self.included klass
	def klass.source_root
	  # during dev time
	  if(File.dirname(__FILE__) == './bin')
 File.dirname('.')
	  else 
 "#{File.dirname(__FILE__)}/../../"
	  end
	end
end

Instance Method Details

#artifactObject



28
29
30
# File 'lib/opskeleton/thorable.rb', line 28

def artifact
	"#{name}-#{meta.version}"
end

#artifact_pathObject



32
33
34
# File 'lib/opskeleton/thorable.rb', line 32

def artifact_path
	"pkg/#{name}-#{meta.version}"
end

#machinesObject



36
37
38
39
40
41
42
43
# File 'lib/opskeleton/thorable.rb', line 36

def machines
	machines = %x{vagrant status --machine-readable 2>&1}	
	unless $? == 0
    $stderr.puts "failed to parse vagrant machines #{machines}"
	  exit 1 
	end
	machines.split('\n').collect {|line| line.split(',')[1]}.find_all{|v| v}
end

#metaObject



14
15
16
# File 'lib/opskeleton/thorable.rb', line 14

def meta 
	OpenStruct.new(YAML.load_file('opsk.yaml'))
end

#nameObject



24
25
26
# File 'lib/opskeleton/thorable.rb', line 24

def name 
	"#{meta.name}-sandbox"
end

#type_ofObject

Raises:

  • (Exception)


18
19
20
21
22
# File 'lib/opskeleton/thorable.rb', line 18

def type_of
	return :puppet if meta.includes.include?('Puppetfile')
	return :chef if meta.includes.include?('Cheffile')
	raise Exception.new('no matching provisoner type found, make sure to include Cheffile or Pupppetfile in opsk.yaml')
end