Class: DeployRubygem::Kitchen

Inherits:
Object
  • Object
show all
Defined in:
lib/deploy_rubygem/kitchen.rb

Overview

Using Kitchen to deploy and manage Kitchen

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kitchen_name, cookbook) ⇒ Kitchen

Returns a new instance of Kitchen.



10
11
12
13
# File 'lib/deploy_rubygem/kitchen.rb', line 10

def initialize(kitchen_name, cookbook)
  @kitchen_name = kitchen_name
  @cookbook = cookbook
end

Instance Attribute Details

#cookbookObject (readonly)

Returns the value of attribute cookbook.



8
9
10
# File 'lib/deploy_rubygem/kitchen.rb', line 8

def cookbook
  @cookbook
end

#kitchen_nameObject (readonly)

Returns the value of attribute kitchen_name.



8
9
10
# File 'lib/deploy_rubygem/kitchen.rb', line 8

def kitchen_name
  @kitchen_name
end

Instance Method Details

#check_fileObject



15
16
17
# File 'lib/deploy_rubygem/kitchen.rb', line 15

def check_file
  ::File.join("#{kitchen_name}_check.log")
end

#convergeObject



19
20
21
# File 'lib/deploy_rubygem/kitchen.rb', line 19

def converge
  system("kitchen converge #{kitchen_name}")
end

#destroyObject



23
24
25
# File 'lib/deploy_rubygem/kitchen.rb', line 23

def destroy
  system("kitchen destroy #{kitchen_name}")
end

#ipObject



27
28
29
30
# File 'lib/deploy_rubygem/kitchen.rb', line 27

def ip
  switch_to_cookbook
  system("kitchen exec #{kitchen_name} -c 'hostname -I'")
end

#targetObject



41
42
43
44
# File 'lib/deploy_rubygem/kitchen.rb', line 41

def target
  verify(showing: false)
  system("grep -n Target #{check_file}")
end

#verify(showing: true) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/deploy_rubygem/kitchen.rb', line 32

def verify(showing: true)
  cookbook.switch_to_cookbook
  if showing
    system("kitchen verify #{kitchen_name}")
  else
    system("kitchen verify #{kitchen_name} > #{check_file}")
  end
end