Module: DanarchyDeploy::System

Defined in:
lib/danarchy_deploy/system.rb,
lib/danarchy_deploy/system/fstab.rb,
lib/danarchy_deploy/system/centos.rb,
lib/danarchy_deploy/system/debian.rb,
lib/danarchy_deploy/system/gentoo.rb,
lib/danarchy_deploy/system/opensuse.rb,
lib/danarchy_deploy/system/cryptsetup.rb

Defined Under Namespace

Classes: CentOS, Cryptsetup, Debian, Fstab, Gentoo, OpenSUSE

Class Method Summary collapse

Class Method Details

.new(deployment, options) ⇒ Object



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
39
40
41
42
43
44
45
46
47
48
# File 'lib/danarchy_deploy/system.rb', line 11

def self.new(deployment, options)
  abort('Operating System not defined! Exiting!') if !deployment[:os]
  puts "\n" + self.name

  installer, updater, cleaner = prep_operating_system(deployment, options)
  install_result, updater_result = nil, nil

  puts "\n > Package Installation"
  if [true, 'all', 'selected', nil].include?(deployment[:system][:update]) &&
     deployment[:packages].any?
    packages = deployment[:packages].join(' ')
    puts "\n   - Installing packages..."
    install_result = DanarchyDeploy::Helpers.run_command("#{installer} #{packages}", options)
    puts install_result[:stdout] if install_result[:stdout]
  else
    puts "\n   - Not installing packages."
    puts "       |_ Packages selected: #{deployment[:packages].count}"
    puts "       |_ Install/Update: #{deployment[:system][:update]}"
  end

  puts "\n > #{deployment[:os].capitalize} System Updates"
  if [true, 'all', 'system', nil].include?(deployment[:system][:update])
    puts "\n   - Running system updates..."
    updater_result = DanarchyDeploy::Helpers.run_command(updater, options)
    puts updater_result[:stdout] if updater_result[:stdout]
  else
    puts "\n   - Not running #{deployment[:os].capitalize} system updates."
    puts "       |_ Install/Update: #{deployment[:system][:update]}"
  end

  if install_result || updater_result
    puts "\n   - Cleaning up unused packages..."
    cleanup_result = DanarchyDeploy::Helpers.run_command(cleaner, options)
    puts cleanup_result[:stdout] if cleanup_result[:stdout]
  end

  deployment
end