Class: Opsk::Package

Inherits:
Thor::Group
  • Object
show all
Includes:
Thorable, Thor::Actions
Defined in:
lib/opskeleton/package.rb

Instance Method Summary collapse

Methods included from Thorable

#artifact, #artifact_path, #check_root, included, #machines, #meta, #name, #type_of

Instance Method Details

#create_buildObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/opskeleton/package.rb', line 11

def create_build
	empty_directory(artifact_path)
	path = Dir.getwd
	meta.includes.each {|f| 
	  if(File.directory?("#{path}/#{f}"))
 directory "#{path}/#{f}", "#{artifact_path}/#{f}", :verbose => false
	  elsif(File.exist?("#{path}/#{f}"))
 copy_file "#{path}/#{f}", "#{artifact_path}/#{f}"
	  else
 raise Exception.new("#{f} not found please validate opks.yaml includes section")
	  end
	}

	meta.excludes.each {|f| remove_file("#{artifact_path}/#{f}") } if(meta.excludes)

	unless(File.exist?("#{artifact_path}/manifests/site.pp"))
	  template('templates/puppet/site.erb', "#{artifact_path}/manifests/site.pp")
	end
end

#packageObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/opskeleton/package.rb', line 42

def package
	ignored = IO.readlines('.gitignore').map(&:chomp)
	ignored.delete('modules')
	ignored = ignored.select {|ig| !meta.includes.include?(ig)}
	excludes = ignored.map{|f| "'#{f}'"}.join(" --exclude=") << ' --exclude-backups --exclude-vcs --exclude=pkg'
	tar = "#{artifact}.tar.gz"
	input = artifact
	inside('pkg') do
	  run("tar --exclude=#{excludes} -czf #{tar} #{input} >> /dev/null" , :verbose => false) 
	end

end

#scriptsObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/opskeleton/package.rb', line 31

def scripts
	empty_directory("#{artifact_path}/scripts")
	files = {:puppet => %w(lookup.rb run.sh) }
	files[type_of].each  do |s|
	  unless(File.exist?("#{artifact_path}/scripts/#{s}"))
 template("templates/#{type_of}/scripts/#{s}", "#{artifact_path}/scripts/#{s}")
 chmod("#{artifact_path}/scripts/#{s}", 0755)
	  end
	end
end

#validateObject



7
8
9
# File 'lib/opskeleton/package.rb', line 7

def validate
	check_root
end