Skip to content

Commit

Permalink
Upgrade to Alpine 3.16.2
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Fraser <[email protected]>
  • Loading branch information
bobfraser1 committed Sep 12, 2022
1 parent e7a101b commit 8e60ced
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 54 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change log for packer-alpine

## v1.3.0

This release builds a VirtualBox VM (OVA) for Alpine 3.16.2

- Admin user is now created as part of setup-alpine
- SSH key is now in http/ssh.keys

## v1.2.1

This release builds a VirtualBox VM (OVA) for Alpine 3.15.4
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2017 Bob Fraser github.com/bobfraser1
Copyright (c) 2022 Bob Fraser github.com/bobfraser1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Build a virtual machine image for [Alpine linux](https://www.alpinelinux.org) us

This Packer template will build a [VirtualBox](https://www.virtualbox.org) VM (OVA) from an Alpine ISO image. Networking is configured for DHCP and an SSH user is created (default `vagrant` password `vagrant`) with sudo privileges.

**Security Note:** The Vagrant [insecure public key](https://github.com/hashicorp/vagrant/tree/master/keys) has been added. You can override `ssh_key` to provide your own secure ssh key.
**Security Note:** The Vagrant [insecure public key](https://github.com/hashicorp/vagrant/tree/master/keys) has been added. You can replace `http/ssh.keys` to provide your own secure ssh key.

You can customize this login

Expand Down
89 changes: 59 additions & 30 deletions alpine.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"root<enter><wait>",
"ifconfig eth0 up && udhcpc -i eth0<enter><wait5>",
"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>",
"setup-apkrepos -1<enter><wait5>",
"ERASE_DISKS='/dev/sda' setup-alpine -f $PWD/answers<enter><wait5>",
"{{user `ssh_password`}}<enter><wait>",
"{{user `ssh_password`}}<enter><wait30>",
"export ERASE_DISKS=/dev/sda<enter>",
"export USEROPTS='-a -u -g audio,video,netdev {{user `ssh_username`}}'<enter>",
"export USERSSHKEY='http://{{ .HTTPIP }}:{{ .HTTPPort }}/ssh.keys'<enter>",
"setup-alpine -f $PWD/answers<enter><wait5>",
"{{user `root_password`}}<enter><wait>",
"{{user `root_password`}}<enter><wait30>",
"mount /dev/sda3 /mnt<enter>",
"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>",
"umount /mnt ; reboot<enter>"
"umount /mnt; reboot<enter>"
],
"boot_wait": "10s",
"communicator": "ssh",
Expand All @@ -22,20 +24,53 @@
"headless": false,
"http_directory": "http",
"iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
"iso_urls": ["{{user `iso_local_url`}}", "{{user `iso_download_url`}}"],
"iso_urls": [
"{{user `iso_local_url`}}",
"{{user `iso_download_url`}}"
],
"keep_registered": "false",
"shutdown_command": "/sbin/poweroff",
"ssh_password": "{{user `ssh_password`}}",
"ssh_password": "{{user `root_password`}}",
"ssh_timeout": "10m",
"ssh_username": "root",
"type": "virtualbox-iso",
"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "{{user `memory`}}"],
["modifyvm", "{{.Name}}", "--cpus", "{{user `cpus`}}"],
["modifyvm", "{{.Name}}", "--rtcuseutc", "on"],
["modifyvm", "{{.Name}}", "--graphicscontroller", "vmsvga"],
["modifyvm", "{{.Name}}", "--vram", "6"],
["modifyvm", "{{.Name}}", "--vrde", "off"]
[
"modifyvm",
"{{.Name}}",
"--memory",
"{{user `memory`}}"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"{{user `cpus`}}"
],
[
"modifyvm",
"{{.Name}}",
"--rtcuseutc",
"on"
],
[
"modifyvm",
"{{.Name}}",
"--graphicscontroller",
"vmsvga"
],
[
"modifyvm",
"{{.Name}}",
"--vram",
"9"
],
[
"modifyvm",
"{{.Name}}",
"--vrde",
"off"
]
],
"vm_name": "{{user `vm_name`}}"
}
Expand All @@ -44,40 +79,34 @@
"provisioners": [
{
"inline": [
"echo http://dl-cdn.alpinelinux.org/alpine/v3.15/community >> /etc/apk/repositories",
"echo {{user `community_repo`}} >> /etc/apk/repositories",
"apk update",
"apk add sudo",
"apk upgrade",
"apk add virtualbox-guest-additions",
"echo '%wheel ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/wheel",
"apk add sudo",
"user={{user `ssh_username`}}",
"echo Add user $user with NOPASSWD sudo",
"adduser $user --disabled-password",
"echo $user 'ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/$user",
"chmod 0440 /etc/sudoers.d/$user",
"echo '{{user `ssh_username`}}:{{user `ssh_password`}}' | chpasswd",
"adduser $user wheel",
"echo add ssh key",
"cd ~{{user `ssh_username`}}",
"mkdir .ssh",
"chmod 700 .ssh",
"echo {{user `ssh_key`}} > .ssh/authorized_keys",
"chown -R $user .ssh",
"echo disable ssh root login",
"sed '/PermitRootLogin yes/d' -i /etc/ssh/sshd_config"
],
"type": "shell"
}
],
"variables": {
"community_repo": "http://dl-cdn.alpinelinux.org/alpine/v3.16/community",
"cpus": "1",
"disk_size": "10240",
"iso_checksum": "11cb6ceec4967e0089c44268d2cc7b4efbad74f40d962ecec558e1a8fb6f2ac9",
"iso_checksum": "6c7cb998ec2c8925d5a1239410a4d224b771203f916a18f8015f31169dd767a2",
"iso_checksum_type": "sha256",
"iso_download_url": "http://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-virt-3.15.4-x86_64.iso",
"iso_local_url": "../../iso/alpine-virt-3.15.4-x86_64.iso",
"iso_download_url": "https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso",
"iso_local_url": "../../iso/alpine-virt-3.16.2-x86_64.iso",
"memory": "1024",
"root_password": "vagrant",
"ssh_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key",
"ssh_password": "vagrant",
"ssh_username": "vagrant",
"vm_name": "alpine-3.15.4-x86_64"
"vm_name": "alpine-3.16.2-x86_64"
}
}
}
41 changes: 30 additions & 11 deletions http/answers
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,58 @@

