Class: ChefMetal::ConvergenceStrategy::InstallMsi
- Inherits:
-
PrecreateChefObjects
- Object
- ChefMetal::ConvergenceStrategy
- PrecreateChefObjects
- ChefMetal::ConvergenceStrategy::InstallMsi
- Defined in:
- lib/chef_metal/convergence_strategy/install_msi.rb
Constant Summary collapse
- @@install_msi_cache =
{}
Instance Attribute Summary collapse
-
#install_msi_path ⇒ Object
readonly
Returns the value of attribute install_msi_path.
-
#install_msi_url ⇒ Object
readonly
Returns the value of attribute install_msi_url.
Attributes inherited from PrecreateChefObjects
#client_pem_path, #client_rb_path
Instance Method Summary collapse
- #converge(action_handler, machine) ⇒ Object
-
#initialize(options = {}) ⇒ InstallMsi
constructor
A new instance of InstallMsi.
- #setup_convergence(action_handler, machine, machine_resource) ⇒ Object
Methods inherited from PrecreateChefObjects
Methods inherited from ChefMetal::ConvergenceStrategy
Constructor Details
#initialize(options = {}) ⇒ InstallMsi
Returns a new instance of InstallMsi.
9 10 11 12 |
# File 'lib/chef_metal/convergence_strategy/install_msi.rb', line 9 def initialize( = {}) @install_msi_url = [:install_msi_url] || 'http://www.opscode.com/chef/install.msi' @install_msi_path = [:install_msi_path] || "%TEMP%\\#{File.basename(@install_msi_url)}" end |
Instance Attribute Details
#install_msi_path ⇒ Object (readonly)
Returns the value of attribute install_msi_path.
15 16 17 |
# File 'lib/chef_metal/convergence_strategy/install_msi.rb', line 15 def install_msi_path @install_msi_path end |
#install_msi_url ⇒ Object (readonly)
Returns the value of attribute install_msi_url.
14 15 16 |
# File 'lib/chef_metal/convergence_strategy/install_msi.rb', line 14 def install_msi_url @install_msi_url end |
Instance Method Details
#converge(action_handler, machine) ⇒ Object
35 36 37 38 |
# File 'lib/chef_metal/convergence_strategy/install_msi.rb', line 35 def converge(action_handler, machine) # TODO For some reason I get a 500 back if I don't do -l debug machine.transport.execute("chef-client -l debug") end |
#setup_convergence(action_handler, machine, machine_resource) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chef_metal/convergence_strategy/install_msi.rb', line 17 def setup_convergence(action_handler, machine, machine_resource) system_drive = machine.execute_always('$env:SystemDrive').stdout.strip @client_rb_path ||= "#{system_drive}\\chef\\client.rb" @client_pem_path ||= "#{system_drive}\\chef\\client.pem" 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? # TODO find a way to cache this on the host like with the Unix stuff. # Limiter is we don't know how to efficiently upload large files to # the remote machine with WMI. machine.execute(action_handler, "(New-Object System.Net.WebClient).DownloadFile(#{machine.escape(install_msi_url)}, #{machine.escape(install_msi_path)})") machine.execute(action_handler, "msiexec /qn /i #{machine.escape(install_msi_path)}") end end |