import files
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# https://github.com/alpinelinux/alpine-conf/blob/master/setup-alpine.in
|
||||
|
||||
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
ALPINE_VERSION="${ALPINE_VERSION:-3.10}"
|
||||
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"
|
||||
HOSTNAME="${HOSTNAME:-alpine}"
|
||||
HOSTNAMEOPTS="-n ${HOSTNAME}"
|
||||
INTERFACESOPTS="auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
|
||||
auto eth1
|
||||
iface eth1 inet dhcp
|
||||
"
|
||||
KEYMAPOPTS="fr fr"
|
||||
NTPOPTS="-c openntpd"
|
||||
PROXYOPTS="none"
|
||||
SSHDOPTS="-c none"
|
||||
TIMEZONEOPTS="-z Europe/Paris"
|
||||
export MIRRORS="http://dl-cdn.alpinelinux.org/alpine/
|
||||
http://dl-2.alpinelinux.org/alpine/
|
||||
http://dl-3.alpinelinux.org/alpine/
|
||||
http://dl-4.alpinelinux.org/alpine/
|
||||
http://dl-5.alpinelinux.org/alpine/
|
||||
http://dl-8.alpinelinux.org/alpine/"
|
||||
|
||||
/sbin/setup-keymap ${KEYMAPOPTS}
|
||||
/sbin/setup-hostname ${HOSTNAMEOPTS}
|
||||
echo "${INTERFACESOPTS}" | /sbin/setup-interfaces -i
|
||||
# /etc/init.d/networking --quiet start >/dev/null
|
||||
# /sbin/setup-dns ${DNSOPTS}
|
||||
/sbin/setup-timezone ${TIMEZONEOPTS}
|
||||
/sbin/setup-proxy -q ${PROXYOPTS}
|
||||
/sbin/setup-apkrepos ${APKREPOSOPTS}
|
||||
/sbin/setup-ntp ${NTPOPTS}
|
||||
/sbin/setup-sshd ${SSHDOPTS}
|
||||
rc-update --quiet add networking boot
|
||||
rc-update --quiet add urandom boot
|
||||
/etc/init.d/hostname --quiet restart
|
||||
killall ntpd
|
||||
sed -i 's/constraints/# constraints/' /etc/ntpd.conf
|
||||
sed -i 's/^#NTPD_OPTS=$/NTPD_OPTS=-s/' /etc/conf.d/openntpd
|
||||
openrc boot
|
||||
openrc default
|
||||
|
||||
echo "y" | BOOT_SIZE="${BOOT_SIZE}" DEFAULT_DISK="none" /sbin/setup-disk -q ${DISKOPTS} || exit
|
||||
Reference in New Issue
Block a user