Class: RepuppetCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/repuppet.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, env) ⇒ RepuppetCommand

Returns a new instance of RepuppetCommand.



3
4
5
6
7
# File 'lib/commands/repuppet.rb', line 3

def initialize(argv, env)
  @argv = argv
  @env  = env
  @logger = Log4r::Logger.new("vagrant::command::#{self.class.to_s.downcase}")
end

Class Method Details

.synopsisObject



9
10
11
# File 'lib/commands/repuppet.rb', line 9

def self.synopsis
  "Destroy and bring up a new puppet cluster (puppet master and puppetdb)"
end

Instance Method Details

#executeObject



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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/commands/repuppet.rb', line 13

def execute
  # Parse the options
  argv = parse_options
  return unless argv.length == 0

  #########################################
  # Destroy all the puppet infrastructure #
  #########################################
  with_target_vms('puppetdb') do |machine|
      @env.ui.info "Destroying puppet db", :color => :green
      machine.action(:destroy, :force_confirm_destroy=>true)
  end
  with_target_vms('puppet') do |machine|
      @env.ui.info "Destroying puppet"
      machine.action(:destroy, :force_confirm_destroy=>true)
  end

  ###########################################
  # Rebuild the puppet master in no-db mode #
  ###########################################
  with_target_vms('puppet') do |machine|
      @env.ui.info "rebuilding puppet", :color => :green
      machine.action(:up)

      # this is hack to get around a bug in the vagrant
      # initialization.
      # this is the issue on REHL:
      # https://github.com/mitchellh/vagrant/pull/1577
      cycle_iface machine, "eth1"

      @env.ui.info "Bootstrapping puppet master", :color => :green
      # ssh_cmd machine, "/opt/lfuserdata/puppet_master_setup.sh puppet.localdev.livefyre.com"
  end

  ########################
  # Rebuild the puppetdb #
  ########################
  with_target_vms('puppetdb') do |machine|
      @env.ui.info "rebuilding puppetdb", :color => :green
      machine.action(:up)

      # this is hack to get around a bug in the vagrant
      # initialization.
      # this is the issue on REHL:
      # https://github.com/mitchellh/vagrant/pull/1577
      cycle_iface machine, "eth1"

      # @env.ui.info "Bootstrapping puppetdb"
      # ssh_cmd machine, "/opt/lfuserdata/puppet_db_setup.sh puppetdb.localdev.livefyre.com"
      # @env.ui.info "Running puppet on puppet db"
      # ssh_cmd machine, "/opt/lfuserdata/ensure_puppet_converged.sh -w"
  end

  #####################################
  # Re-enable store configs in puppet #
  #####################################
  with_target_vms('puppet') do |machine|
      @env.ui.info "Running puppet on puppet master", :color => :green
      ssh_cmd machine, "/opt/lfuserdata/ensure_puppet_converged.sh -w"
  end
end