wip: alpine 3.16
This commit is contained in:
@@ -1,105 +0,0 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"accelerator": "{{user `accelerator`}}",
|
||||
"boot_command": [
|
||||
"{{user `username`}}<enter>",
|
||||
"passwd<enter>{{user `password`}}<enter>{{user `password`}}<enter>",
|
||||
"ifconfig eth0 up \u0026\u0026 udhcpc -i eth0<enter>",
|
||||
"apk add --repository http://dl-cdn.alpinelinux.org/alpine/v{{user `alpine_version`}}/main dropbear dropbear-openrc openssh-sftp-server<enter>",
|
||||
"rc-update add dropbear<enter>",
|
||||
"echo -e 'auto eth0\\niface eth0 inet dhcp' > /etc/network/interfaces<enter>",
|
||||
"rc-service dropbear start<enter>",
|
||||
"<wait>"
|
||||
],
|
||||
"boot_wait": "{{user `boot_wait`}}",
|
||||
"disk_interface": "virtio",
|
||||
"disk_size": "{{user `iso_size`}}",
|
||||
"format": "raw",
|
||||
"headless": true,
|
||||
"host_port_max": "{{user `ssh_port_max`}}",
|
||||
"host_port_min": "{{user `ssh_port_min`}}",
|
||||
"iso_checksum": "file:http://dl-cdn.alpinelinux.org/alpine/v{{user `alpine_version`}}/releases/{{user `alpine_arch`}}/alpine-virt-{{user `alpine_release`}}-{{user `alpine_arch`}}.iso.sha256",
|
||||
"iso_url": "http://dl-cdn.alpinelinux.org/alpine/v{{user `alpine_version`}}/releases/{{user `alpine_arch`}}/alpine-virt-{{user `alpine_release`}}-{{user `alpine_arch`}}.iso",
|
||||
"net_device": "virtio-net",
|
||||
"output_directory": "{{user `output`}}",
|
||||
"qemuargs": [
|
||||
[
|
||||
"-device",
|
||||
"virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x7"
|
||||
],
|
||||
[
|
||||
"-object",
|
||||
"rng-random,filename=/dev/urandom,id=rng0"
|
||||
]
|
||||
],
|
||||
"shutdown_command": "/sbin/poweroff",
|
||||
"ssh_file_transfer_method": "sftp",
|
||||
"ssh_password": "{{user `password`}}",
|
||||
"ssh_port": 22,
|
||||
"ssh_timeout": "{{user `ssh_wait_timeout`}}",
|
||||
"ssh_username": "{{user `username`}}",
|
||||
"type": "qemu",
|
||||
"vm_name": "{{user `iso_name`}}.iso",
|
||||
"vnc_bind_address": "{{user `vnc_bind_address`}}",
|
||||
"vnc_port_max": "{{user `vnc_port_max`}}",
|
||||
"vnc_port_min": "{{user `vnc_port_min`}}"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"environment_vars": [
|
||||
"ALPINE_VERSION={{user `alpine_version`}}",
|
||||
"HOSTNAME={{user `hostname`}}"
|
||||
],
|
||||
"script": "packer/alpine/setup.sh",
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"expect_disconnect": true,
|
||||
"inline": [
|
||||
"/usr/bin/eject -s",
|
||||
"/sbin/reboot"
|
||||
],
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"extra_arguments": [
|
||||
"--extra-vars",
|
||||
"{{user `ansible_extra_vars`}}",
|
||||
"{{user `ansible_verbose`}}"
|
||||
],
|
||||
"inventory_directory": "ansible/inventories",
|
||||
"pause_before": "16s",
|
||||
"playbook_file": "ansible/playbook.yml",
|
||||
"sftp_command": "/usr/lib/ssh/sftp-server -e",
|
||||
"type": "ansible",
|
||||
"user": "{{user `ansible_user`}}"
|
||||
}
|
||||
],
|
||||
"variables": {
|
||||
"accelerator": "kvm",
|
||||
"alpine_arch": "x86_64",
|
||||
"alpine_release": "3.12.0",
|
||||
"alpine_version": "3.12",
|
||||
"ansible_extra_vars": "target=default",
|
||||
"ansible_user": "root",
|
||||
"ansible_verbose": "-v",
|
||||
"boot_wait": "8s",
|
||||
"hostname": "alpine",
|
||||
"iso_name": "alpine-3.12.0-x86_64",
|
||||
"iso_size": "1024",
|
||||
"output": "build/iso",
|
||||
"password": "alpine",
|
||||
"qemuargs": "",
|
||||
"ssh_port_max": "2222",
|
||||
"ssh_port_min": "2222",
|
||||
"ssh_wait_timeout": "32s",
|
||||
"template": "alpine",
|
||||
"username": "root",
|
||||
"vnc_bind_address": "127.0.0.1",
|
||||
"vnc_port_max": "5900",
|
||||
"vnc_port_min": "5900"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
|
||||
variable "accelerator" {
|
||||
type = string
|
||||
default = "kvm"
|
||||
}
|
||||
|
||||
variable "alpine_arch" {
|
||||
type = string
|
||||
default = "x86_64"
|
||||
}
|
||||
|
||||
variable "alpine_release" {
|
||||
type = string
|
||||
default = "3.16.0"
|
||||
}
|
||||
|
||||
variable "alpine_version" {
|
||||
type = string
|
||||
default = "3.16"
|
||||
}
|
||||
|
||||
variable "ansible_extra_vars" {
|
||||
type = string
|
||||
default = "target=default"
|
||||
}
|
||||
|
||||
variable "ansible_user" {
|
||||
type = string
|
||||
default = "root"
|
||||
}
|
||||
|
||||
variable "ansible_verbose" {
|
||||
type = string
|
||||
default = "-v"
|
||||
}
|
||||
|
||||
variable "boot_wait" {
|
||||
type = string
|
||||
default = "8s"
|
||||
}
|
||||
|
||||
variable "hostname" {
|
||||
type = string
|
||||
default = "alpine"
|
||||
}
|
||||
|
||||
variable "iso_name" {
|
||||
type = string
|
||||
default = "alpine-3.16.0-x86_64"
|
||||
}
|
||||
|
||||
variable "iso_size" {
|
||||
type = string
|
||||
default = "1024"
|
||||
}
|
||||
|
||||
variable "nameserver" {
|
||||
type = string
|
||||
default = "1.1.1.1"
|
||||
}
|
||||
|
||||
variable "output" {
|
||||
type = string
|
||||
default = "build/iso"
|
||||
}
|
||||
|
||||
variable "password" {
|
||||
type = string
|
||||
default = "alpine"
|
||||
}
|
||||
|
||||
variable "pause_before" {
|
||||
type = string
|
||||
default = "24s"
|
||||
}
|
||||
|
||||
variable "qemuargs" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "ssh_port_max" {
|
||||
type = string
|
||||
default = "2222"
|
||||
}
|
||||
|
||||
variable "ssh_port_min" {
|
||||
type = string
|
||||
default = "2222"
|
||||
}
|
||||
|
||||
variable "ssh_timeout" {
|
||||
type = string
|
||||
default = "42s"
|
||||
}
|
||||
|
||||
variable "template" {
|
||||
type = string
|
||||
default = "alpine"
|
||||
}
|
||||
|
||||
variable "username" {
|
||||
type = string
|
||||
default = "root"
|
||||
}
|
||||
|
||||
variable "vnc_bind_address" {
|
||||
type = string
|
||||
default = "127.0.0.1"
|
||||
}
|
||||
|
||||
variable "vnc_port_max" {
|
||||
type = string
|
||||
default = "5900"
|
||||
}
|
||||
|
||||
variable "vnc_port_min" {
|
||||
type = string
|
||||
default = "5900"
|
||||
}
|
||||
|
||||
source "qemu" "autogenerated_1" {
|
||||
accelerator = "${var.accelerator}"
|
||||
boot_command = ["${var.username}<enter>", "passwd<enter>${var.password}<enter>${var.password}<enter>", "ifconfig eth0 up && udhcpc -i eth0<enter>", "apk add --repository http://dl-cdn.alpinelinux.org/alpine/v${var.alpine_version}/main dropbear dropbear-openrc openssh-sftp-server<enter>", "rc-update add dropbear<enter>", "echo -e 'auto eth0\\niface eth0 inet dhcp' > /etc/network/interfaces<enter>", "mkdir -p /etc/dropbear<enter>", "dropbearkey -t ed25519 -f /etc/dropbear/dropbear_ed25519_host_key<enter>", "rc-service dropbear start<enter>", "<wait>"]
|
||||
boot_wait = "${var.boot_wait}"
|
||||
disk_interface = "virtio"
|
||||
disk_size = "${var.iso_size}"
|
||||
format = "raw"
|
||||
headless = true
|
||||
host_port_max = "${var.ssh_port_max}"
|
||||
host_port_min = "${var.ssh_port_min}"
|
||||
iso_checksum = "file:http://dl-cdn.alpinelinux.org/alpine/v${var.alpine_version}/releases/${var.alpine_arch}/alpine-virt-${var.alpine_release}-${var.alpine_arch}.iso.sha256"
|
||||
iso_url = "http://dl-cdn.alpinelinux.org/alpine/v${var.alpine_version}/releases/${var.alpine_arch}/alpine-virt-${var.alpine_release}-${var.alpine_arch}.iso"
|
||||
net_device = "virtio-net"
|
||||
output_directory = "${var.output}"
|
||||
qemuargs = [["-device", "virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x7"], ["-object", "rng-random,filename=/dev/urandom,id=rng0"]]
|
||||
// qemuargs = ["${var.qemuargs}"]
|
||||
shutdown_command = "/sbin/poweroff"
|
||||
ssh_file_transfer_method = "sftp"
|
||||
ssh_password = "${var.password}"
|
||||
ssh_port = 22
|
||||
ssh_timeout = "${var.ssh_timeout}"
|
||||
ssh_username = "${var.username}"
|
||||
vm_name = "${var.iso_name}.iso"
|
||||
vnc_bind_address = "${var.vnc_bind_address}"
|
||||
vnc_port_max = "${var.vnc_port_max}"
|
||||
vnc_port_min = "${var.vnc_port_min}"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.qemu.autogenerated_1"]
|
||||
|
||||
provisioner "shell" {
|
||||
environment_vars = ["ALPINE_VERSION=${var.alpine_version}", "HOSTNAME=${var.hostname}", "NAMESERVER=${var.nameserver}"]
|
||||
script = "packer/alpine/setup.sh"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
expect_disconnect = true
|
||||
inline = ["/usr/bin/eject -s", "/sbin/reboot"]
|
||||
}
|
||||
|
||||
provisioner "ansible" {
|
||||
// https://github.com/hashicorp/packer-plugin-ansible/issues/69
|
||||
ansible_ssh_extra_args = ["-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"]
|
||||
extra_arguments = ["--extra-vars", "${var.ansible_extra_vars}", "${var.ansible_verbose}"]
|
||||
inventory_directory = "ansible/inventories"
|
||||
pause_before = "${var.pause_before}"
|
||||
playbook_file = "ansible/playbook.yml"
|
||||
sftp_command = "/usr/lib/ssh/sftp-server -e"
|
||||
use_proxy = "true"
|
||||
use_sftp = "true"
|
||||
user = "${var.ansible_user}"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
ALPINE_VERSION="${ALPINE_VERSION:-3.10}"
|
||||
ALPINE_VERSION="${ALPINE_VERSION:-3.16}"
|
||||
APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community"
|
||||
BOOT_SIZE="32"
|
||||
DISKOPTS="-s 0 -m sys /dev/vda"
|
||||
DNSOPTS="-n 8.8.8.8"
|
||||
DNSOPTS="-n ${NAMESERVER:-1.1.1.1}"
|
||||
HOSTNAME="${HOSTNAME:-alpine}"
|
||||
HOSTNAMEOPTS="-n ${HOSTNAME}"
|
||||
INTERFACESOPTS="auto lo
|
||||
@@ -15,9 +15,6 @@ iface lo inet loopback
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
|
||||
auto eth1
|
||||
iface eth1 inet dhcp
|
||||
"
|
||||
KEYMAPOPTS="fr fr"
|
||||
NTPOPTS="-c openntpd"
|
||||
@@ -35,7 +32,7 @@ http://dl-8.alpinelinux.org/alpine/"
|
||||
/sbin/setup-hostname ${HOSTNAMEOPTS}
|
||||
echo "${INTERFACESOPTS}" | /sbin/setup-interfaces -i
|
||||
# /etc/init.d/networking --quiet start >/dev/null
|
||||
# /sbin/setup-dns ${DNSOPTS}
|
||||
/sbin/setup-dns ${DNSOPTS}
|
||||
/sbin/setup-timezone ${TIMEZONEOPTS}
|
||||
/sbin/setup-proxy -q ${PROXYOPTS}
|
||||
/sbin/setup-apkrepos ${APKREPOSOPTS}
|
||||
|
||||
Reference in New Issue
Block a user