~lamont/maas/bug-1567176

1
2
3
4
5
6
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
Local Mirroring of Boot Images
==============================

Boot images are delivered to MAAS via the simplestreams protocol.  It is
useful in some situations, such as testing, to mirror the images locally
so that you don't need to repeatedly pull them down over a slower Internet
link.

First, install the required packages on the host where you wish to store
the mirrored images::

  $ sudo apt-get install simplestreams ubuntu-cloudimage-keyring apache2

Now you can pull the images over using the mirroring tools for simplestreams.
This example gets the daily trusty (14.04) and precise (12.04) images for the
amd64/generic and amd64/hwe-t architectures::

  $ sudo sstream-mirror --keyring=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg https://images.maas.io/ephemeral-v2/daily/ /var/www/html/maas/images/ephemeral-v2/daily 'arch=amd64' 'subarch~(generic|hwe-t)' 'release~(trusty|precise)' --max=1

This may take a while as hundreds of megabytes will be downloaded.

The images will be written to the local disk and you can verify their
presence by browsing to
``http://<server>/maas/images/ephemeral-v2/daily/streams/v1/index.sjson``
(replace ``<server>`` with your own server's name).

It is a good idea to configure a ``cron`` job to repeat this import on a
regular basis to keep your mirror up-to-date.


Configuring MAAS to use the local mirror
----------------------------------------

You can do this using the API or the web UI.  To do this via the API you
can use the ``maas`` (see :doc:`maascli`) command, logged in as the admin
user::

  $ maas <profile> boot-sources create url=http://<server>/images/ephemeral-v2/releases/ keyring_filename=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg

And then initiate the download with::

  $ maas <profile> boot-resources import

See :doc:`bootsources` for more detail.

In the web UI, browse to the Settings tab as the admin user and scroll down
to the "Boot Images" section.  There you will find input boxes for the
Sync URL and the keyring path, which should be set as the values in the API
example above.

The import is initiated by browsing to the Images tab and following the
instructions on that page.