mirror of
https://github.com/0x1d/terraform-docker-packer.git
synced 2025-12-14 05:56:52 +01:00
Add bootstrap scripts
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@
|
||||
.terraform/
|
||||
terraform.tfstate
|
||||
terraform.tfstate.backup
|
||||
|
||||
*.img
|
||||
11
ctl.sh
11
ctl.sh
@@ -5,10 +5,13 @@ function info {
|
||||
}
|
||||
|
||||
function build {
|
||||
docker run --rm --privileged \
|
||||
-v /dev:/dev \
|
||||
-v ${PWD}:/build mkaczanowski/packer-builder-arm:latest \
|
||||
build packer/raspios.pkr.hcl
|
||||
function image {
|
||||
docker run --rm --privileged \
|
||||
-v /dev:/dev \
|
||||
-v ${PWD}:/build mkaczanowski/packer-builder-arm:latest \
|
||||
build packer/raspios.pkr.hcl
|
||||
}
|
||||
${@:-info}
|
||||
}
|
||||
|
||||
${@:-info}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
variable "image_url" {
|
||||
type = string
|
||||
default = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz"
|
||||
}
|
||||
|
||||
source "arm" "raspios-arm64" {
|
||||
file_urls = ["https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz"]
|
||||
file_checksum_url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz.sha256"
|
||||
file_urls = ["${var.image_url}"]
|
||||
file_checksum_url = "${var.image_url}.sha256"
|
||||
file_checksum_type = "sha256"
|
||||
file_target_extension = "xz"
|
||||
file_unarchive_cmd = ["xz", "--decompress", "$ARCHIVE_PATH"]
|
||||
image_build_method = "resize"
|
||||
image_path = "raspios-arm64.img"
|
||||
image_size = "4G"
|
||||
image_size = "6G"
|
||||
image_type = "dos"
|
||||
|
||||
image_partitions {
|
||||
@@ -34,13 +39,11 @@ source "arm" "raspios-arm64" {
|
||||
|
||||
build {
|
||||
sources = ["source.arm.raspios-arm64"]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
"touch /boot/ssh.txt",
|
||||
"echo 'pi:$6$c70VpvPsVNCG0YR5$l5vWWLsLko9Kj65gcQ8qvMkuOoRkEagI90qi3F/Y7rm8eNYZHW8CY6BOIKwMH7a3YYzZYL90zf304cAHLFaZE0' > /boot/userconf.txt",
|
||||
"apt update",
|
||||
"apt upgrade -y"
|
||||
scripts = [
|
||||
"scripts/pi.sh",
|
||||
"scripts/docker.sh",
|
||||
"scripts/hashi.sh"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
7
scripts/docker.sh
Normal file
7
scripts/docker.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||
sudo sh ./get-docker.sh
|
||||
rm get-docker.sh
|
||||
|
||||
usermod -aG docker pi
|
||||
12
scripts/hashi.sh
Normal file
12
scripts/hashi.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# install hashistack
|
||||
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
||||
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
||||
sudo apt update
|
||||
sudo apt install -y nomad consul
|
||||
|
||||
# install CNI plugins
|
||||
curl -L -o /tmp/cni-plugins.tgz "https://github.com/containernetworking/plugins/releases/download/v1.0.0/cni-plugins-linux-$([ $(uname -m) = aarch64 ] && echo arm64 || echo amd64)"-v1.0.0.tgz
|
||||
sudo mkdir -p /opt/cni/bin
|
||||
sudo tar -C /opt/cni/bin -xzf /tmp/cni-plugins.tgz
|
||||
4
scripts/pi.sh
Normal file
4
scripts/pi.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
touch /boot/ssh.txt
|
||||
echo 'pi:$6$c70VpvPsVNCG0YR5$l5vWWLsLko9Kj65gcQ8qvMkuOoRkEagI90qi3F/Y7rm8eNYZHW8CY6BOIKwMH7a3YYzZYL90zf304cAHLFaZE0' > /boot/userconf.txt
|
||||
Reference in New Issue
Block a user