Module: JimboDragon

Defined in:
lib/jimbodragon.rb,
lib/jimbodragon/main.rb,
lib/jimbodragon/knife.rb,
lib/jimbodragon/deploy.rb,
lib/jimbodragon/jimboenv.rb,
lib/jimbodragon/convergence.rb

Defined Under Namespace

Modules: Convergence, JimboEnv Classes: Deploy, Knife, Main

Class Method Summary collapse

Class Method Details

.converge(knife_or_chefclient) ⇒ Object



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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/jimbodragon.rb', line 8

def self.converge(knife_or_chefclient)
  extend JimboDragon::JimboEnv
  extend JimboDragon::Convergence

  deploy = JimboDragon::Deploy.new

  case knife_or_chefclient
  when JimboDragon::Main
    install_chef
    [
      "chef exec knife cookbook upload #{[
        JimboDragon::JimboEnv::NAMED_RUN_LIST,
        JimboDragon::JimboEnv::GEM_PROJECT_NAME,
      ].flatten.join(' ')}",
      "chef-client -r #{JimboDragon::JimboEnv::NAMED_RUN_LIST}",
      "chef gem build #{JimboDragon::JimboEnv::GEM_PROJECT_NAME}.gemspec",
      "chef gem push #{JimboDragon::JimboEnv::GEM_PROJECT_NAME}-#{JimboDragon::JimboEnv::GEM_PROJECT_VERSION}.gem",
      "chef gem install #{JimboDragon::JimboEnv::GEM_PROJECT_NAME}",
    ].each do |command|
      puts "Executing command #{command}"
      deploy.deploy_commands.push command
    end
  else
    case knife_or_chefclient.to_s
    when 'ChefConfig::Config'
      Chef::Log.warn('Haha Chef is now in use')
      JimboDragon::Knife.new(knife_or_chefclient).load_knife
    else
      if respond_to? :logger
        logger.warn "knife_or_chefclient = #{logger.class}"
        case logger
        when nil
          logger.warn "knife_or_chefclient = #{logger.class}"
        else
          logger.warn "knife_or_chefclient = #{knife_or_chefclient.class}"
        end
      elsif respond_to? :Chef
        Chef::Log.warn "knife_or_chefclient = #{knife_or_chefclient.to_s}"
      else
        puts "knife_or_chefclient = #{knife_or_chefclient.to_s}"
      end
    end
  end

  prepare_project
  deploy.execute_deploy_command
  finalize_project
end