selfbootstrap 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/selfbootstrap/nochef/chef.rb +38 -0
- data/lib/selfbootstrap/nochef/commandline.rb +22 -20
- data/lib/selfbootstrap/nochef/defaultmethods.rb +10 -4
- data/lib/selfbootstrap/nochef/defaultworkstationresource.rb +35 -35
- data/lib/selfbootstrap/nochef/kitchen.rb +4 -0
- data/lib/selfbootstrap/nochef/knife.rb +5 -13
- data/lib/selfbootstrap/nochef/selfbootstrap.rb +70 -67
- data/lib/selfbootstrap/nochef/ssh.rb +1 -1
- data/lib/selfbootstrap/nochef/workstationresource.rb +1 -2
- data/lib/selfbootstrap/withchef/commandline.rb +19 -0
- data/lib/selfbootstrap/withchef/workstationresource.rb +11 -0
- data/lib/selfbootstrap/withchef.rb +0 -11
- data/lib/selfbootstrap/withlogger.rb +0 -4
- data/lib/selfbootstrap.rb +1 -7
- data.tar.gz.sig +0 -0
- metadata +20 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8739c46ccf96e927b7cc40f639e182255f07e7aea55b873f169e789f7f885985
|
4
|
+
data.tar.gz: 5bb61401af6856a5c800f9d8a19be52f1ebd6a5cc69734b3dbfd200c39b08a34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8d1b86380929c3f71d0fc0deb3bab480712a418674183f173378c631e118b17031a172f3d791184e2b17420428a6f5b95ce520f0cc3f61492d439ea88485f84
|
7
|
+
data.tar.gz: d45e16169c93f4432ec3be3e18ee98e59da5ba9c3d29a4266417721a55f6e2d30ae49b052c706f535a2096025ce7924b9050e529faa831519ddf1b81718ee0c6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -26,6 +26,40 @@ module ChefWorkstationInitialize
|
|
26
26
|
module ChefHelpers
|
27
27
|
include ChefWorkstationInitialize::SelfBootstrap::NoChef::BerksHelpers
|
28
28
|
|
29
|
+
def is_chef_enabled?
|
30
|
+
is_chef_constant_enabled? :Chef
|
31
|
+
end
|
32
|
+
|
33
|
+
def is_chef_command?
|
34
|
+
::File.basename($PROGRAM_NAME).eql?('chef')
|
35
|
+
end
|
36
|
+
|
37
|
+
def is_chef_cli_command?
|
38
|
+
::File.basename($PROGRAM_NAME).eql?('chef-cli')
|
39
|
+
end
|
40
|
+
|
41
|
+
def is_chef_client_command?
|
42
|
+
::File.basename($PROGRAM_NAME).eql?('chef-client')
|
43
|
+
end
|
44
|
+
|
45
|
+
def is_chef_installed?
|
46
|
+
::Dir.exist?('/opt/chef-workstation')
|
47
|
+
end
|
48
|
+
|
49
|
+
def is_chef_profile_set?
|
50
|
+
is_chef_installed? ? (base_command('which ruby', [], as_system: true).include? '/opt/chef-workstation') : false
|
51
|
+
end
|
52
|
+
|
53
|
+
def is_chefworkstation_available?
|
54
|
+
if is_chef_profile_set?
|
55
|
+
$LOAD_PATH.select do |loaded_path|
|
56
|
+
loaded_path.include? '/opt/chef-workstation'
|
57
|
+
end.count > 0
|
58
|
+
else
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
29
63
|
def chef(*args, **run_opts)
|
30
64
|
base_command('chef', args, run_opts)
|
31
65
|
end
|
@@ -37,6 +71,10 @@ module ChefWorkstationInitialize
|
|
37
71
|
def is_knife_gem_install?
|
38
72
|
chef('gem list -i knife') == 'true'
|
39
73
|
end
|
74
|
+
|
75
|
+
def install_chef_workstation
|
76
|
+
base_command('curl -L https://omnitruck.chef.io/install.sh | bash -s -- -s once -P chef-workstation', [], as_system: true)
|
77
|
+
end
|
40
78
|
end
|
41
79
|
end
|
42
80
|
end
|
@@ -17,10 +17,14 @@ module ChefWorkstationInitialize
|
|
17
17
|
module CommandlineHelpers
|
18
18
|
include ChefWorkstationInitialize::SelfBootstrap::NoChef::DefaultMethodsHelpers
|
19
19
|
|
20
|
+
def is_mixlib_disabled?
|
21
|
+
!is_chef_constant_enabled? :Mixlib
|
22
|
+
end
|
23
|
+
|
20
24
|
def main_command(command, args = [], run_opts = {})
|
21
25
|
command = 'sudo ' + command.to_s if run_opts[:sudo]
|
22
26
|
main_command = [command, args].compact.join(' ')
|
23
|
-
worklog "running \"#{main_command}\" from a shell terminal" if run_opts[:debug]
|
27
|
+
worklog "running \"#{main_command}\" from a shell terminal" # if run_opts[:debug]
|
24
28
|
[main_command, run_options(run_opts)]
|
25
29
|
end
|
26
30
|
|
@@ -31,9 +35,22 @@ module ChefWorkstationInitialize
|
|
31
35
|
if respond_to?('shell_out!')
|
32
36
|
warning_worklog('Using shell_out! as executer')
|
33
37
|
[shell_out!(final_command, final_run_options)]
|
34
|
-
elsif
|
35
|
-
|
36
|
-
|
38
|
+
elsif is_mixlib_disabled?
|
39
|
+
if run_opts[:as_system]
|
40
|
+
warning_worklog "Using system to run command #{final_command}"
|
41
|
+
exit_status = system(final_command)
|
42
|
+
if exit_status.nil?
|
43
|
+
1
|
44
|
+
elsif exit_status.is_a?(Integer)
|
45
|
+
exit_status
|
46
|
+
else
|
47
|
+
2
|
48
|
+
end
|
49
|
+
else
|
50
|
+
error_worklog('Cannot continue without at least a Chef workstation setup to run command ' + final_command)
|
51
|
+
restart_bootstrap
|
52
|
+
exit 1
|
53
|
+
end
|
37
54
|
else
|
38
55
|
# warning_worklog('Using Mixlib::ShellOut as executer')
|
39
56
|
shell_command = Mixlib::ShellOut.new(final_command, final_run_options)
|
@@ -47,22 +64,7 @@ module ChefWorkstationInitialize
|
|
47
64
|
|
48
65
|
def run_options(run_opts = {})
|
49
66
|
# debug_worklog run_opts.inspect
|
50
|
-
|
51
|
-
if workstation_resource[:user]
|
52
|
-
run_opts[:user] = workstation_resource[:user]
|
53
|
-
# Certain versions of `git` misbehave if git configuration is
|
54
|
-
# inaccessible in $HOME. We need to ensure $HOME matches the
|
55
|
-
# user who is executing `git` not the user running Chef.
|
56
|
-
env['HOME'] = get_homedir(workstation_resource[:user])
|
57
|
-
end
|
58
|
-
livestream = run_opts[:live].nil? || run_opts[:live]
|
59
|
-
run_opts[:group] = workstation_resource[:group] if workstation_resource[:group]
|
60
|
-
env['GIT_SSH'] = workstation_resource[:ssh_wrapper] if workstation_resource[:ssh_wrapper]
|
61
|
-
run_opts[:log_tag] = workstation_resource[:log_tag] if workstation_resource[:log_tag]
|
62
|
-
run_opts[:timeout] = workstation_resource[:timeout] if workstation_resource[:timeout]
|
63
|
-
env.merge!(workstation_resource[:environment_variables]) if workstation_resource[:environment_variables]
|
64
|
-
run_opts[:environment] = env unless env.empty?
|
65
|
-
run_opts[:live_stream] = $stdout if livestream
|
67
|
+
run_opts[:live_stream] = $stdout if run_opts[:live]
|
66
68
|
run_opts.delete :sudo if run_opts.key? :sudo
|
67
69
|
run_opts.delete :live if run_opts.key? :live
|
68
70
|
run_opts.delete :debug if run_opts.key? :debug
|
@@ -24,10 +24,6 @@ require 'fileutils'
|
|
24
24
|
require 'yaml'
|
25
25
|
require 'socket'
|
26
26
|
|
27
|
-
require 'kitchen'
|
28
|
-
require 'chef'
|
29
|
-
require 'chef/workstation_config_loader'
|
30
|
-
|
31
27
|
module ChefWorkstationInitialize
|
32
28
|
module SelfBootstrap
|
33
29
|
module NoChef
|
@@ -35,6 +31,16 @@ module ChefWorkstationInitialize
|
|
35
31
|
def define_resource_requirements
|
36
32
|
end
|
37
33
|
|
34
|
+
def is_chef_constant_enabled?(constant)
|
35
|
+
# if is_chefworkstation_available?
|
36
|
+
constant_defined = const_defined?(constant)
|
37
|
+
worklog "constant_defined = #{constant_defined.class} for #{constant}"
|
38
|
+
constant_defined
|
39
|
+
# else
|
40
|
+
# false
|
41
|
+
# end
|
42
|
+
end
|
43
|
+
|
38
44
|
def worklog_counter
|
39
45
|
@worklog_counter ||= 0
|
40
46
|
@worklog_counter += 1
|
@@ -47,47 +47,47 @@ module ChefWorkstationInitialize
|
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
50
|
-
class DefaultWorkstationResource
|
51
|
-
|
52
|
-
|
50
|
+
# class DefaultWorkstationResource
|
51
|
+
# include ChefWorkstationInitialize::SelfBootstrap::NoChef
|
52
|
+
# prepend ChefWorkstationInitialize::SelfBootstrap::NoChef
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
# def initialize
|
55
|
+
# config_loader = ChefConfig::WorkstationConfigLoader.new(nil)
|
56
|
+
# Chef::Config.from_file(config_loader.config_location)
|
57
|
+
# end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
# def workstation_resource_keys
|
60
|
+
# @selfbootstrap_resource.keys
|
61
|
+
# end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
63
|
+
# def [](key)
|
64
|
+
# @selfbootstrap_resource ||= default_workstation_data
|
65
|
+
# if @selfbootstrap_resource.key?(key.to_sym)
|
66
|
+
# @selfbootstrap_resource[key.to_sym]
|
67
|
+
# elsif @selfbootstrap_resource.key?(key.to_s)
|
68
|
+
# @selfbootstrap_resource[key.to_s]
|
69
|
+
# end
|
70
|
+
# end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
# def get_workstation_property(property_name)
|
73
|
+
# debug_worklog("Get property #{property_name}") # if property_name == 'group'
|
74
|
+
# self[property_name]
|
75
|
+
# end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
# def set_workstation_property(property_name, value)
|
78
|
+
# debug_worklog("Assign property #{property_name} is value #{value.is_a?(::Dir) ? get_path(value) : value}")
|
79
|
+
# self[property_name] = value
|
80
|
+
# end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
82
|
+
# def render_template(generated_path, source, **variables)
|
83
|
+
# if ::File.basename(generated_path).eq?('kitchen.yml')
|
84
|
+
# worklog('Generating a new kitchen file')
|
85
|
+
# kitchen 'init'
|
86
|
+
# else
|
87
|
+
# super(generated_path, source, variables)
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
# end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
#
|
@@ -28,6 +28,10 @@ module ChefWorkstationInitialize
|
|
28
28
|
include ChefWorkstationInitialize::SelfBootstrap::NoChef::ChefHelpers
|
29
29
|
include ChefWorkstationInitialize::SelfBootstrap::NoChef::ProvisionersHelpers
|
30
30
|
|
31
|
+
def is_kitchen_command?
|
32
|
+
::File.basename($PROGRAM_NAME).eql?('kitchen')
|
33
|
+
end
|
34
|
+
|
31
35
|
def kitchen(*args, **run_opts)
|
32
36
|
write_kitchen_file unless args.eql? ['init']
|
33
37
|
base_command('kitchen', args, run_opts)
|
@@ -26,6 +26,10 @@ module ChefWorkstationInitialize
|
|
26
26
|
module KnifeHelpers
|
27
27
|
include ChefWorkstationInitialize::SelfBootstrap::NoChef::ChefRepoHelpers
|
28
28
|
|
29
|
+
def is_knife?
|
30
|
+
::File.basename($PROGRAM_NAME).eql?('knife')
|
31
|
+
end
|
32
|
+
|
29
33
|
def knife(*args, **run_opts)
|
30
34
|
base_command('knife', *args, **run_opts)
|
31
35
|
end
|
@@ -53,21 +57,9 @@ module ChefWorkstationInitialize
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def knife_self_bootstrap_cmd
|
60
|
+
debug_worklog 'boostrapped with chef-server and knife'
|
56
61
|
knife "bootstrap #{self_bootstrap_options} --policy-group #{project_name} --policy-name #{project_name} #{default_hostname}"
|
57
62
|
end
|
58
|
-
|
59
|
-
def chef_client_self_bootstrap_cmd
|
60
|
-
chef_client_options = [self_bootstrap_options]
|
61
|
-
chef_client_options << "--runlist #{project_name}"
|
62
|
-
if ::File.exist?('solo.rb')
|
63
|
-
chef_client_options << '-c solo.rb'
|
64
|
-
else
|
65
|
-
chef_client_options << chef_solo_options_command
|
66
|
-
chef_client_options << "--chef-zero-host #{default_hostname}"
|
67
|
-
chef_client_options << "--chef-zero-port #{default_chefzero_portrange}"
|
68
|
-
end
|
69
|
-
chef_client chef_client_options, debug: true
|
70
|
-
end
|
71
63
|
end
|
72
64
|
end
|
73
65
|
end
|
@@ -19,37 +19,6 @@ module ChefWorkstationInitialize
|
|
19
19
|
|
20
20
|
attr_accessor :force_solo
|
21
21
|
|
22
|
-
def self_bootstrap_with_kitchen
|
23
|
-
worklog 'Self bootstrap with sudo command'
|
24
|
-
base_command('selfbootstrap', sudo: true)
|
25
|
-
# kitchen 'list bootstrap self', sudo: true
|
26
|
-
end
|
27
|
-
|
28
|
-
def set_chef_profile
|
29
|
-
bash_file = '/etc/bash.bashrc.copy'
|
30
|
-
chef_shell_cmd = 'eval "$(chef shell-init bash)"'
|
31
|
-
debug_worklog "Set chef profile tpo #{bash_file}"
|
32
|
-
open(bash_file, 'a') do |f|
|
33
|
-
f.puts chef_shell_cmd
|
34
|
-
end unless ::File.read(bash_file).include?(chef_shell_cmd)
|
35
|
-
end
|
36
|
-
|
37
|
-
def install_chef_client
|
38
|
-
base_command('curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -s once -P chef-workstation')
|
39
|
-
end
|
40
|
-
|
41
|
-
def is_chef_installed?
|
42
|
-
::Dir.exist?('/opt/chef-workstation')
|
43
|
-
end
|
44
|
-
|
45
|
-
def is_chef_profile_set?
|
46
|
-
base_command('which ruby') == '/usr/bin/chef-client'
|
47
|
-
end
|
48
|
-
|
49
|
-
def is_knife?
|
50
|
-
::File.basename($PROGRAM_NAME).eql?('knife')
|
51
|
-
end
|
52
|
-
|
53
22
|
def for_solo?
|
54
23
|
is_knife? && ARGV.join(' ').include?('config show solo --format json')
|
55
24
|
end
|
@@ -63,36 +32,23 @@ module ChefWorkstationInitialize
|
|
63
32
|
end
|
64
33
|
|
65
34
|
def is_boostrapping?
|
66
|
-
|
67
|
-
::File.exist?(bootstrapping_progress_file)
|
68
|
-
end
|
69
|
-
|
70
|
-
def is_chef_command?
|
71
|
-
::File.basename($PROGRAM_NAME).eql?('chef')
|
72
|
-
end
|
73
|
-
|
74
|
-
def is_chef_cli_command?
|
75
|
-
::File.basename($PROGRAM_NAME).eql?('chef-cli')
|
76
|
-
end
|
77
|
-
|
78
|
-
def is_chef_client_command?
|
79
|
-
::File.basename($PROGRAM_NAME).eql?('chef-client')
|
80
|
-
end
|
81
|
-
|
82
|
-
def is_kitchen_command?
|
83
|
-
::File.basename($PROGRAM_NAME).eql?('kitchen')
|
35
|
+
is_chef_enabled? ? ::File.exist?(bootstrapping_progress_file) : false
|
84
36
|
end
|
85
37
|
|
86
38
|
def unauthorized_to_boostrap?
|
87
39
|
is_chef_command? || is_chef_client_command? || is_chef_cli_command?
|
88
40
|
end
|
89
41
|
|
42
|
+
def run_as_root?
|
43
|
+
ENV['USER'] == 'root' # workstation_resource[:user] == 'root'
|
44
|
+
end
|
45
|
+
|
90
46
|
def skip_boostrap?
|
91
47
|
debug_worklog("for_solo = #{for_solo?}")
|
92
48
|
debug_worklog("for_search_local_node = #{for_search_local_node?}")
|
93
|
-
debug_worklog("is_boostrapping = #{is_boostrapping?}")
|
94
49
|
debug_worklog("unauthorized_to_boostrap = #{unauthorized_to_boostrap?}")
|
95
|
-
|
50
|
+
debug_worklog("is_boostrapping = #{is_boostrapping?}")
|
51
|
+
for_solo? || for_search_local_node? || unauthorized_to_boostrap? || is_boostrapping?
|
96
52
|
end
|
97
53
|
|
98
54
|
def chef_solo_options
|
@@ -123,6 +79,58 @@ module ChefWorkstationInitialize
|
|
123
79
|
FileUtils.rm bootstrapping_progress_file if ::File.exist?(bootstrapping_progress_file)
|
124
80
|
end
|
125
81
|
|
82
|
+
def install_this_gem
|
83
|
+
chef 'gem install selfbootstrap', { as_system: true }
|
84
|
+
end
|
85
|
+
|
86
|
+
def restart_bootstrap
|
87
|
+
rerun_opt = { sudo: true }
|
88
|
+
if run_as_root?
|
89
|
+
install_chef_workstation
|
90
|
+
set_chef_profile
|
91
|
+
install_this_gem
|
92
|
+
rerun_opt[:as_system] = true
|
93
|
+
end
|
94
|
+
worklog 'Self bootstrap with sudo command'
|
95
|
+
debug_worklog 'boostrapped with solo and kitchen and root'
|
96
|
+
remove_bootstrap_file
|
97
|
+
exit base_command('selfbootstrap', ARGV, rerun_opt)
|
98
|
+
# kitchen 'list bootstrap self', sudo: true
|
99
|
+
end
|
100
|
+
|
101
|
+
def set_chef_profile
|
102
|
+
bash_file = '/etc/bash.bashrc'
|
103
|
+
# chef_shell_cmd = "cd #{workstation_scripts_dir}; curl -L https://omnitruck.chef.io/install_desktop.sh | sudo bash -s -- #{project_name} #{environments.join(' ')}"
|
104
|
+
chef_shell_cmd = 'eval "$(chef shell-init bash)"'
|
105
|
+
debug_worklog "Set chef profile to #{bash_file}"
|
106
|
+
open(bash_file, 'a') do |f|
|
107
|
+
f.puts chef_shell_cmd
|
108
|
+
end unless ::File.read(bash_file).include?(chef_shell_cmd)
|
109
|
+
end
|
110
|
+
|
111
|
+
def bootstrap_self_command
|
112
|
+
if is_solo?
|
113
|
+
debug_worklog 'boostrapped with solo'
|
114
|
+
if chefworkstation_available?
|
115
|
+
if chef_enabled?
|
116
|
+
prepend ChefWorkstationInitialize::SelfBootstrap::WithChef
|
117
|
+
bootstrap_self_command
|
118
|
+
else
|
119
|
+
require 'kitchen'
|
120
|
+
require 'chef'
|
121
|
+
require 'chef/workstation_config_loader'
|
122
|
+
end
|
123
|
+
elsif run_as_root?
|
124
|
+
chef_client_self_bootstrap_cmd
|
125
|
+
else
|
126
|
+
restart_bootstrap
|
127
|
+
end
|
128
|
+
else
|
129
|
+
knife_self_bootstrap_cmd
|
130
|
+
end
|
131
|
+
debug_worklog 'bootstrap self command completed'
|
132
|
+
end
|
133
|
+
|
126
134
|
def boostrapp_once
|
127
135
|
create_chef_additionnal_dir
|
128
136
|
berks_vendor_init unless is_self_bootsrapping?
|
@@ -136,24 +144,19 @@ module ChefWorkstationInitialize
|
|
136
144
|
end
|
137
145
|
end
|
138
146
|
|
139
|
-
def
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
else
|
147
|
-
debug_worklog 'boostrapped with solo and chef-client'
|
148
|
-
install_chef_client
|
149
|
-
set_chef_profile
|
150
|
-
chef_client_self_bootstrap_cmd
|
151
|
-
end
|
147
|
+
def chef_client_self_bootstrap_cmd
|
148
|
+
debug_worklog 'boostrapped with solo and chef-client'
|
149
|
+
|
150
|
+
chef_client_options = [self_bootstrap_options]
|
151
|
+
chef_client_options << "--runlist #{project_name}"
|
152
|
+
if ::File.exist?('solo.rb')
|
153
|
+
chef_client_options << '-c solo.rb'
|
152
154
|
else
|
153
|
-
|
154
|
-
|
155
|
+
chef_client_options << chef_solo_options_command
|
156
|
+
chef_client_options << "--chef-zero-host #{default_hostname}"
|
157
|
+
chef_client_options << "--chef-zero-port #{default_chefzero_portrange}"
|
155
158
|
end
|
156
|
-
|
159
|
+
chef_client chef_client_options, debug: true
|
157
160
|
end
|
158
161
|
|
159
162
|
def bootstrap_self
|
@@ -16,6 +16,25 @@ module ChefWorkstationInitialize
|
|
16
16
|
module WithChef
|
17
17
|
module CommandlineHelpers
|
18
18
|
include ChefWorkstationInitialize::SelfBootstrap::WithChef::DefaultMethodsHelpers
|
19
|
+
|
20
|
+
def run_options(run_opts = {})
|
21
|
+
# debug_worklog run_opts.inspect
|
22
|
+
env = {}
|
23
|
+
if workstation_resource[:user]
|
24
|
+
run_opts[:user] = workstation_resource[:user]
|
25
|
+
# Certain versions of `git` misbehave if git configuration is
|
26
|
+
# inaccessible in $HOME. We need to ensure $HOME matches the
|
27
|
+
# user who is executing `git` not the user running Chef.
|
28
|
+
env['HOME'] = get_homedir(workstation_resource[:user])
|
29
|
+
end
|
30
|
+
run_opts[:group] = workstation_resource[:group] if workstation_resource[:group]
|
31
|
+
env['GIT_SSH'] = workstation_resource[:ssh_wrapper] if workstation_resource[:ssh_wrapper]
|
32
|
+
run_opts[:log_tag] = workstation_resource[:log_tag] if workstation_resource[:log_tag]
|
33
|
+
run_opts[:timeout] = workstation_resource[:timeout] if workstation_resource[:timeout]
|
34
|
+
env.merge!(workstation_resource[:environment_variables]) if workstation_resource[:environment_variables]
|
35
|
+
run_opts[:environment] = env unless env.empty?
|
36
|
+
super(run_opts)
|
37
|
+
end
|
19
38
|
end
|
20
39
|
end
|
21
40
|
end
|
@@ -36,6 +36,17 @@ module ChefWorkstationInitialize
|
|
36
36
|
# swap_workstation(ChefWorkstationInitialize::SelfBootstrap::WithLogger) if respond_to? 'logger'
|
37
37
|
# @workstation
|
38
38
|
# end
|
39
|
+
|
40
|
+
def workstation_resource
|
41
|
+
@workstation_data ||= (
|
42
|
+
if Chef::Config[:selfbootstrap].nil?
|
43
|
+
config_loader = ChefConfig::WorkstationConfigLoader.new(nil)
|
44
|
+
Chef::Config.from_file(config_loader.config_location) unless config_loader.config_location.nil?
|
45
|
+
default_workstation_data.deep_merge Chef::Config[:selfbootstrap]
|
46
|
+
end
|
47
|
+
)
|
48
|
+
@workstation_data
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
@@ -16,17 +16,6 @@ module ChefWorkstationInitialize
|
|
16
16
|
module SelfBootstrap
|
17
17
|
module WithChef
|
18
18
|
include ChefWorkstationInitialize::SelfBootstrap::WithChef::SelfBootstrapHelpers
|
19
|
-
|
20
|
-
def workstation_resource
|
21
|
-
@workstation_data ||= (
|
22
|
-
if Chef::Config[:selfbootstrap].nil?
|
23
|
-
config_loader = ChefConfig::WorkstationConfigLoader.new(nil)
|
24
|
-
Chef::Config.from_file(config_loader.config_location) unless config_loader.config_location.nil?
|
25
|
-
default_workstation_data.deep_merge Chef::Config[:selfbootstrap]
|
26
|
-
end
|
27
|
-
)
|
28
|
-
@workstation_data
|
29
|
-
end
|
30
19
|
#
|
31
20
|
# Define the methods that you would like to assist the work you do in recipes,
|
32
21
|
# resources, or templates.
|
@@ -16,10 +16,6 @@ module ChefWorkstationInitialize
|
|
16
16
|
module SelfBootstrap
|
17
17
|
module WithLogger
|
18
18
|
include ChefWorkstationInitialize::SelfBootstrap::WithLogger::SelfBootstrapHelpers
|
19
|
-
|
20
|
-
def worklog(logstr)
|
21
|
-
logger.warn("\n\n(#{worklog_counter})WORKLOG:: #{logstr}\n\n")
|
22
|
-
end
|
23
19
|
#
|
24
20
|
# Define the methods that you would like to assist the work you do in recipes,
|
25
21
|
# resources, or templates.
|
data/lib/selfbootstrap.rb
CHANGED
@@ -13,13 +13,7 @@ require_relative 'selfbootstrap/withlogger'
|
|
13
13
|
|
14
14
|
module ChefWorkstationInitialize
|
15
15
|
module SelfBootstrap
|
16
|
-
|
17
|
-
include ChefWorkstationInitialize::SelfBootstrap::WithLogger
|
18
|
-
elsif respond_to? 'Chef'
|
19
|
-
include ChefWorkstationInitialize::SelfBootstrap::WithChef
|
20
|
-
else
|
21
|
-
include ChefWorkstationInitialize::SelfBootstrap::NoChef
|
22
|
-
end
|
16
|
+
include ChefWorkstationInitialize::SelfBootstrap::NoChef
|
23
17
|
|
24
18
|
def self.bootstrap
|
25
19
|
extend ChefWorkstationInitialize::SelfBootstrap
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selfbootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Provencher
|
@@ -35,22 +35,36 @@ cert_chain:
|
|
35
35
|
+V3ectLBpuoKM8f/ZFMnUPA0mAv5e7J6u9IBwyNj/cy+wLOAbpPdmhoKZXCpQcno
|
36
36
|
ysBBJbi//0tgFWwC4vOaDMch
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-10-
|
38
|
+
date: 2022-10-21 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: chef
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "<="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '17.10'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "<="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '17.10'
|
40
54
|
- !ruby/object:Gem::Dependency
|
41
55
|
name: test-kitchen
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
43
57
|
requirements:
|
44
|
-
- - "
|
58
|
+
- - "<"
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
60
|
+
version: '4'
|
47
61
|
type: :runtime
|
48
62
|
prerelease: false
|
49
63
|
version_requirements: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
|
-
- - "
|
65
|
+
- - "<"
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
67
|
+
version: '4'
|
54
68
|
description: Using Chef cookbook style and force any script using it to switch to
|
55
69
|
chef even if it is not install. It will install it tho ;)
|
56
70
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|