Created
September 21, 2021 21:44
-
-
Save VasiliyS/ab24c7418dbb11f904128ed2d421eb92 to your computer and use it in GitHub Desktop.
Use Oracle Cloud Metadata to set-up a Flatcar instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Getting metadata ..." | |
read -d '' Name Key <<< $(/usr/bin/curl -s -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance/ | /usr/bin/jq -r ' .hostname,.metadata.ssh_authorized_keys') | |
#set the hostname | |
echo "Setting hostname to $Name" | |
/usr/bin/hostnamectl set-hostname $Name | |
echo "Updating authorized keys..." | |
#put SSH keys | |
echo $Key > /home/core/.ssh/authorized_keys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment