Class: Chef::Knife::BootstrapSsh
- Inherits:
-
Ssh
- Object
- Ssh
- Chef::Knife::BootstrapSsh
- Defined in:
- lib/knife-zero/bootstrap_ssh.rb
Direct Known Subclasses
Instance Method Summary collapse
- #build_client_json ⇒ Object
-
#ssh_command(command, session_list = session) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity.
Instance Method Details
#build_client_json ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/knife-zero/bootstrap_ssh.rb', line 79 def build_client_json <<-SCRIPT sudo sh -c 'cat <<"EOP" > /etc/#{ChefUtils::Dist::Infra::DIR_SUFFIX}/chef_client_json.json #{config[:chef_client_json].to_json} ' SCRIPT end |
#ssh_command(command, session_list = session) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/knife-zero/bootstrap_ssh.rb', line 14 def ssh_command(command, subsession = nil) # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity if config[:client_version] case config[:alter_project] when 'cinc' super(%{/opt/cinc/embedded/bin/ruby -ropen-uri -e 'puts open("https://omnitruck.cinc.sh/install.sh").read' | sudo sh -s -- -v #{config[:client_version]}}) else super(%{/opt/chef/embedded/bin/ruby -ropen-uri -e 'puts open("https://omnitruck.chef.io/chef/install.sh").read' | sudo sh -s -- -v #{config[:client_version]}}) end end if config[:json_attribs] Chef::Log.info "Onetime Attributes: #{config[:chef_client_json]}" super(build_client_json) end chef_zero_port = config[:chef_zero_port] || Chef::Config[:knife][:chef_zero_port] || URI.parse(Chef::Config.chef_server_url).port chef_zero_host = config[:chef_zero_host] || Chef::Config[:knife][:chef_zero_host] || '127.0.0.1' (subsession || session).servers.each do |server| session = server.session(true) session.forward.remote(chef_zero_port, chef_zero_host, ::Knife::Zero::Helper.zero_remote_port) end super rescue => e # rubocop:disable Style/RescueStandardError ui.error(e.class.to_s + e.) ui.error e.backtrace.join("\n") exit 1 end |