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
1=== modified file 'doc/index.rst'
2--- doc/index.rst 2016-08-18 16:17:20 +0000
3+++ doc/index.rst 2017-09-29 22:00:32 +0000
4@@ -17,6 +17,7 @@
5 topics/apt_source
6 topics/networking
7 topics/storage
8+ topics/curthooks
9 topics/reporting
10 topics/development
11 topics/integration-testing
12
13=== added file 'doc/topics/curthooks.rst'
14--- doc/topics/curthooks.rst 1970-01-01 00:00:00 +0000
15+++ doc/topics/curthooks.rst 2017-09-29 22:00:32 +0000
16@@ -0,0 +1,108 @@
17+========================================
18+Curthooks / New OS Support
19+========================================
20+Curtin has built-in support for installation of Ubuntu.
21+Other operating systems are supported through a mechanism called
22+'curthooks' or 'curtin-hooks'.
23+
24+A curtin install runs through different stages. See the
25+:ref:`Stages <stages>`
26+documentation for function of each stage.
27+The stages communicate with each other via data in a working directory and
28+environment variables as described in
29+:ref:`Command Environment`.
30+
31+Curtin handles partitioning, filesystem creation and target filesystem
32+population for all operating systems. Curthooks are the mechanism provided
33+so that the operating system can customize itself before reboot. This
34+customization typically would need to include:
35+
36+ - ensuring that appropriate device drivers are loaded on first boot
37+ - consuming the network interfaces file and applying its declarations.
38+ - ensuring that necessary packages are installed to utilize storage
39+ configuration or networking configuration.
40+ - making the system boot (running grub-install or equivalent).
41+
42+Image provided curtin-hooks
43+---------------------------
44+An image provides curtin hooks support by containing a file
45+``/curtin/curtin-hooks``.
46+
47+If an Ubuntu image image contains this path it will override the builtin
48+curtin support.
49+
50+The ``curtin-hooks`` program should be executable in the filesystem and
51+will be executed without any arguments. It will be executed in the install
52+environment, *not* the target environment. A change of root to the
53+target environment can be done with ``curtin in-target``.
54+
55+The hook is provided with some environment variables that can be used
56+to find more information. See the :ref:`Command Environment` doc for
57+details. Specifically interesting to this stage are:.
58+
59+ - ``OUTPUT_NETWORK_CONFIG``: This is a path to the file created during
60+ network discovery stage.
61+ - ``FSTAB``: This is a path to the file created during partitioning stage
62+ - ``CONFIG``: This is a path to the curtin config file. It is provided so
63+ that additional configuration could be provided through to the OS
64+ customization.
65+
66+**TODO**: We should add 'PYTHON' or 'CURTIN_PYTHON' to this environment
67+so that the hook can easily run a python program with the same python
68+that curtin ran with (ie, python2 or python3).
69+
70+
71+Networking configuration
72+------------------------
73+Access to the network configuration that is desired is inside the config
74+and is in the format described in :ref:`networking`.
75+
76+.. TODO: We should guarantee that the presense
77+ of network config v1 in the file OUTPUT_NETWORK_CONFIG.
78+
79+The curtin-hooks program must read the configuration from the
80+path contained in ``OUTPUT_NETWORK_CONFIG`` and then set up
81+the installed system to use it.
82+
83+If the installed system has cloud-init at version 17.1 or higher, it may
84+be possible to simply copy this section into the target in
85+``/etc/cloud/cloud.cfg.d/`` and let cloud-init render the correct
86+networking on first boot.
87+
88+Storage configuration
89+---------------------
90+Access to the storage configuration that was set up is inside the config
91+and is in the format described in :ref:`storage`.
92+
93+.. TODO: We should guarantee that the presense
94+ of storage config v1 in the file OUTPUT_STORAGE_CONFIG.
95+ This would mean the user would not have to pull it out
96+ of CONFIG. We should guarantee its presense and format
97+ even in the 'simple' path.
98+
99+To apply this storage configuration, the curthooks may need to:
100+
101+ * update /etc/fstab to add the expected mounts entries. The environment
102+ variable ``FSTAB`` contains a path to a file that may be suitable
103+ for use.
104+
105+ * install any packages that are not already installed that are required
106+ to boot with the provided storage config. For example, if the storage
107+ layout includes raid you may need to install the mdadm package.
108+
109+ * update or create an initramfs.
110+
111+
112+System boot
113+-----------
114+In Ubuntu, curtin will run 'grub-setup' and to install grub. This covers
115+putting the bootloader onto the disk(s) that are marked as
116+``grub_device``. The provided hook will need to do the equivalent
117+operation.
118+
119+finalize hook
120+-------------
121+There is one other hook that curtin will invoke in an install, called
122+``finalize``. This program is invoked in the same environment as
123+``curtin-hooks`` above. It is intended to give the OS a final opportunity
124+make updates before reboot. It is called before ``late_commands``.
125
126=== modified file 'doc/topics/networking.rst'
127--- doc/topics/networking.rst 2016-08-18 15:39:15 +0000
128+++ doc/topics/networking.rst 2017-09-29 22:00:32 +0000
129@@ -1,3 +1,5 @@
130+.. _networking:
131+
132 ==========
133 Networking
134 ==========
135
136=== modified file 'doc/topics/overview.rst'
137--- doc/topics/overview.rst 2016-08-18 16:02:27 +0000
138+++ doc/topics/overview.rst 2017-09-29 22:00:32 +0000
139@@ -4,6 +4,8 @@
140
141 Curtin 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.
142
143+.. _Stages:
144+
145 Stages
146 ------
147 A usage of curtin will go through the following stages:
148@@ -22,6 +24,32 @@
149
150 Curtin's assumption is that a fairly rich Linux (Ubuntu) environment is booted.
151
152+.. _Command Environment:
153+
154+Command Environment
155+~~~~~~~~~~~~~~~~~~~
156+Stages and commands invoked by curtin always have the following environment
157+variables defined.
158+
159+- ``WORKING_DIR``: This is for inter-command state. It will be the same
160+ directory for each command run and will only be deleted at the end of the
161+ install. Files referenced in other environment variables will be in
162+ this directory.
163+
164+- ``TARGET_MOUNT_POINT``: The path in the filesystem where the target
165+ filesystem will be mounted.
166+
167+- ``OUTPUT_NETWORK_CONFIG``: After the network discovery stage, this file
168+ should contain networking config information that should then be written
169+ to the target.
170+
171+- ``OUTPUT_FSTAB``: After partitioning and filesystem creation, this file
172+ will contain fstab(5) style content representing mounts.
173+
174+- ``CONFIG``: This variable contains a path to a yaml formatted file with
175+ the fully rendered config.
176+
177+
178 Early Commands
179 ~~~~~~~~~~~~~~
180 Early 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
181@@ -48,32 +76,23 @@
182 10_wipe_filesystems: curtin wipe --quick --all-unused-disks
183 50_setup_raid: curtin disk-setup --all-disks raid0 /
184
185-**Command environment**
186-
187-Partitioning commands have the following environment variables available to them:
188-
189-- ``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.
190-- ``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.
191-- ``TARGET_MOUNT_POINT``:
192-
193-
194-Network Discovery and Setup
195-~~~~~~~~~~~~~~~~~~~~~~~~~~~
196-Networking 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``.
197-
198-Note, 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.
199-
200-**Config Example**::
201-
202- network_commands:
203- 10_netconf: curtin network copy-existing
204-
205-**Command environment**
206-
207-Networking commands have the following environment variables available to them:
208-
209-- ``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.
210-- ``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.
211+
212+Network Discovery
213+~~~~~~~~~~~~~~~~~
214+Networking configuration is *discovered* in the 'network' stage.
215+The default command run at this stage is ``curtin net-meta auto``. After
216+execution, it will write the discovered networking to the file specified
217+in the environment variable ``OUTPUT_NETWORK_CONFIG``. The format of this
218+file is as described in :ref:`networking`.
219+
220+If curtin's config has a network section, the net-meta will simply parrot the
221+data to the output file. If there is no network section, then its default
222+behavior is to copy existing config from the running environment.
223+
224+Note, that as with fstab, this file is not copied verbatim to the target
225+filesystem, but rather made available to the OS customization stage. That
226+stage may just copy the file verbatim, but may also parse it, and apply the
227+settings.
228
229 Extraction of sources
230 ~~~~~~~~~~~~~~~~~~~~~
231@@ -88,27 +107,6 @@
232
233 wget $URL | tar -Sxvzf
234
235-Hook for installed OS to customize itself
236-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237-After extraction of sources, the source that was extracted is then given a chance to customize itself for the system. This customization may include:
238- - ensuring that appropriate device drivers are loaded on first boot
239- - consuming the network interfaces file and applying its declarations.
240- - ensuring that necessary packages
241-
242-**Config Example**::
243-
244- config_hook: {{TARGET_MP}}/opt/curtin/config-hook
245-
246-**Command environment**
247- - ``INTERFACES``: This is a path to the file created during networking stage
248- - ``FSTAB``: This is a path to the file created during partitioning stage
249- - ``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.
250-
251-**Helpers**
252-
253-Curtin provides some helpers to make the OS customization easier.
254- - `curtin in-target`: run the command while chrooted into the target.
255-
256 Final Commands
257 ~~~~~~~~~~~~~~
258
259
260=== modified file 'doc/topics/storage.rst'
261--- doc/topics/storage.rst 2017-04-21 17:36:27 +0000
262+++ doc/topics/storage.rst 2017-09-29 22:00:32 +0000
263@@ -1,3 +1,5 @@
264+.. _storage:
265+
266 =======
267 Storage
268 =======

Subscribers

People subscribed via source and target branches