Class: Prepper::Runner
- Inherits:
-
Object
- Object
- Prepper::Runner
- Defined in:
- lib/prepper/runner.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#host ⇒ Object
Returns the value of attribute host.
-
#packages ⇒ Object
Returns the value of attribute packages.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #add_command(command, opts = {}) ⇒ Object
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #package(name, opts = {}, &block) ⇒ Object
- #run ⇒ Object
- #server_hash ⇒ Object
- #server_host(host) ⇒ Object
- #server_port(port) ⇒ Object
- #server_user(user) ⇒ Object
- #ssh_options(ssh_options) ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
14 15 16 17 18 19 |
# File 'lib/prepper/runner.rb', line 14 def initialize @packages = [] @commands = [] @user = "root" @port = 22 end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
6 7 8 |
# File 'lib/prepper/runner.rb', line 6 def commands @commands end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/prepper/runner.rb', line 6 def host @host end |
#packages ⇒ Object
Returns the value of attribute packages.
6 7 8 |
# File 'lib/prepper/runner.rb', line 6 def packages @packages end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/prepper/runner.rb', line 6 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/prepper/runner.rb', line 6 def user @user end |
Class Method Details
.run(config) ⇒ Object
8 9 10 11 12 |
# File 'lib/prepper/runner.rb', line 8 def self.run(config) runner = new runner.instance_eval config runner.run end |
Instance Method Details
#add_command(command, opts = {}) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/prepper/runner.rb', line 46 def add_command(command, opts = {}) package = Package.new("base", opts) package.runner = self opts[:user] ||= "root" opts[:within] ||= "/" package.commands << Command.new(command, opts) @packages << package end |
#package(name, opts = {}, &block) ⇒ Object
55 56 57 |
# File 'lib/prepper/runner.rb', line 55 def package(name, opts = {}, &block) @packages << Package.new(name, opts.merge(runner: self), &block) end |
#run ⇒ Object
21 22 23 24 |
# File 'lib/prepper/runner.rb', line 21 def run puts "running on #{host}" @packages.each(&:process) end |
#server_hash ⇒ Object
42 43 44 |
# File 'lib/prepper/runner.rb', line 42 def server_hash {hostname: host, user: user, port: port, ssh_options: @ssh_options} end |
#server_host(host) ⇒ Object
26 27 28 |
# File 'lib/prepper/runner.rb', line 26 def server_host(host) @host = host end |
#server_port(port) ⇒ Object
34 35 36 |
# File 'lib/prepper/runner.rb', line 34 def server_port(port) @port = port end |
#server_user(user) ⇒ Object
30 31 32 |
# File 'lib/prepper/runner.rb', line 30 def server_user(user) @user = user end |
#ssh_options(ssh_options) ⇒ Object
38 39 40 |
# File 'lib/prepper/runner.rb', line 38 def () @ssh_options = end |