Class: ChefMetal::ConvergenceStrategy::InstallSh
- Inherits:
-
PrecreateChefObjects
- Object
- ChefMetal::ConvergenceStrategy
- PrecreateChefObjects
- ChefMetal::ConvergenceStrategy::InstallSh
- Defined in:
- lib/chef_metal/convergence_strategy/install_sh.rb
Constant Summary collapse
- @@install_sh_cache =
{}
Instance Attribute Summary collapse
-
#install_sh_path ⇒ Object
readonly
Returns the value of attribute install_sh_path.
-
#install_sh_url ⇒ Object
readonly
Returns the value of attribute install_sh_url.
Attributes inherited from PrecreateChefObjects
#client_pem_path, #client_rb_path
Instance Method Summary collapse
- #converge(action_handler, machine, chef_server) ⇒ Object
-
#initialize(options = {}) ⇒ InstallSh
constructor
A new instance of InstallSh.
- #setup_convergence(action_handler, machine, machine_resource) ⇒ Object
Methods inherited from PrecreateChefObjects
Methods inherited from ChefMetal::ConvergenceStrategy
Constructor Details
#initialize(options = {}) ⇒ InstallSh
Returns a new instance of InstallSh.
9 10 11 12 13 14 15 |
# File 'lib/chef_metal/convergence_strategy/install_sh.rb', line 9 def initialize( = {}) @install_sh_url = [:install_sh_url] || 'http://www.opscode.com/chef/install.sh' @install_sh_path = [:install_sh_path] || '/tmp/chef-install.sh' @client_rb_path ||= '/etc/chef/client.rb' @client_pem_path ||= '/etc/chef/client.pem' @chef_client_timeout = .has_key?(:chef_client_timeout) ? [:chef_client_timeout] : 120*60 # Default: 2 hours end |
Instance Attribute Details
#install_sh_path ⇒ Object (readonly)
Returns the value of attribute install_sh_path.
18 19 20 |
# File 'lib/chef_metal/convergence_strategy/install_sh.rb', line 18 def install_sh_path @install_sh_path end |
#install_sh_url ⇒ Object (readonly)
Returns the value of attribute install_sh_url.
17 18 19 |
# File 'lib/chef_metal/convergence_strategy/install_sh.rb', line 17 def install_sh_url @install_sh_url end |
Instance Method Details
#converge(action_handler, machine, chef_server) ⇒ Object
32 33 34 35 36 |
# File 'lib/chef_metal/convergence_strategy/install_sh.rb', line 32 def converge(action_handler, machine, chef_server) super machine.execute(action_handler, "chef-client -l #{Chef::Config.log_level.to_s}", :stream => true, :timeout => @chef_client_timeout) end |
#setup_convergence(action_handler, machine, machine_resource) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chef_metal/convergence_strategy/install_sh.rb', line 20 def setup_convergence(action_handler, machine, machine_resource) super # Install chef-client. TODO check and update version if not latest / not desired if machine.execute_always('chef-client -v').exitstatus != 0 # TODO ssh verification of install.sh before running arbtrary code would be nice? @@install_sh_cache[install_sh_url] ||= Net::HTTP.get(URI(install_sh_url)) machine.write_file(action_handler, install_sh_path, @@install_sh_cache[install_sh_url], :ensure_dir => true) machine.execute(action_handler, "bash #{install_sh_path}") end end |