Minimal solar VM packer template
Alpine linux as a base, vbox and libvirt Change-Id: Iaa37b1ae02b4b0d22fc01fbeff5c6ce96e0b2699
This commit is contained in:
parent
5b9d856ff8
commit
7325a9371d
2
bootstrap/alpine/README.md
Normal file
2
bootstrap/alpine/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
This directory is adjusted and modified version of:
|
||||||
|
https://github.com/maier/packer-templates/tree/master/alpine3.3
|
16
bootstrap/alpine/http/answers_qemu
Normal file
16
bootstrap/alpine/http/answers_qemu
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
KEYMAPOPTS="us us"
|
||||||
|
HOSTNAMEOPTS="-n solar"
|
||||||
|
INTERFACESOPTS="auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet dhcp
|
||||||
|
hostname solar
|
||||||
|
"
|
||||||
|
DNSOPTS="-d local -n 8.8.8.8 8.8.4.4"
|
||||||
|
TIMEZONEOPTS="-z UTC"
|
||||||
|
PROXYOPTS="none"
|
||||||
|
APKREPOSOPTS="-r"
|
||||||
|
SSHDOPTS="-c openssh"
|
||||||
|
NTPOPTS="-c openntpd"
|
||||||
|
DISKOPTS="-s 0 -m sys /dev/vda"
|
16
bootstrap/alpine/http/answers_vbox
Normal file
16
bootstrap/alpine/http/answers_vbox
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
KEYMAPOPTS="us us"
|
||||||
|
HOSTNAMEOPTS="-n solar"
|
||||||
|
INTERFACESOPTS="auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet dhcp
|
||||||
|
hostname solar
|
||||||
|
"
|
||||||
|
DNSOPTS="-d local -n 8.8.8.8 8.8.4.4"
|
||||||
|
TIMEZONEOPTS="-z UTC"
|
||||||
|
PROXYOPTS="none"
|
||||||
|
APKREPOSOPTS="-r"
|
||||||
|
SSHDOPTS="-c openssh"
|
||||||
|
NTPOPTS="-c openntpd"
|
||||||
|
DISKOPTS="-s 0 -m sys /dev/sda"
|
19
bootstrap/alpine/scripts/00base.sh
Normal file
19
bootstrap/alpine/scripts/00base.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
set -ux
|
||||||
|
|
||||||
|
apk upgrade -U --available
|
||||||
|
|
||||||
|
source /etc/os-release
|
||||||
|
|
||||||
|
cat << EOF > /etc/motd
|
||||||
|
|
||||||
|
$PRETTY_NAME ($VERSION_ID) Development Environment
|
||||||
|
|
||||||
|
Built for use with Vagrant using:
|
||||||
|
<https://github.com/maier/packer-templates>
|
||||||
|
|
||||||
|
See the Alpine Wiki for how-to guides and
|
||||||
|
general information about administrating
|
||||||
|
Alpine systems and development.
|
||||||
|
See <http://wiki.alpinelinux.org>
|
||||||
|
|
||||||
|
EOF
|
5
bootstrap/alpine/scripts/01alpine.sh
Normal file
5
bootstrap/alpine/scripts/01alpine.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set -ux
|
||||||
|
|
||||||
|
# nothing special required
|
||||||
|
|
||||||
|
exit 0
|
5
bootstrap/alpine/scripts/01networking.sh
Normal file
5
bootstrap/alpine/scripts/01networking.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set -ux
|
||||||
|
|
||||||
|
# nothing special required
|
||||||
|
|
||||||
|
exit 0
|
10
bootstrap/alpine/scripts/02sshd.sh
Normal file
10
bootstrap/alpine/scripts/02sshd.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set -eux
|
||||||
|
|
||||||
|
# add in order to allow packer ssh access to provision
|
||||||
|
# the system, remove here to make box more secure
|
||||||
|
sed -i '/^PermitRootLogin yes/d' /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# make 'vagrant ssh' connections faster
|
||||||
|
echo "UseDNS no" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
|
25
bootstrap/alpine/scripts/03vagrant.sh
Normal file
25
bootstrap/alpine/scripts/03vagrant.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
set -exu
|
||||||
|
|
||||||
|
date > /etc/vagrant_box_build_time
|
||||||
|
|
||||||
|
#
|
||||||
|
# bash for vagrant (default shell is bash)
|
||||||
|
# doesn't look like there is an easy way for vagrant guest
|
||||||
|
# plugin to register a default shell. easier than always
|
||||||
|
# having to *remember* to configure `ssh.shell` for
|
||||||
|
# alpine boxes.
|
||||||
|
#
|
||||||
|
# cURL for initial vagrant key install from vagrant github repo.
|
||||||
|
# on first 'vagrant up', overwritten with a local, secure key.
|
||||||
|
#
|
||||||
|
apk add bash curl
|
||||||
|
|
||||||
|
adduser -D vagrant
|
||||||
|
echo "vagrant:vagrant" | chpasswd
|
||||||
|
|
||||||
|
mkdir -pm 700 /home/vagrant/.ssh
|
||||||
|
|
||||||
|
curl -sSo /home/vagrant/.ssh/authorized_keys 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub'
|
||||||
|
|
||||||
|
chown -R vagrant:vagrant /home/vagrant/.ssh
|
||||||
|
chmod -R go-rwsx /home/vagrant/.ssh
|
7
bootstrap/alpine/scripts/04sudoers.sh
Normal file
7
bootstrap/alpine/scripts/04sudoers.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
set -eux
|
||||||
|
|
||||||
|
apk add sudo
|
||||||
|
adduser vagrant wheel
|
||||||
|
|
||||||
|
echo "Defaults exempt_group=wheel" > /etc/sudoers
|
||||||
|
echo "%wheel ALL=NOPASSWD:ALL" >> /etc/sudoers
|
53
bootstrap/alpine/scripts/90virtualbox.sh
Normal file
53
bootstrap/alpine/scripts/90virtualbox.sh
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
set -eux
|
||||||
|
echo "VBoxGuestAdditions currently do not build or install on Alpine Linux."
|
||||||
|
exit 0
|
||||||
|
#
|
||||||
|
# #
|
||||||
|
# # VBoxGuestAdditions fails to install.
|
||||||
|
# #
|
||||||
|
# # Alpine is intended to be 'minimal' so
|
||||||
|
# # there are certain things VBGA
|
||||||
|
# # 1. needs
|
||||||
|
# # 2. *assumes* are available
|
||||||
|
# # 3. or function a specific way
|
||||||
|
# # which is, not yet, the case...
|
||||||
|
# #
|
||||||
|
#
|
||||||
|
# mkdir -p /mnt/virtualbox
|
||||||
|
# retval=$?
|
||||||
|
# [ $retval -eq 0 ] || exit $retval
|
||||||
|
#
|
||||||
|
# modprobe loop
|
||||||
|
# retval=$?
|
||||||
|
# [ $retval -eq 0 ] || exit $retval
|
||||||
|
#
|
||||||
|
# LOOP=`losetup -f`
|
||||||
|
# retval=$?
|
||||||
|
# [ $retval -eq 0 ] || exit $retval
|
||||||
|
#
|
||||||
|
# losetup $LOOP /root/VBoxGuestAdditions.iso
|
||||||
|
# retval=$?
|
||||||
|
# [ $retval -eq 0 ] || exit $retval
|
||||||
|
#
|
||||||
|
# mount -t iso9660 -o ro $LOOP /mnt/virtualbox
|
||||||
|
# retval=$?
|
||||||
|
# [ $retval -eq 0 ] || exit $retval
|
||||||
|
#
|
||||||
|
# # current error 'unable to determine library path.'
|
||||||
|
# # "ldconfig -v" does not result in a list of valid
|
||||||
|
# # library paths (it is actually a shell script which
|
||||||
|
# # silently ignores -v).
|
||||||
|
# #
|
||||||
|
# # there are other issues as well, which have been
|
||||||
|
# # open with oracle/virtualbox for several years.
|
||||||
|
# # without forward progress (according to search
|
||||||
|
# # results and skimming through various discussions).
|
||||||
|
# sh /mnt/virtualbox/VBoxLinuxAdditions.run
|
||||||
|
# retval=$?
|
||||||
|
# [ $retval -eq 0 ] || exit $retval
|
||||||
|
#
|
||||||
|
# ln -s /opt/VBoxGuestAdditions-*/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
|
||||||
|
# umount /mnt/virtualbox
|
||||||
|
# rm -rf /root/VBoxGuestAdditions.iso
|
||||||
|
#
|
||||||
|
# # END
|
54
bootstrap/alpine/scripts/98solar.sh
Executable file
54
bootstrap/alpine/scripts/98solar.sh
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# install required stuff
|
||||||
|
apk add --no-cache py-pip openssl git gcc build-base python-dev libffi libffi-dev
|
||||||
|
|
||||||
|
# install packages for solar transports
|
||||||
|
# (sshpass -> password passing for SSH commands)
|
||||||
|
apk add --no-cache rsync sshpass
|
||||||
|
|
||||||
|
mkdir -p /opt
|
||||||
|
cd /opt
|
||||||
|
git clone https://github.com/openstack/solar.git
|
||||||
|
cd /opt/solar
|
||||||
|
sudo sed -i '/ansible.*/ s/^#*/#/' requirements.txt
|
||||||
|
pip install pbr && pip install -e .
|
||||||
|
chown -R vagrant: /opt/solar
|
||||||
|
mkdir -p /etc/solar
|
||||||
|
echo "solar_db: sqlite:////home/vagrant/solar.db" > /etc/solar/solar.yaml
|
||||||
|
mkdir -p /var/lib/solar/repositories
|
||||||
|
chown -R vagrant: /var/lib/solar/repositories
|
||||||
|
|
||||||
|
# ssh config
|
||||||
|
cat <<EOF >>/home/vagrant/.ssh/config
|
||||||
|
Host *
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# worker
|
||||||
|
cat <<EOF >>/etc/init.d/solar-worker
|
||||||
|
#!/sbin/runscript
|
||||||
|
# $Header: $
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need net
|
||||||
|
need localmount
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
ebegin "Starting solar-worker"
|
||||||
|
exec start-stop-daemon -b --chdir /tmp --start --user vagrant --make-pidfile --pidfile /tmp/solar-worker.pid --exec solar-worker
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
ebegin "Stopping solar-worker"
|
||||||
|
exec start-stop-daemon --stop --user vagrant --pidfile /tmp/solar-worker.pid --exec solar-worker
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
chmod +x /etc/init.d/solar-worker
|
||||||
|
rc-update add solar-worker default
|
11
bootstrap/alpine/scripts/99minimize.sh
Normal file
11
bootstrap/alpine/scripts/99minimize.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
set -ux
|
||||||
|
|
||||||
|
dd if=/dev/zero of=/EMPTY bs=1M
|
||||||
|
rm -f /EMPTY
|
||||||
|
# Block until the empty file has been removed, otherwise, Packer
|
||||||
|
# will try to kill the box while the disk is still full and that's bad
|
||||||
|
sync
|
||||||
|
sync
|
||||||
|
sync
|
||||||
|
|
||||||
|
exit 0
|
15
bootstrap/alpine/sh_vars
Normal file
15
bootstrap/alpine/sh_vars
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
dist_name="alpine"
|
||||||
|
dist_vers="3.3"
|
||||||
|
dist_arch="x86_64"
|
||||||
|
|
||||||
|
# local or remote
|
||||||
|
build_type="local"
|
||||||
|
|
||||||
|
# set in .bashrc
|
||||||
|
# ATLAS_USER_NAME="maier"
|
||||||
|
#
|
||||||
|
# default in atlas.sh is fine
|
||||||
|
# ATLAS_BOX_NAME="${dist_name}-${dist_vers}-${dist_arch}"
|
||||||
|
|
||||||
|
# END
|
147
bootstrap/alpine/solar-minimal.json
Normal file
147
bootstrap/alpine/solar-minimal.json
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
{
|
||||||
|
"description": "Build base Alpine Linux x86_64",
|
||||||
|
"provisioners": [
|
||||||
|
{
|
||||||
|
"type": "shell",
|
||||||
|
"scripts": [
|
||||||
|
"scripts/00base.sh",
|
||||||
|
"scripts/01alpine.sh",
|
||||||
|
"scripts/01networking.sh",
|
||||||
|
"scripts/02sshd.sh",
|
||||||
|
"scripts/03vagrant.sh",
|
||||||
|
"scripts/04sudoers.sh",
|
||||||
|
"scripts/90virtualbox.sh",
|
||||||
|
"scripts/98solar.sh",
|
||||||
|
"scripts/99minimize.sh"
|
||||||
|
],
|
||||||
|
"override": {
|
||||||
|
"virtualbox-iso": {
|
||||||
|
"execute_command": "/bin/sh '{{.Path}}'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"builders": [
|
||||||
|
{
|
||||||
|
"type": "virtualbox-iso",
|
||||||
|
"virtualbox_version_file": ".vbox_version",
|
||||||
|
|
||||||
|
"guest_additions_mode": "disable",
|
||||||
|
"guest_os_type": "Linux26_64",
|
||||||
|
"headless": true,
|
||||||
|
"disk_size": 1024,
|
||||||
|
"http_directory": "http",
|
||||||
|
|
||||||
|
"iso_url": "http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86_64/alpine-3.3.3-x86_64.iso",
|
||||||
|
"iso_checksum": "af766ac6221c6f5b471ca388be22df81ac6f21be37486ba6846f115d1798528a",
|
||||||
|
"iso_checksum_type": "sha256",
|
||||||
|
|
||||||
|
"communicator": "ssh",
|
||||||
|
"ssh_username": "root",
|
||||||
|
"ssh_password": "vagrant",
|
||||||
|
"ssh_wait_timeout": "30m",
|
||||||
|
"shutdown_command": "/sbin/poweroff",
|
||||||
|
|
||||||
|
"boot_wait": "30s",
|
||||||
|
"boot_command": [
|
||||||
|
"root<enter><wait>",
|
||||||
|
"ifconfig eth0 up && udhcpc -i eth0<enter><wait>",
|
||||||
|
"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers_vbox<enter><wait>",
|
||||||
|
"setup-alpine -f answers_vbox<enter><wait5>",
|
||||||
|
"vagrant<enter><wait>",
|
||||||
|
"vagrant<enter><wait>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"y<enter>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"rc-service sshd stop<enter>",
|
||||||
|
"mount /dev/sda3 /mnt<enter>",
|
||||||
|
"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>",
|
||||||
|
"umount /mnt<enter>",
|
||||||
|
"reboot<enter>"
|
||||||
|
],
|
||||||
|
|
||||||
|
"hard_drive_interface": "sata",
|
||||||
|
"vboxmanage": [
|
||||||
|
["modifyvm", "{{.Name}}", "--memory", "512"],
|
||||||
|
["modifyvm", "{{.Name}}", "--cpus", "1"]
|
||||||
|
]
|
||||||
|
|
||||||
|
}, {
|
||||||
|
"type": "qemu",
|
||||||
|
"headless": true,
|
||||||
|
"disk_size": 1024,
|
||||||
|
"accelerator": "kvm",
|
||||||
|
"format": "qcow2",
|
||||||
|
"http_directory": "http",
|
||||||
|
|
||||||
|
"iso_url": "http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.3/releases/x86_64/alpine-3.3.3-x86_64.iso",
|
||||||
|
"iso_checksum": "af766ac6221c6f5b471ca388be22df81ac6f21be37486ba6846f115d1798528a",
|
||||||
|
"iso_checksum_type": "sha256",
|
||||||
|
|
||||||
|
"communicator": "ssh",
|
||||||
|
"ssh_username": "root",
|
||||||
|
"ssh_password": "vagrant",
|
||||||
|
"ssh_wait_timeout": "30m",
|
||||||
|
"shutdown_command": "/sbin/poweroff",
|
||||||
|
|
||||||
|
"boot_wait": "30s",
|
||||||
|
"boot_command": [
|
||||||
|
"root<enter><wait>",
|
||||||
|
"ifconfig eth0 up && udhcpc -i eth0<enter><wait>",
|
||||||
|
"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers_qemu<enter><wait>",
|
||||||
|
"setup-alpine -f answers_qemu<enter><wait5>",
|
||||||
|
"vagrant<enter><wait>",
|
||||||
|
"vagrant<enter><wait>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"y<enter>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"<wait10><wait10><wait10>",
|
||||||
|
"rc-service sshd stop<enter>",
|
||||||
|
"mount /dev/vda3 /mnt<enter>",
|
||||||
|
"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>",
|
||||||
|
"umount /mnt<enter>",
|
||||||
|
"reboot<enter>"
|
||||||
|
],
|
||||||
|
"qemuargs": [
|
||||||
|
[
|
||||||
|
"-m",
|
||||||
|
"512M"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"-smp",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"post-processors": [
|
||||||
|
[{
|
||||||
|
"type": "vagrant",
|
||||||
|
"keep_input_artifact": false,
|
||||||
|
"only": ["virtualbox-iso"],
|
||||||
|
"output": "solar-minimal-virtualbox.box"
|
||||||
|
},{
|
||||||
|
"type": "vagrant",
|
||||||
|
"keep_input_artifact": true,
|
||||||
|
"only": ["qemu"],
|
||||||
|
"output": "solar-minimal-qemu.box"
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user