Class: Circus::Profiles::ChefStack

Inherits:
Base
  • Object
show all
Defined in:
lib/circus/profiles/chef_stack.rb

Overview

A Chef Stack provides the ability to trigger deployment of system packages and configuration.

Constant Summary collapse

CHEF_STACK_PROPERTY =
'chef-stack'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cleanup_after_deploy, #extra_dirs, #package_base_dir?, #package_for_deploy, #package_for_dev

Constructor Details

#initialize(name, dir, props) ⇒ ChefStack

Returns a new instance of ChefStack.



16
17
18
19
20
# File 'lib/circus/profiles/chef_stack.rb', line 16

def initialize(name, dir, props)
  super(name, dir, props)
  
  @stack_script = props[CHEF_STACK_PROPERTY] || "stack.yaml"
end

Class Method Details

.accepts?(name, dir, props) ⇒ Boolean

Checks if this is a chef stack applcation. Will accept the application if it has a file named stack.yaml, or has a ‘chef-stack’ property describing the entry point.

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/circus/profiles/chef_stack.rb', line 11

def self.accepts?(name, dir, props)
  return true if props.include? CHEF_STACK_PROPERTY
  return File.exists?(File.join(dir, "stack.yaml"))
end

Instance Method Details

#deploy_run_script_contentObject



64
65
66
67
68
69
70
# File 'lib/circus/profiles/chef_stack.rb', line 64

def deploy_run_script_content
  shell_run_script do
    <<-EOT
    exec chef-solo -c solo-stack.rb -j stack.json
    EOT
  end
end

#dev_run_script_contentObject



42
43
44
45
46
47
48
49
# File 'lib/circus/profiles/chef_stack.rb', line 42

def dev_run_script_content
  shell_run_script do
    <<-EOT
    cd #{@dir}
    exec echo "Stacks cannot be run in development"
    EOT
  end
end

#mark_for_persistent_run?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/circus/profiles/chef_stack.rb', line 33

def mark_for_persistent_run?
  false
end

#nameObject

The name of this profile



23
24
25
# File 'lib/circus/profiles/chef_stack.rb', line 23

def name
  "chef-stack"
end

#prepare_for_deploy(logger, overlay_dir) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/circus/profiles/chef_stack.rb', line 51

def prepare_for_deploy(logger, overlay_dir)
  # Generate a chef configuration file
  stack_config = YAML::load(File.read(File.join(@dir, @stack_script)))
  File.open(File.join(overlay_dir, 'stack.json'), 'w') do |f|
    f.write(stack_config.to_json)
  end
  File.open(File.join(overlay_dir, 'solo-stack.rb'), 'w') do |f|
    f << "cookbook_path File.expand_path('../cookbooks', __FILE__)"
  end
  
  true
end

#requirementsObject



27
28
29
30
31
# File 'lib/circus/profiles/chef_stack.rb', line 27

def requirements
  reqs = super
  reqs['execution-user'] = 'root'
  reqs
end

#supported_for_development?Boolean

Stacks are not useful in development

Returns:

  • (Boolean)


38
39
40
# File 'lib/circus/profiles/chef_stack.rb', line 38

def supported_for_development?
  false
end