Merge lp:~smoser/curtin/trunk.doc-interface into lp:~curtin-dev/curtin/trunk

Proposed by Scott Moser
Status: Merged
Merged at revision: 529
Proposed branch: lp:~smoser/curtin/trunk.doc-interface
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 268 lines (+158/-47)
5 files modified
doc/index.rst (+1/-0)
doc/topics/curthooks.rst (+108/-0)
doc/topics/networking.rst (+2/-0)
doc/topics/overview.rst (+45/-47)
doc/topics/storage.rst (+2/-0)
To merge this branch: bzr merge lp:~smoser/curtin/trunk.doc-interface
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+331608@code.launchpad.net

Commit message

doc: update documentation on curtin-hooks and non-ubuntu installation.

Add the section 'curthooks' to the documentation.
Generalize the environment variables in overview.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Minor spelling nits inline. Approved afterward. Good content (and good education/reference for me).

review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

ok. so comments in line. i took your obvious feedback and we can work on the others subsequently (mainly whether or not to document CURTIN_REPORTSTACK).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/index.rst'
--- doc/index.rst 2016-08-18 16:17:20 +0000
+++ doc/index.rst 2017-09-29 22:00:32 +0000
@@ -17,6 +17,7 @@
17 topics/apt_source17 topics/apt_source
18 topics/networking18 topics/networking
19 topics/storage19 topics/storage
20 topics/curthooks
20 topics/reporting21 topics/reporting
21 topics/development22 topics/development
22 topics/integration-testing23 topics/integration-testing
2324
=== added file 'doc/topics/curthooks.rst'
--- doc/topics/curthooks.rst 1970-01-01 00:00:00 +0000
+++ doc/topics/curthooks.rst 2017-09-29 22:00:32 +0000
@@ -0,0 +1,108 @@
1========================================
2Curthooks / New OS Support
3========================================
4Curtin has built-in support for installation of Ubuntu.
5Other operating systems are supported through a mechanism called
6'curthooks' or 'curtin-hooks'.
7
8A curtin install runs through different stages. See the
9:ref:`Stages <stages>`
10documentation for function of each stage.
11The stages communicate with each other via data in a working directory and
12environment variables as described in
13:ref:`Command Environment`.
14
15Curtin handles partitioning, filesystem creation and target filesystem
16population for all operating systems. Curthooks are the mechanism provided
17so that the operating system can customize itself before reboot. This
18customization typically would need to include:
19
20 - ensuring that appropriate device drivers are loaded on first boot
21 - consuming the network interfaces file and applying its declarations.
22 - ensuring that necessary packages are installed to utilize storage
23 configuration or networking configuration.
24 - making the system boot (running grub-install or equivalent).
25
26Image provided curtin-hooks
27---------------------------
28An image provides curtin hooks support by containing a file
29``/curtin/curtin-hooks``.
30
31If an Ubuntu image image contains this path it will override the builtin
32curtin support.
33
34The ``curtin-hooks`` program should be executable in the filesystem and
35will be executed without any arguments. It will be executed in the install
36environment, *not* the target environment. A change of root to the
37target environment can be done with ``curtin in-target``.
38
39The hook is provided with some environment variables that can be used
40to find more information. See the :ref:`Command Environment` doc for
41details. Specifically interesting to this stage are:.
42
43 - ``OUTPUT_NETWORK_CONFIG``: This is a path to the file created during
44 network discovery stage.
45 - ``FSTAB``: This is a path to the file created during partitioning stage
46 - ``CONFIG``: This is a path to the curtin config file. It is provided so
47 that additional configuration could be provided through to the OS
48 customization.
49
50**TODO**: We should add 'PYTHON' or 'CURTIN_PYTHON' to this environment
51so that the hook can easily run a python program with the same python
52that curtin ran with (ie, python2 or python3).
53
54
55Networking configuration
56------------------------
57Access to the network configuration that is desired is inside the config
58and is in the format described in :ref:`networking`.
59
60.. TODO: We should guarantee that the presense
61 of network config v1 in the file OUTPUT_NETWORK_CONFIG.
62
63The curtin-hooks program must read the configuration from the
64path contained in ``OUTPUT_NETWORK_CONFIG`` and then set up
65the installed system to use it.
66
67If the installed system has cloud-init at version 17.1 or higher, it may
68be possible to simply copy this section into the target in
69``/etc/cloud/cloud.cfg.d/`` and let cloud-init render the correct
70networking on first boot.
71
72Storage configuration
73---------------------
74Access to the storage configuration that was set up is inside the config
75and is in the format described in :ref:`storage`.
76
77.. TODO: We should guarantee that the presense
78 of storage config v1 in the file OUTPUT_STORAGE_CONFIG.
79 This would mean the user would not have to pull it out
80 of CONFIG. We should guarantee its presense and format
81 even in the 'simple' path.
82
83To apply this storage configuration, the curthooks may need to:
84
85 * update /etc/fstab to add the expected mounts entries. The environment
86 variable ``FSTAB`` contains a path to a file that may be suitable
87 for use.
88
89 * install any packages that are not already installed that are required
90 to boot with the provided storage config. For example, if the storage
91 layout includes raid you may need to install the mdadm package.
92
93 * update or create an initramfs.
94
95
96System boot
97-----------
98In Ubuntu, curtin will run 'grub-setup' and to install grub. This covers
99putting the bootloader onto the disk(s) that are marked as
100``grub_device``. The provided hook will need to do the equivalent
101operation.
102
103finalize hook
104-------------
105There is one other hook that curtin will invoke in an install, called
106``finalize``. This program is invoked in the same environment as
107``curtin-hooks`` above. It is intended to give the OS a final opportunity
108make updates before reboot. It is called before ``late_commands``.
0109
=== modified file 'doc/topics/networking.rst'
--- doc/topics/networking.rst 2016-08-18 15:39:15 +0000
+++ doc/topics/networking.rst 2017-09-29 22:00:32 +0000
@@ -1,3 +1,5 @@
1.. _networking:
2
1==========3==========
2Networking4Networking
3==========5==========
46
=== modified file 'doc/topics/overview.rst'
--- doc/topics/overview.rst 2016-08-18 16:02:27 +0000
+++ doc/topics/overview.rst 2017-09-29 22:00:32 +0000
@@ -4,6 +4,8 @@
44
5Curtin is intended to be a bare bones "installer". Its goal is to take data from a source, and get it onto disk as quick as possible and then boot it. The key difference from traditional package based installers is that curtin assumes the thing its installing is intelligent and will do the right thing.5Curtin is intended to be a bare bones "installer". Its goal is to take data from a source, and get it onto disk as quick as possible and then boot it. The key difference from traditional package based installers is that curtin assumes the thing its installing is intelligent and will do the right thing.
66
7.. _Stages:
8
7Stages9Stages
8------10------
9A usage of curtin will go through the following stages:11A usage of curtin will go through the following stages:
@@ -22,6 +24,32 @@
2224
23Curtin's assumption is that a fairly rich Linux (Ubuntu) environment is booted.25Curtin's assumption is that a fairly rich Linux (Ubuntu) environment is booted.
2426
27.. _Command Environment:
28
29Command Environment
30~~~~~~~~~~~~~~~~~~~
31Stages and commands invoked by curtin always have the following environment
32variables defined.
33
34- ``WORKING_DIR``: This is for inter-command state. It will be the same
35 directory for each command run and will only be deleted at the end of the
36 install. Files referenced in other environment variables will be in
37 this directory.
38
39- ``TARGET_MOUNT_POINT``: The path in the filesystem where the target
40 filesystem will be mounted.
41
42- ``OUTPUT_NETWORK_CONFIG``: After the network discovery stage, this file
43 should contain networking config information that should then be written
44 to the target.
45
46- ``OUTPUT_FSTAB``: After partitioning and filesystem creation, this file
47 will contain fstab(5) style content representing mounts.
48
49- ``CONFIG``: This variable contains a path to a yaml formatted file with
50 the fully rendered config.
51
52
25Early Commands53Early Commands
26~~~~~~~~~~~~~~54~~~~~~~~~~~~~~
27Early commands are executed on the system, and non-zero exit status will terminate the installation process. These commands are intended to be used for things like55Early commands are executed on the system, and non-zero exit status will terminate the installation process. These commands are intended to be used for things like
@@ -48,32 +76,23 @@
48 10_wipe_filesystems: curtin wipe --quick --all-unused-disks76 10_wipe_filesystems: curtin wipe --quick --all-unused-disks
49 50_setup_raid: curtin disk-setup --all-disks raid0 /77 50_setup_raid: curtin disk-setup --all-disks raid0 /
5078
51**Command environment**79
5280Network Discovery
53Partitioning commands have the following environment variables available to them:81~~~~~~~~~~~~~~~~~
5482Networking configuration is *discovered* in the 'network' stage.
55- ``WORKING_DIR``: This is simply for some sort of inter-command state. It will be the same directory for each command run and will only be deleted at the end of all partitioning_commands.83The default command run at this stage is ``curtin net-meta auto``. After
56- ``OUTPUT_FSTAB``: This is the target path for a fstab file. After all partitioning commands have been run, a file should exist, formatted per fstab(5) that describes how the filesystems should be mounted.84execution, it will write the discovered networking to the file specified
57- ``TARGET_MOUNT_POINT``:85in the environment variable ``OUTPUT_NETWORK_CONFIG``. The format of this
5886file is as described in :ref:`networking`.
5987
60Network Discovery and Setup88If curtin's config has a network section, the net-meta will simply parrot the
61~~~~~~~~~~~~~~~~~~~~~~~~~~~89data to the output file. If there is no network section, then its default
62Networking is done in a similar fashion to partitioning. A series of commands, specified in the config are run. At the end of these commands, a interfaces(5) style file is expected to be written to ``OUTPUT_INTERFACES``.90behavior is to copy existing config from the running environment.
6391
64Note, that as with fstab, this file is not copied verbatim to the target filesystem, but rather made available to the OS customization stage. That stage may just copy the file verbatim, but may also parse it, and use that as input.92Note, that as with fstab, this file is not copied verbatim to the target
6593filesystem, but rather made available to the OS customization stage. That
66**Config Example**::94stage may just copy the file verbatim, but may also parse it, and apply the
6795settings.
68 network_commands:
69 10_netconf: curtin network copy-existing
70
71**Command environment**
72
73Networking commands have the following environment variables available to them:
74
75- ``WORKING_DIR``: This is simply for some sort of inter-command state. It will be the same directory for each command run and will only be deleted at the end of all network_commands.
76- ``OUTPUT_INTERFACES``: This is the target path for an interfaces style file. After all commands have been run, a file should exist, formatted per interfaces(5) that describes the systems network setup.
7796
78Extraction of sources97Extraction of sources
79~~~~~~~~~~~~~~~~~~~~~98~~~~~~~~~~~~~~~~~~~~~
@@ -88,27 +107,6 @@
88107
89 wget $URL | tar -Sxvzf 108 wget $URL | tar -Sxvzf
90109
91Hook for installed OS to customize itself
92~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93After extraction of sources, the source that was extracted is then given a chance to customize itself for the system. This customization may include:
94 - ensuring that appropriate device drivers are loaded on first boot
95 - consuming the network interfaces file and applying its declarations.
96 - ensuring that necessary packages
97
98**Config Example**::
99
100 config_hook: {{TARGET_MP}}/opt/curtin/config-hook
101
102**Command environment**
103 - ``INTERFACES``: This is a path to the file created during networking stage
104 - ``FSTAB``: This is a path to the file created during partitioning stage
105 - ``CONFIG``: This is a path to the curtin config file. It is provided so that additional configuration could be provided through to the OS customization.
106
107**Helpers**
108
109Curtin provides some helpers to make the OS customization easier.
110 - `curtin in-target`: run the command while chrooted into the target.
111
112Final Commands110Final Commands
113~~~~~~~~~~~~~~111~~~~~~~~~~~~~~
114112
115113
=== modified file 'doc/topics/storage.rst'
--- doc/topics/storage.rst 2017-04-21 17:36:27 +0000
+++ doc/topics/storage.rst 2017-09-29 22:00:32 +0000
@@ -1,3 +1,5 @@
1.. _storage:
2
1=======3=======
2Storage4Storage
3=======5=======

Subscribers

People subscribed via source and target branches