Skip to content

Instantly share code, notes, and snippets.

@mika
Forked from arnaudmorin/debian-10-packer.json
Created April 8, 2020 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mika/ccb2c83fd04dd134d21ab3a4fab210a3 to your computer and use it in GitHub Desktop.
Save mika/ccb2c83fd04dd134d21ab3a4fab210a3 to your computer and use it in GitHub Desktop.
Install new cloud-init on Debian 10 using packer
{
"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"
}
]
}
#!/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