#!/usr/bin/env ruby require 'pastel' if ENV['HACKING'] require_relative '../lib/cloudstrap' else require 'cloudstrap' end gem = Gem::Specification .find_all_by_name('cloudstrap') .sort_by { |spec| spec.version } .last version = Regexp.union(/^-[vV]$/, /--?version/) if ARGV.any? { |arg| arg =~ version } puts "#{gem.name} v#{gem.version}" exit end config = Cloudstrap::Config.new agent = Cloudstrap::Agent.new puts <<-EOS # #{gem.name} v#{gem.version} # #{gem.summary} # General Configuration # These settings can be configured via ENV or config.yaml BOOTSTRAP_REGION=#{config.region} BOOTSTRAP_CACHE_PATH=#{config.cache_path} BOOTSTRAP_VPC_CIDR_BLOCK=#{config.vpc_cidr_block} BOOTSTRAP_PUBLIC_CIDR_BLOCK=#{config.public_cidr_block} BOOTSTRAP_PRIVATE_CIDR_BLOCK=#{config.private_cidr_block} BOOTSTRAP_AMI_OWNER=#{config.ami_owner} BOOTSTRAP_UBUNTU_RELEASE=#{config.ubuntu_release} BOOTSTRAP_INSTANCE_TYPE=#{config.instance_type} BOOTSTRAP_SSH_DIR=#{config.ssh_dir} BOOTSTRAP_SSH_USERNAME=#{config.ssh_username} BOOTSTRAP_HDP_DIR=#{config.hdp_dir} BOOTSTRAP_HDP_BOOTSTRAP_ORIGIN=#{config.hdp_origin} BOOTSTRAP_HDP_BOOTSTRAP_VERSION=#{config.hdp_version} BOOTSTRAP_HDP_BOOTSTRAP_PACKAGE_URL=#{config.hdp_package_url} BOOTSTRAP_PROPERTIES_SEED_URL=#{config.bootstrap_properties_seed_url} # Cached Configuration # These settings can be overridden via ENV only BOOTSTRAP_USERNAME=#{agent.username} BOOTSTRAP_UUID=#{agent.uuid} BOOTSTRAP_TAG=#{agent.bootstrap_tag} BOOTSTRAP_AMI=#{agent.ami} BOOTSTRAP_VPC_ID=#{agent.vpc} BOOTSTRAP_INTERNET_GATEWAY_ID=#{agent.internet_gateway} BOOTSTRAP_NAT_GATEWAY_ID=#{agent.nat_gateway} BOOTSTRAP_JUMPBOX_SECURITY_GROUP=#{agent.jumpbox_security_group} BOOTSTRAP_PRIVATE_SUBNET_ID=#{agent.private_subnet} BOOTSTRAP_PUBLIC_SUBNET_ID=#{agent.public_subnet} BOOTSTRAP_ROUTE_TABLE_ID=#{agent.route_table} BOOTSTRAP_PRIVATE_ROUTE_TABLE_ID=#{agent.private_route_table} BOOTSTRAP_NAT_ROUTE_ASSOCIATION_ID=#{agent.nat_route_association} BOOTSTRAP_PRIVATE_AVAILABILITY_ZONE=#{agent.private_availability_zone} BOOTSTRAP_PUBLIC_AVAILABILITY_ZONE=#{agent.public_availability_zone} BOOTSTRAP_JUMPBOX_ID=#{agent.jumpbox} BOOTSTRAP_JUMPBOX_IP=#{agent.jumpbox_ip} BOOTSTRAP_WITHOUT_HUMAN_OVERSIGHT=#{!agent.requires_human_oversight?} # Additional Information # These do not need configuration, and are presented as a debugging checklist # DNS Support Enabled for VPC? #{agent.enable_dns_support} # DNS Hostnames Enabled for VPC? #{agent.enable_dns_hostnames} # Public IPs Enabled in Public Subnet? #{agent.enable_public_ips} # Gateway Attached to VPC? #{agent.attach_gateway} # Route to Internet via Gateway? #{agent.default_route} # Route to NAT Gateway from Private Subnets? #{agent.configure_nat_routes} # SSH Allowed to Jumpbox? #{agent.allow_ssh} # SSH Key uploaded to AWS? #{agent.upload_ssh_key} # HDP bootstrap.properties configured? #{agent.configure_hdp} # Jumpbox Tagged? #{agent.tag_jumpbox} # Jumpbox Running? #{agent.jumpbox_running?} EOS if agent.jumpbox_running? agent.configure_jumpbox STDERR.puts Pastel.new.green <<-EOS Congratulations! Your Jumpbox is ready. This instance has been configured with everything you need to deploy your very own cluster. The SSH key used by this process has been uploaded to your Jumpbox, along with a bootstrap.properties file that has been configured to match the settings used here. EOS if agent.requires_human_oversight? STDERR.puts <<-EOS When you are ready to proceed, the following command will do the rest: ssh -l ubuntu -i #{agent.ssh_key.private_file} #{agent.jumpbox_ip} bootstrap install bootstrap.properties You will need to provide AWS credentials either via environment (recommended) or directly in bootstrap.properties. Alternatively, this can be done automatically if you set BOOTSTRAP_WITHOUT_HUMAN_OVERSIGHT=true and invoke cloudstrap again. EOS else STDERR.puts Pastel.new.bold.bright_yellow.on_blue 'Human oversight has been disabled.' STDERR.puts Pastel.new.blue <<-EOS Now would be a good time for tea and swordplay (https://xkcd.com/303/). What happens next is non-interactive and will take approximately 30 minutes. EOS agent.launch end else STDERR.puts Pastel.new.red <<-EOS Your Jumpbox (#{agent.jumpbox}) is not in a "running" state. It is normal for the first boot to take several minutes as the instance configures itself. If you wait a few minutes and try again, it should work. EOS abort end