Class: DanarchyDeploy::System::Cryptsetup

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy/system/cryptsetup.rb

Class Method Summary collapse

Class Method Details

.new(os, cryptsetup, options) ⇒ Object



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
# File 'lib/danarchy_deploy/system/cryptsetup.rb', line 5

def self.new(os, cryptsetup, options)
  return false if cryptsetup.nil?
  puts "\n" + self.name

  # expects object: {
  # "cryptsetup": {
  #       "source": "/danarchy/deploy/templates/system/cryptsetup.erb", (optional)
  #       "volumes": {
  #               "vg_name:vg0:/dev/vdb": {
  #                       "target": "dm-vg0-mongodb",
  #                       "source": "/dev/mapper/vg0-mongodb",
  #                       "key": "/root/vdb_mongodb.key" } } } }

  if os == 'gentoo'
    DanarchyDeploy::Services::Init.init_manager(os, 'lvmetad', 'enable', options)
    DanarchyDeploy::Services::Init.init_manager(os, 'lvmetad', 'start', options)
  end

  service, target, source = set_config(cryptsetup, options)
  lvm_result, crypt_result = nil
  cryptsetup[:volumes].each do |device, volume|
    lvm_result   = lvm_setup(device, volume, options)
    crypt_result = encrypt_volume(volume, options)
  end

  deploy_template(target, source, cryptsetup[:volumes], options)
  if os == 'gentoo'
    DanarchyDeploy::Services::Init.init_manager(os, service, 'enable', options)
    DanarchyDeploy::Services::Init.init_manager(os, service, 'start', options)
  end
end