Last active
April 8, 2020 09:59
-
-
Save arnaudmorin/e43a00cff8b163ab5b79cd7269b017ef to your computer and use it in GitHub Desktop.
Install new cloud-init on Debian 10 using packer
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
{ | |
"builders": [ | |
{ | |
"type": "openstack", | |
"username": "xxx", | |
"password": "yyy", | |
"identity_endpoint": "https://auth.cloud.ovh.net/v3/", | |
"region": "DE1", | |
"tenant_id": "zzz", | |
"image_name": "debian10-arnaud", | |
"ssh_username": "debian", | |
"source_image": "6a27a33f-9cb9-4c65-b99c-bb904dfb43aa", | |
"flavor": "3be7c73a-735a-4ee1-b8d4-83feb080109d", | |
"ssh_ip_version": "4", | |
"networks": [ | |
"ed0ab0c6-93ee-44f8-870b-d103065b1b34" | |
] | |
} | |
], | |
"provisioners": [ | |
{ | |
"script": "setup.sh", | |
"type": "shell" | |
} | |
] | |
} |
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 | |
set -e | |
if [ `id -u` -ne 0 ]; then | |
sudo $0 | |
exit 0 | |
fi | |
# Setup logging stdout + stderr to logfile | |
log_file="/var/log/postinstall.log" | |
function log_handler { | |
while IFS='' read -r output; do | |
echo $output | |
echo "$(date) - $output" >> $log_file | |
done | |
} | |
function title.print | |
{ | |
local string="$1" | |
local stringw=$((77 - $(wc -L <<< "$string"))) | |
echo "" | |
echo "┌──────────────────────────────────────────────────────────────────────────────┐" | |
echo -n "│ $string" | |
for i in $(seq 1 ${stringw}); do echo -n " " ; done | |
echo "│" | |
echo "└──────────────────────────────────────────────────────────────────────────────┘" | |
echo "" | |
} | |
exec &> >(log_handler) | |
export DEBIAN_FRONTEND=noninteractive | |
title.print "Downloading package" | |
wget -O cloudinit.deb https://people.debian.org/~noahm/cloud-init/cloud-init_20.1-2~bpo10+1_all.deb | |
title.print "Installing" | |
dpkg -i --force-all cloudinit.deb | |
echo 'done' | |
echo '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment