Class: SimpleProvision::CLI
- Inherits:
-
Object
- Object
- SimpleProvision::CLI
- Defined in:
- lib/simple_provision/cli.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #configure ⇒ Object
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(args) ⇒ CLI
6 7 8 9 10 |
# File 'lib/simple_provision/cli.rb', line 6 def initialize(args) @profile = args[:profile] @username = args[:username] @host = args[:host] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/simple_provision/cli.rb', line 5 def host @host end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
5 6 7 |
# File 'lib/simple_provision/cli.rb', line 5 def profile @profile end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/simple_provision/cli.rb', line 5 def username @username end |
Instance Method Details
#bootstrap ⇒ Object
12 13 14 |
# File 'lib/simple_provision/cli.rb', line 12 def bootstrap SimpleProvision::SCP.new(username, host, ).copy_files end |
#configure ⇒ Object
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 |
# File 'lib/simple_provision/cli.rb', line 16 def configure begin Net::SSH.start(host, username, :forward_agent => true) do |ssh| ssh.exec! "tar -xzf #{SimpleProvision::SCP::FILENAME}" scripts = .fetch(:scripts).each do |script| puts "Execute #{script}" ssh.open_channel do |ssh_channel| ssh_channel.request_pty ssh_channel.exec("#{environment_exports} bash -c '#{script}'") do |channel, success| unless success raise "Could not execute command: #{command.inspect}" end channel.on_data do |ch, data| STDOUT << data end channel.on_extended_data do |ch, type, data| next unless type == 1 STDERR << data end end end ssh.loop end end rescue Net::SSH::HostKeyMismatch => exception exception.remember_host! sleep 0.2 retry end end |