oem/oracle: Set SSH keys when launching instance

This commit is contained in:
Benjamin Gilbert 2017-08-30 16:20:55 -07:00
parent 51c5345c0d
commit 95b2c96ce2

View File

@ -13,10 +13,15 @@ name=
shape="VM.Standard1.1"
ipxe=0
ignition=
keyfile="$HOME/.ssh/id_rsa.pub"
baseurl="http://alpha.release.core-os.net/amd64-usr/current"
bucket_base="users.developer.core-os.net/$USER/bmcs"
kargs=
if [[ ! -f "$keyfile" ]]; then
keyfile=""
fi
# Parse args
usage="Usage: $0 [args] -n name
Options:
@ -26,6 +31,7 @@ Options:
-s SHAPE Instance shape (default: ${shape})
-S SUBNET-ID Subnet ID to use (default: ${subnet_id})
-i IGNITION Path to Ignition config
-A SSH-KEYS Path to SSH keys (default: ${keyfile})
-p Boot with iPXE
-I IMAGE-ID Image ID to use; only relevant for non-iPXE (default: ${image_id})
-b BASEURL URL to the image mirror; only relevant for iPXE (default: ${baseurl})
@ -33,7 +39,7 @@ Options:
-k ARGS Additional kernel command line arguments for iPXE script
-h This ;-)
"
while getopts "c:a:n:s:S:i:pI:b:B:k:h" OPTION
while getopts "c:a:n:s:S:i:A:pI:b:B:k:h" OPTION
do
case "${OPTION}" in
c) compartment="${OPTARG}" ;;
@ -42,6 +48,7 @@ do
s) shape="${OPTARG}" ;;
S) subnet_id="${OPTARG}" ;;
i) ignition="${OPTARG}" ;;
A) keyfile="${OPTARG}" ;;
p) ipxe=1 ;;
I) image_id="${OPTARG}" ;;
b) baseurl="${OPTARG}" ;;
@ -97,6 +104,9 @@ fi
if [[ -n "${ignition}" ]]; then
launch_args+=("--user-data-file" "${ignition}")
fi
if [[ -n "${keyfile}" ]]; then
launch_args+=("--ssh-authorized-keys-file" "${keyfile}")
fi
bmcs compute instance launch \
--availability-domain "${availability_domain}" \
--compartment-id "${compartment}" \