Class: Chef::Provisioning::ConvergenceStrategy::InstallSh
- Inherits:
-
PrecreateChefObjects
- Object
- Chef::Provisioning::ConvergenceStrategy
- PrecreateChefObjects
- Chef::Provisioning::ConvergenceStrategy::InstallSh
- Defined in:
- lib/chef/provisioning/convergence_strategy/install_sh.rb
Constant Summary collapse
- @@install_sh_cache =
{}
Instance Attribute Summary collapse
-
#bootstrap_env ⇒ Object
readonly
Returns the value of attribute bootstrap_env.
-
#chef_version ⇒ Object
readonly
Returns the value of attribute chef_version.
-
#client_rb_path ⇒ Object
readonly
Returns the value of attribute client_rb_path.
-
#install_sh_arguments ⇒ Object
readonly
Returns the value of attribute install_sh_arguments.
-
#install_sh_path ⇒ Object
readonly
Returns the value of attribute install_sh_path.
-
#prerelease ⇒ Object
readonly
Returns the value of attribute prerelease.
Attributes inherited from Chef::Provisioning::ConvergenceStrategy
Instance Method Summary collapse
- #converge(action_handler, machine) ⇒ Object
-
#initialize(convergence_options, config) ⇒ InstallSh
constructor
A new instance of InstallSh.
- #setup_convergence(action_handler, machine) ⇒ Object
Methods inherited from PrecreateChefObjects
#chef_server, #cleanup_convergence
Methods inherited from Chef::Provisioning::ConvergenceStrategy
Constructor Details
#initialize(convergence_options, config) ⇒ InstallSh
Returns a new instance of InstallSh.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 11 def initialize(, config) = Cheffish::MergedConfig.new(.to_hash, { :client_rb_path => '/etc/chef/client.rb', :client_pem_path => '/etc/chef/client.pem' }) super(, config) @client_rb_path ||= [:client_rb_path] @install_sh_path = [:install_sh_path] || '/tmp/chef-install.sh' @chef_version = [:chef_version] @prerelease = [:prerelease] @install_sh_arguments = [:install_sh_arguments] @bootstrap_env = [:bootstrap_proxy] ? "http_proxy=#{[:bootstrap_proxy]} https_proxy=$http_proxy " : "" @chef_client_timeout = .has_key?(:chef_client_timeout) ? [:chef_client_timeout] : 120*60 # Default: 2 hours @chef_command = [:chef_command] || "chef-client" end |
Instance Attribute Details
#bootstrap_env ⇒ Object (readonly)
Returns the value of attribute bootstrap_env.
32 33 34 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 32 def bootstrap_env @bootstrap_env end |
#chef_version ⇒ Object (readonly)
Returns the value of attribute chef_version.
28 29 30 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 28 def chef_version @chef_version end |
#client_rb_path ⇒ Object (readonly)
Returns the value of attribute client_rb_path.
27 28 29 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 27 def client_rb_path @client_rb_path end |
#install_sh_arguments ⇒ Object (readonly)
Returns the value of attribute install_sh_arguments.
31 32 33 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 31 def install_sh_arguments @install_sh_arguments end |
#install_sh_path ⇒ Object (readonly)
Returns the value of attribute install_sh_path.
30 31 32 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 30 def install_sh_path @install_sh_path end |
#prerelease ⇒ Object (readonly)
Returns the value of attribute prerelease.
29 30 31 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 29 def prerelease @prerelease end |
Instance Method Details
#converge(action_handler, machine) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 62 def converge(action_handler, machine) super action_handler.open_stream(machine.node['name']) do |stdout| action_handler.open_stream(machine.node['name']) do |stderr| command_line = "#{@chef_command} -c #{@client_rb_path}" command_line << " -l #{config[:log_level].to_s}" if config[:log_level] machine.execute(action_handler, command_line, :stream_stdout => stdout, :stream_stderr => stderr, :timeout => @chef_client_timeout) end end end |
#setup_convergence(action_handler, machine) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/chef/provisioning/convergence_strategy/install_sh.rb', line 34 def setup_convergence(action_handler, machine) super opts = {"prerelease" => prerelease} if [:bootstrap_proxy] opts["http_proxy"] = [:bootstrap_proxy] opts["https_proxy"] = [:bootstrap_proxy] end opts["omnibus_url"] = [:install_sh_url] if [:install_sh_url] if [:install_sh_arguments] opts['install_flags'] = [:install_sh_arguments] end # Install::ScriptGenerator will use current by default, unless we specify -c stable # So we add this install flag unless 'prerelease' was specified, in which case we do not if (not opts['install_flags'].nil?) and (not opts['install_flags'].include?('-c ')) and (not opts['install_flags'].include?('-channel ') and (not prerelease)) opts['install_flags']='' unless opts['install_flags'].nil? opts['install_flags']+=' -c stable' end install_command = Mixlib::Install::ScriptGenerator.new(chef_version, false, opts).install_command machine.write_file(action_handler, install_sh_path, install_command, :ensure_dir => true) machine.set_attributes(action_handler, install_sh_path, :mode => '0755') machine.execute(action_handler, "sh -c #{install_sh_path}") end |