Class: Cucumber::Chef::Bootstrap
- Inherits:
-
Object
- Object
- Cucumber::Chef::Bootstrap
- Defined in:
- lib/cucumber/chef/bootstrap.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout = STDOUT, stderr = STDERR, stdin = STDIN) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
- #run ⇒ Object
Constructor Details
#initialize(stdout = STDOUT, stderr = STDERR, stdin = STDIN) ⇒ Bootstrap
Returns a new instance of Bootstrap.
32 33 34 35 36 37 38 39 |
# File 'lib/cucumber/chef/bootstrap.rb', line 32 def initialize(stdout=STDOUT, stderr=STDERR, stdin=STDIN) @stdout, @stderr, @stdin = stdout, stderr, stdin @stdout.sync = true if @stdout.respond_to?(:sync=) @ssh = Cucumber::Chef::SSH.new(@stdout, @stderr, @stdin) @config = Hash.new(nil) @config[:context] = Hash.new(nil) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
28 29 30 |
# File 'lib/cucumber/chef/bootstrap.rb', line 28 def config @config end |
#stderr ⇒ Object
Returns the value of attribute stderr.
28 29 30 |
# File 'lib/cucumber/chef/bootstrap.rb', line 28 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
28 29 30 |
# File 'lib/cucumber/chef/bootstrap.rb', line 28 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
28 29 30 |
# File 'lib/cucumber/chef/bootstrap.rb', line 28 def stdout @stdout end |
Instance Method Details
#run ⇒ Object
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 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/cucumber/chef/bootstrap.rb', line 43 def run $logger.debug { "config(#{@config.inspect})" } if !@config[:template_file] = "You must supply a 'template_file' option." $logger.fatal { } raise BootstrapError, end if !@config[:host] = "You must supply a 'host' option." $logger.fatal { } raise BootstrapError, end if !@config[:ssh_user] = "You must supply a 'ssh_user' option." $logger.fatal { } raise BootstrapError, end if (!@config[:ssh_password] && !@config[:identity_file]) = "You must supply a 'ssh_password' or 'identity_file' option." $logger.fatal { } raise BootstrapError, end $logger.debug { "prepare(#{@config[:host]})" } @ssh.config[:host] = @config[:host] @ssh.config[:ssh_user] = @config[:ssh_user] @ssh.config[:ssh_password] = @config[:ssh_password] @ssh.config[:identity_file] = @config[:identity_file] @ssh.config[:timeout] = 5 $logger.debug { "template_file(#{@config[:template_file]})" } command = Cucumber::Chef::Template.render(@config[:template_file], @config[:context]) command = "sudo #{command}" if @config[:use_sudo] $logger.debug { "begin(#{@config[:host]})" } @ssh.exec(command, :silence => true) $logger.debug { "end(#{@config[:host]})" } end |