class ChefCore::Actions::InstallChef
TODO shouldn't be redeclaring Base
here
Public Class Methods
new(opts = { check_only: false })
click to toggle source
Calls superclass method
ChefCore::Actions::Base::new
# File lib/chef_core/actions/install_chef.rb, line 25 def initialize(opts = { check_only: false }) super end
Public Instance Methods
download_to_workstation(url_path)
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 106 def download_to_workstation(url_path) require "chef_core/file_fetcher" ChefCore::FileFetcher.fetch(config[:cache_path], url_path) end
lookup_artifact()
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 66 def lookup_artifact return @artifact_info if @artifact_info require "mixlib/install" c = train_to_mixlib(target_host.platform) Mixlib::Install.new(c).artifact_info end
perform_action()
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 29 def perform_action if InstallChef::MinimumChefVersion.check!(target_host, config[:check_only]) == :minimum_version_met notify(:already_installed) else perform_local_install end end
perform_local_install()
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 41 def perform_local_install package = lookup_artifact notify(:downloading) local_path = download_to_workstation(package.url) notify(:uploading) remote_path = upload_to_target(local_path) notify(:installing) target_host.install_package(remote_path) notify(:install_complete) end
perform_remote_install()
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 52 def perform_remote_install # TODO BOOTSTRAP - we'll need to implement this for both platforms # require "mixlib/install" # installer = Mixlib::Install.new({ # platform: "windows",/etc - # product_name: "chef", # channel: :stable, # shell_type: :ps1, # version: "13", # }) # target_host.run_command! installer.install_command raise NotImplementedError end
train_to_mixlib(platform)
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 78 def train_to_mixlib(platform) opts = { platform_version: platform.release, platform: platform.name, architecture: platform.arch, product_name: "chef", product_version: :latest, channel: :stable, platform_version_compatibility_mode: true, } case platform.name when /windows/ opts[:platform] = "windows" when "redhat", "centos" opts[:platform] = "el" when "suse" opts[:platform] = "sles" when "amazon" opts[:platform] = "el" if platform.release.to_i > 2010 # legacy Amazon version 1 opts[:platform_version] = "6" else opts[:platform_version] = "7" end end opts end
upgrading?()
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 37 def upgrading? @upgrading end
upload_to_target(local_path)
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 112 def upload_to_target(local_path) installer_dir = target_host.temp_dir remote_path = File.join(installer_dir, File.basename(local_path)) target_host.upload_file(local_path, remote_path) remote_path end
version_to_install()
click to toggle source
# File lib/chef_core/actions/install_chef.rb, line 74 def version_to_install lookup_artifact.version end