Class: ChefApply::Action::InstallChef::Base
- Inherits:
-
Base
- Object
- Base
- ChefApply::Action::InstallChef::Base
show all
- Defined in:
- lib/chef_apply/action/install_chef/base.rb
Constant Summary
Constants inherited
from Base
Base::PATH_MAPPING
Instance Attribute Summary
Attributes inherited from Base
#config, #target_host
Instance Method Summary
collapse
Methods inherited from Base
#escape_windows_path, #initialize, #notify, #run, #run_chef
Instance Method Details
#download_to_workstation(url_path) ⇒ Object
97
98
99
100
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 97
def download_to_workstation(url_path)
require "chef_apply/file_fetcher"
ChefApply::FileFetcher.fetch(url_path)
end
|
#install_chef_to_target(remote_path) ⇒ Object
113
114
115
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 113
def install_chef_to_target(remote_path)
raise NotImplementedError
end
|
#lookup_artifact ⇒ Object
58
59
60
61
62
63
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 58
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
|
#name ⇒ Object
33
34
35
36
37
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 33
def name
self.class.name.split("::")[-2..-1].join("::")
end
|
25
26
27
28
29
30
31
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 25
def perform_action
if ChefApply::MinimumChefVersion.check!(target_host, config[:check_only]) == :minimum_version_met
notify(:already_installed)
else
perform_local_install
end
end
|
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 43
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)
install_chef_to_target(remote_path)
notify(:install_complete)
end
|
54
55
56
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 54
def perform_remote_install
raise NotImplementedError
end
|
#setup_remote_temp_path ⇒ Object
109
110
111
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 109
def setup_remote_temp_path
raise NotImplementedError
end
|
#train_to_mixlib(platform) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 69
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
opts[:platform_version] = "6"
else
opts[:platform_version] = "7"
end
end
opts
end
|
#upgrading? ⇒ Boolean
39
40
41
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 39
def upgrading?
@upgrading
end
|
#upload_to_target(local_path) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 102
def upload_to_target(local_path)
installer_dir = setup_remote_temp_path()
remote_path = File.join(installer_dir, File.basename(local_path))
target_host.upload_file(local_path, remote_path)
remote_path
end
|
#version_to_install ⇒ Object
65
66
67
|
# File 'lib/chef_apply/action/install_chef/base.rb', line 65
def version_to_install
lookup_artifact.version
end
|