Class: Provisioner::Command::Bootstrap::HostCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/provisioner/command/bootstrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, context) ⇒ HostCommand

Returns a new instance of HostCommand.



25
26
27
28
# File 'lib/provisioner/command/bootstrap.rb', line 25

def initialize(name, context)
  @name = name
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



24
25
26
# File 'lib/provisioner/command/bootstrap.rb', line 24

def context
  @context
end

#nameObject

Returns the value of attribute name.



24
25
26
# File 'lib/provisioner/command/bootstrap.rb', line 24

def name
  @name
end

Instance Method Details

#bootstrap_commandObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/provisioner/command/bootstrap.rb', line 38

def bootstrap_command
  bootstrap_command = [
      'knife bootstrap',
      ip_for_host,
      "--bootstrap-template #{context.distro}",
      "--environment #{context.environment}",
      "--node-name #{name}",
  ]

  bootstrap_command << "--run-list #{context.run_list}" if context.run_list
  bootstrap_command << "--ssh-user #{context.ssh_user}"
  bootstrap_command << '--sudo' if context.use_sudo?
  bootstrap_command << "2>&1 > #{context.log_dir}/#{name}_provision.log &"
  bootstrap_command.join(' ')
end

#ip_for_hostObject



30
31
32
# File 'lib/provisioner/command/bootstrap.rb', line 30

def ip_for_host
  Provisioner::HostIP.ip_for name
end

#reset_commandObject



34
35
36
# File 'lib/provisioner/command/bootstrap.rb', line 34

def reset_command
  "ssh #{ip_for_host} -l #{context.ssh_user} 'sudo rm -rf /etc/chef'"
end