Class: Hetzner::Bootstrap::CoreOS
- Inherits:
-
Object
- Object
- Hetzner::Bootstrap::CoreOS
- Defined in:
- lib/hetzner-bootstrap-coreos.rb,
lib/hetzner/bootstrap/coreos/target.rb,
lib/hetzner/bootstrap/coreos/version.rb,
lib/hetzner/bootstrap/coreos/cloud_config.rb
Defined Under Namespace
Classes: CloudConfig, Target
Constant Summary collapse
- VERSION =
'0.0.2'
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#api ⇒ Object
Returns the value of attribute api.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#targets ⇒ Object
Returns the value of attribute targets.
Instance Method Summary collapse
- #<<(param) ⇒ Object
- #add_target(param) ⇒ Object
- #bootstrap!(options = {}) ⇒ Object
- #bootstrap_one_target!(target) ⇒ Object
-
#initialize(options = {}) ⇒ CoreOS
constructor
A new instance of CoreOS.
Constructor Details
#initialize(options = {}) ⇒ CoreOS
Returns a new instance of CoreOS.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 17 def initialize( = {}) @targets = [] @actions = %w(enable_rescue_mode reset wait_for_ssh_down wait_for_ssh_up installimage reboot wait_for_ssh_down wait_for_ssh_up verify_installation update_local_known_hosts post_install post_install_remote) @api = [:api] @logger = [:logger] || Logger.new(STDOUT) end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
14 15 16 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 14 def actions @actions end |
#api ⇒ Object
Returns the value of attribute api.
13 14 15 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 13 def api @api end |
#logger ⇒ Object
Returns the value of attribute logger.
15 16 17 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 15 def logger @logger end |
#targets ⇒ Object
Returns the value of attribute targets.
12 13 14 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 12 def targets @targets end |
Instance Method Details
#<<(param) ⇒ Object
43 44 45 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 43 def <<(param) add_target param end |
#add_target(param) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 35 def add_target(param) if param.is_a? Hetzner::Bootstrap::CoreOS::Target @targets << param else @targets << (Hetzner::Bootstrap::CoreOS::Target.new param) end end |
#bootstrap!(options = {}) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 47 def bootstrap!( = {}) @targets.each do |target| target.use_api @api target.use_logger @logger bootstrap_one_target! target end end |
#bootstrap_one_target!(target) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hetzner-bootstrap-coreos.rb', line 55 def bootstrap_one_target!(target) actions = (target.actions || @actions) actions.each_with_index do |action, index| loghack = "\b" * 24 # remove: "[bootstrap_one_target!] ".length target.logger.info "#{loghack}[#{action}] #{sprintf "%-20s", "START"}" d = Benchmark.realtime do target.send action end target.logger.info "#{loghack}[#{action}] FINISHED in #{sprintf "%.5f",d} seconds" end rescue => e puts "Something bad happened unexpectedly: #{e.class} => #{e.message}" end |