Sha256: c5241ed6335b0b6f5de91cca14a89f6479a052a765ee1b7d897d152a6b9eaebd
Contents?: true
Size: 1.72 KB
Versions: 4
Compression:
Stored size: 1.72 KB
Contents
require "json" # for inline hashes within YAML module Bosh::Bootstrap::Stages class SetupNewBosh attr_reader :settings def initialize(settings) @settings = settings end def commands @commands ||= Bosh::Bootstrap::Commander::Commands.new do |server| server.setup "bosh user", script("setup_bosh_user", "BOSH_NAME" => settings.bosh_name, "BOSH_HOST" => settings.bosh.ip_address, "BOSH_USERNAME" => settings.bosh_username, "BOSH_PASSWORD" => settings.bosh_password) end end private def stage_name "stage_setup_new_bosh" end # Loads local script # If +variables+, then injects KEY=VALUE environment # variables into bash scripts. def script(segment_name, variables={}) path = File.expand_path("../#{stage_name}/#{segment_name}", __FILE__) if File.exist?(path) script = File.read(path) if variables.keys.size > 0 # inject variables into script if its bash script inline_variables = "#!/usr/bin/env bash\n\n" variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" } script.gsub!("#!/usr/bin/env bash", inline_variables) # inject variables into script if its ruby script inline_variables = "#!/usr/bin/env ruby\n\n" variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" } script.gsub!("#!/usr/bin/env ruby", inline_variables) end script else Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red exit 1 end end end end
Version data entries
4 entries across 4 versions & 1 rubygems