Newer
Older
# TL;DR
~~~
# download packer_x.x.x_linux_amd64.zip from https://www.packer.io/downloads.html
unzip packer_x.x.x_linux_amd64.zip
./packer build -only=qemu -var headless=true vtp.json
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
~~~
# Overview
The VTP virtual machine is built using a scripted install process. This
results in an image which can be distributed to trainers and either run on
their local hardware or in a third-party cloud.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
v
Build Ubuntu
16.04+ZFS image
|
v
Local
configuration
(bridges, DNS,
dynamips etc)
|
v
Pull in LXD
master image
|
v
Make master clones
|
v
Customise masters
| | |
v v v
Nagios Smokeping etc...
| | |
v v v
Clones Clones Clones
\ | /
v v v
Bootable raw image
|
v
Convert to:
qcow2
vmdk [vdi]
ami [gce]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Packer
The build-from-ISO process is driven by [packer](https://www.packer.io/)
[Download](https://www.packer.io/downloads.html) the binary into the top
level of this repo and unzip it. Then run using:
~~~
./packer build [-only=qemu] [-var headless=true] vtp.json
* `-only=qemu` is if there are multiple [builders](https://www.packer.io/docs/templates/builders.html)
defined and you only want to run one. For example, in future we could include
configs for building images on EC2 and GCE)
* `-var headless=true` is required if you are running on a system with no
graphics (e.g. ssh to remote box without -X for X11 forwarding)
The configuration consists of a json file which controls packer, and a
preseed file which controls the ubuntu installer. The files here are
derived from:
* The puppetlabs [ubuntu 16.04 templates](https://github.com/puppetlabs/puppetlabs-packer/tree/master/templates/ubuntu-16.04), in particular the vmware-iso one
* The packer [qemu builder](https://www.packer.io/docs/builders/qemu.html) example config
* The ubuntu [example preseed](https://help.ubuntu.com/lts/installation-guide/example-preseed.txt) file
## Viewing progress at the console
If you have an X11 environment (either you are working at a graphical console, or
you used ssh -X to enable X11 forwarding) then a console window is created
automatically.
If this doesn't work, then you can set `-var headless=true` and it will run in
a disconnected VNC session. If you wish to monitor the progress, look through the
output for this message:
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
~~~
==> qemu: Found available VNC port: 5915
~~~
(the number is dynamic), and then from a laptop run
~~~
vncviewer -Shared <hostname>:<display>
~~~
e.g. `vncviewer -Shared 10.10.0.241:15`.
## Debugging
If things go wrong with packer, see the [debugging guide](https://www.packer.io/docs/other/debugging.html)
You get more information if you run:
~~~
PACKER_LOG=1 ./packer build foo.json
~~~
## Ubuntu ISO installation
For an [automated Ubuntu install](https://help.ubuntu.com/lts/installation-guide/amd64/ch04s06.html)
there are two options: [preseeding](https://help.ubuntu.com/lts/installation-guide/amd64/apb.html)
or [kickstart](https://help.ubuntu.com/community/KickstartCompatibility)
The kickstart files are simpler and can be created using
[system-config-kickstart](http://packages.ubuntu.com/xenial/system-config-kickstart)
on an Ubuntu 16.04 desktop machine. However the Ubuntu kickstart implementation offers
only a subset of features and is really just a frontend to selected preseed variables.
Installing Ubuntu with zfs root filesystem is not yet supported by the installer:
[1](https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-install-Ubuntu-16.04-to-a-Native-ZFS-Root-Filesystem)
[2](https://github.com/zfsonlinux/zfs/wiki/Ubuntu-16.04-Root-on-ZFS)
[3](http://dotfiles.tnetconsulting.net/articles/2016/0327/ubuntu-zfs-native-root.html)
For our purposes it's sufficient to have an ext4 root filesystem and create
a separate ZFS partition for LXD. We lose the ability to snapshot the root
and to have compression on the root.