# Use US layout with US variant
KEYMAPOPTS="us us"
#KEYMAPOPTS=none

# Set hostname to alpine
HOSTNAMEOPTS="-n alpine"
# Set hostname to 'alpine.localdomain'
HOSTNAMEOPTS=alpine.localdomain

# Set device manager to mdev
DEVDOPTS=mdev

# Contents of /etc/network/interfaces
INTERFACESOPTS="auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
hostname alpine.localdomain
"

# Search domain of example.com, Google public nameserver
# DNSOPTS="-d example.com 8.8.8.8"

# Set timezone to UTC
TIMEZONEOPTS="-z UTC"
TIMEZONEOPTS="UTC"
#TIMEZONEOPTS=none

# set http/ftp proxy
PROXYOPTS="none"
#PROXYOPTS="http://webproxy:8080"
PROXYOPTS=none

# Add first mirror
# Add first mirror (CDN)
APKREPOSOPTS="-1"

# Create admin user
#USEROPTS="-a -u -g audio,video,netdev juser"
#USERSSHKEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOIiHcbg/7ytfLFHUNLRgEAubFz/13SwXBOM/05GNZe4 [email protected]"
#USERSSHKEY="https://example.com/juser.keys"

# Install Openssh
SSHDOPTS="-c openssh"
SSHDOPTS=openssh
#ROOTSSHKEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOIiHcbg/7ytfLFHUNLRgEAubFz/13SwXBOM/05GNZe4 [email protected]"
#ROOTSSHKEY="https://example.com/juser.keys"

# Use openntpd
NTPOPTS="-c openntpd"
NTPOPTS="openntpd"
#NTPOPTS=none

# Use /dev/sda as a system disk
# Use /dev/sda as a sys disk
DISKOPTS="-m sys /dev/sda"
#DISKOPTS=none

# Setup storage with label APKOVL for config storage
#LBUOPTS="LABEL=APKOVL"
LBUOPTS=none

# Do not setup in /media/sdb1
# LBUOPTS="/media/sdb1"
# APKCACHEOPTS="/media/sdb1/cache"
#APKCACHEOPTS="/media/LABEL=APKOVL/cache"
APKCACHEOPTS=none
1 change: 1 addition & 0 deletions http/ssh.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
16 changes: 9 additions & 7 deletions vagrant/vagrant-cloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"post-processors": [
[
{
"include": ["info.json"],
"include": [
"info.json"
],
"output": "output-vagrant/{{user `box_name`}}.box",
"type": "vagrant",
"vagrantfile_template": "Vagrantfile"
Expand All @@ -27,11 +29,11 @@
]
],
"variables": {
"box_name": "alpine315",
"box_tag": "bobfraser1/alpine315",
"box_version": "1.0.1",
"box_version_description": "Alpine Linux v3.15.4\n\nGitHub: [bobfraser1/packer-alpine](https://github.com/bobfraser1/packer-alpine)",
"box_name": "alpine316",
"box_tag": "bobfraser1/alpine316",
"box_version": "1.0.0",
"box_version_description": "Alpine Linux v3.16.2\n\nGitHub: [bobfraser1/packer-alpine](https://github.com/bobfraser1/packer-alpine)",
"vagrant_cloud_token": "{{env `ATLAS_TOKEN`}}",
"vm_name": "alpine-3.15.4-x86_64"
"vm_name": "alpine-3.16.2-x86_64"
}
}
}
10 changes: 6 additions & 4 deletions vagrant/vagrant.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
"post-processors": [
[
{
"include": ["info.json"],
"include": [
"info.json"
],
"output": "output-vagrant/{{user `box_name`}}.box",
"type": "vagrant",
"vagrantfile_template": "Vagrantfile"
}
]
],
"variables": {
"box_name": "alpine315",
"vm_name": "alpine-3.15.4-x86_64"
"box_name": "alpine316",
"vm_name": "alpine-3.16.2-x86_64"
}
}
}

0 comments on commit 8e60ced

Please sign in to comment.