Class: Opsk::Package
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Opsk::Package
- Includes:
- Thorable, Thor::Actions
- Defined in:
- lib/opskeleton/package.rb
Instance Method Summary collapse
- #artifact ⇒ Object
- #artifact_path ⇒ Object
- #create_build ⇒ Object
- #create_pkg ⇒ Object
- #meta ⇒ Object
- #name ⇒ Object
- #package ⇒ Object
- #scripts ⇒ Object
Methods included from Thorable
Instance Method Details
#artifact ⇒ Object
13 14 15 |
# File 'lib/opskeleton/package.rb', line 13 def artifact "#{name}-#{meta.version}" end |
#artifact_path ⇒ Object
17 18 19 |
# File 'lib/opskeleton/package.rb', line 17 def artifact_path "pkg/#{name}-#{meta.version}" end |
#create_build ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/opskeleton/package.rb', line 21 def create_build empty_directory(artifact_path) path = Dir.getwd directory path, artifact_path, :verbose => false unless(File.exists?("#{artifact_path}/manifests/site.pp")) template('templates/puppet/site.erb', "#{artifact_path}/manifests/site.pp") end end |
#create_pkg ⇒ Object
44 45 46 |
# File 'lib/opskeleton/package.rb', line 44 def create_pkg empty_directory('pkg') end |
#meta ⇒ Object
5 6 7 |
# File 'lib/opskeleton/package.rb', line 5 def OpenStruct.new(YAML.load_file('opsk.yml')) end |
#name ⇒ Object
9 10 11 |
# File 'lib/opskeleton/package.rb', line 9 def name File.basename(Dir.getwd) end |
#package ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/opskeleton/package.rb', line 48 def package ignored = IO.readlines('.gitignore').map(&:chomp) ignored.delete('modules') ignored.delete('cookbooks') 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 |
#scripts ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/opskeleton/package.rb', line 30 def scripts type = :puppet if File.exists?("#{artifact_path}/Puppetfile") type = :chef if File.exists?("#{artifact_path}/Cheffile") raise Exception.new('not matching provisoner type found') if type.nil? empty_directory("#{artifact_path}/scripts") files = {:puppet => %w(lookup.rb run.sh) , :chef => [] } files[type].each do |s| unless(File.exists?("#{artifact_path}/scripts/#{s}")) template("templates/#{type}/scripts/#{s}", "#{artifact_path}/scripts/#{s}") chmod("#{artifact_path}/scripts/#{s}", 0755) end end end |