You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Major refactoring of the scripts, reducing dependencies on third parties.
6
+
The build tools mainly rely on [`qemu-kvm`](http://www.qemu.org/), using [`libvirt`](https://libvirt.org/) and [`libguestfs`](https://libguestfs.org/).
7
+
8
+
As it is a breaking change, previous version has been archived under the `olit-legacy` branch (unmaintained).
9
+
10
+
### Refactor
11
+
12
+
The overall build process has been changed. In previous releases we had:
13
+
14
+
1. Create image from distribution ISO and a kickstart file
15
+
1. Customize the image by running provision scripts inside the running VM
16
+
1. Cleanup the environment by mounting the image filesystems on the host;
17
+
the outcome is a raw disk image
18
+
1. Package the image for the target cloud
19
+
20
+
As of this release, we have:
21
+
22
+
1. Create image: unchanged
23
+
1. Use [`virt-customize`](customize) to run the provisioning scripts
24
+
1. Use [`virt-sysprep`](https://libguestfs.org/virt-sysprep.1.html)/[`virt-sparsify`](https://libguestfs.org/virt-sparsify.1.html) for the cleanup;
25
+
the outcome is a compressed qcow2 image
26
+
1. Package image: unchanged
27
+
28
+
Notable code changes:
29
+
30
+
- Drop support for [VirtualBox](https://www.virtualbox.org/) as **builder** (you can still create Vagrant VirtualBox **images**)
31
+
-`image-scripts.sh``::seal()` functions obsolete; code moved to `provision.sh``::cleanup()` functions.
32
+
We don't need anymore a separate _offline_ cleanup as `virt-customize` doesn't actually run the built VM.
33
+
- Simplify `provision.sh``::cleanup()` functions as most parts are now handled by `virt-sysprep` operations.
34
+
- Add `image-scripts.sh``::customize_args()` and `::sysprep_args()` hooks to inject command line parameters for `virt-customize` and `virt-sysprep`.
35
+
- Root privileges are no longer required on the build host.
36
+
- Root access to the image VM is no longer needed at built time. Root password and/or ssh public key can still be set for the image; parameters have been renamed to ensure configuration is secure by default.
37
+
- Move common code to the `common.sh` and `provision-common.sh` libraries.
38
+
- QCOW2 image files now have the `qcow2` extension instead of `qcow`.
39
+
40
+
### Configuration variables
41
+
42
+
Changes to the configuration variables.
43
+
See the corresponding `env.properties` files for more details.
44
+
45
+
New variables
46
+
47
+
- Generic
48
+
-`INSTALL_WAIT_TIME`: configurable timeout for initial image creation
49
+
-`OS_VARIANT` (optional): OS variant used when creating the image
50
+
-`BOOT_MODE`: OS boot mode (`bios` or `efi`)
51
+
-`BOOT_COMMAND_SERIAL_CONSOLE`: kernel parameters to enable serial console
52
+
-`BOOT_LOCATION`(optional): kernel and initrd location on the distribution media
53
+
-`ROOT_PASSWORD` (optional, default: locked): password for the root account in the generated image
54
+
-`ROOT_SSH_KEY` (optional): public ssh key the root account in the generated image
55
+
-`PERMIT_ROOT_LOGIN` (Default: prohibit-password): default policy for ssh root login
56
+
-`CACHE_DIR` (Default: `.cache` in workspace directory): location of ISO images cache
57
+
- utm cloud
58
+
-`OPC_PASSWORD`: password for the `opc` user for UTM builds
59
+
60
+
Changed variables
61
+
62
+
-`DISTR`: is now mandatory
63
+
-`ISO_LABEL`: is now optional
64
+
-`BOOT_COMMAND`: array of kernel parameters instead of a string
65
+
66
+
Obsolete variables
67
+
68
+
-`LOCK_ROOT`, `SSH_KEY_FILE`, `SSH_PASSWORD`: root access to the image is not needed anymore, see new `ROOT_PASSWORD`, `ROOT_SSH_KEY` if root access to the generated image is needed
Copy file name to clipboardExpand all lines: oracle-linux-image-tools/README.md
+78-73Lines changed: 78 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,87 +4,101 @@
4
4
5
5
This repository provides tools to build Oracle Linux images for cloud deployment.
6
6
7
-
The images built by these tools are based on distribution flavours and target packages.
8
-
Image building is accomplished using Packer to build images from the Oracle Linux ISO using Oracle VM VirtualBox or QEMU/KVM builders.
7
+
__Note__: as of March 2024 the scripts have been refactored and introduce breaking changes. See [CHANGELOG](CHANGELOG.md) for details.
9
8
10
-
The tool currently supports:
9
+
The tools are architected around _distribution flavours_ and _target clouds_.
10
+
They currently support:
11
11
12
12
- Distributions:
13
-
- Oracle Linux 7 update 9 -- Slim (x86_64)
14
-
- Oracle Linux 8 update 9 -- Slim (x86_64 and aarch64)
15
-
__Note__: for aarch64, only Generic, OCI and UTM clouds are supported
16
-
- Oracle Linux 9 update 3 -- Slim (x86_64 and aarch64)
17
-
__Note__: for aarch64, only Generic, OCI and UTM clouds are supported
13
+
- Oracle Linux 7 update 9 -- Slim (x86_64 only)
14
+
- Oracle Linux 8 update 9 -- Slim (x86_64 and aarch64)
15
+
- Oracle Linux 9 update 3 -- Slim (x86_64 and aarch64)
18
16
- Clouds:
19
-
- Microsoft Azure cloud
17
+
- Microsoft Azure cloud (x86_64)
20
18
Target packages: WALinuxAgent
21
19
Image format: VHD
22
-
- Oracle Cloud Infrastructure (OCI)
20
+
- Oracle Cloud Infrastructure (OCI) (x86_64 and aarch64)
23
21
Target packages: qemu-guest-agent / cloud-init
24
22
Image format: QCOW2
25
23
__Note__: no specific OCI tools are actually installed; this image can be used in any cloud-init based environment.
26
-
- Oracle Linux Virtualization Manager (OLVM)
24
+
- Oracle Linux Virtualization Manager (OLVM) (x86_64)
27
25
Target packages: qemu-guest-agent / cloud-init
28
26
Image format: OLVM OVA
29
-
- Oracle VM Server (OVM)
27
+
- Oracle VM Server (OVM) (x86_64)
30
28
Target packages: oracle-template-config + vmapi
31
29
Image format: OVM OVA
32
-
- Vagrant (VirtualBox provider - requires VirtualBox for the build)
30
+
- Vagrant (VirtualBox provider) (x86_64)
33
31
Target packages: VirtualBox guest additions
34
32
Image format: box
35
-
- Vagrant (libvirt provider)
33
+
- Vagrant (libvirt provider) (x86_64)
36
34
Target packages: nfs-utils
37
35
Image format: box
38
-
- UTM ([UTM for macOS](https://mac.getutm.app/))
36
+
- UTM ([UTM for macOS](https://mac.getutm.app/)) (aarch64)
39
37
Target packages: none
40
38
Image format: utm
41
39
__Note__: only for aarch64 distributions
42
-
- Generic (No cloud setup)
40
+
- Generic (No cloud setup) (x86_64 and aarch64)
43
41
Target packages: none
44
42
Image format: VirtualBox OVA or QCOW2 (depending on the builder used)
45
43
46
-
Additional information is available in the [Building (Small) Oracle Linux Images For The Cloud](https://blogs.oracle.com/linux/post/building-small-oracle-linux-images-for-the-cloud) blog post.
44
+
## Requirements
45
+
46
+
### Overview
47
+
48
+
The tools require a Linux host supporting [KVM](https://linux-kvm.org) virtualization with the following installed:
- the host architecture must match the architecture of the target image (e.g.: an `aarch64` host is needed to build `aarch64` images)
58
+
- the host kernel must support the filesystem used in the guest (e.g.: the host kernel must support `btrfs` to build an image with a `btrfs` filesystem)
59
+
60
+
For building [HashiCorp Vagrant](https://vagrantup.com/) boxes for the libvirt provider, download the [`create_box.sh`](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/tools/create_box.sh) third party script from the [`vagrant-libvirt`](https://github.com/vagrant-libvirt/vagrant-libvirt) project or install [Vagrant](https://vagrantup.com/) and the [`vagrant-libvirt`](https://github.com/vagrant-libvirt/vagrant-libvirt) plugin.
- Oracle Linux 8: Download and install Packer from [HashiCorp](https://www.packer.io/downloads/)
70
-
1. Cloud specific requirements:
71
-
- For `Vagrant` box (VirtualBox provider), install [HashiCorp Vagrant](https://vagrantup.com/)
72
-
- For `Vagrant` box (libvirt provider), download the [`create_box.sh`](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/tools/create_box.sh) third party script from the [`vagrant-libvirt`](https://github.com/vagrant-libvirt/vagrant-libvirt) project or install [HashiCorp Vagrant](https://vagrantup.com/) and the [`vagrant-libvirt`](https://github.com/vagrant-libvirt/vagrant-libvirt) plugin
1. Set up a separate workspace directory where the image will be built.
78
89
Ensure there is enough free space in the workspace partition, the builder will need up the two times the image size.
79
90
1. Configure your build environment in the `env.properties` file (or in a copy).
80
91
Minimal configuration:
81
92
- `WORKSPACE`: path of your workspace directory
82
93
- `ISO_URL`: location of the Oracle Linux distribution ISO
83
-
- `ISO_CHECKSUM`: checksum for the ISO file. As from packer 1.6.0, you can prepend the checksum type (see [packer documentation](https://www.packer.io/docs/builders/virtualbox/iso#iso_checksum))
84
-
- `CLOUD`: cloud target (azure, oci, olvm, ovm or none)
85
-
- `PACKER_BUILDER`: builder used by packer (virtualbox-iso.x86-64 or qemu.x86-64)
86
-
1. Run the builder:
87
-
`./bin/build-image.sh --env ENV_PROPERTY_FILE`
94
+
- `ISO_CHECKSUM`: checksum for the ISO file
95
+
Checksums files are available on the [Verify Oracle Linux Downloads](https://linux.oracle.com/security/gpg/) page
@@ -171,7 +187,7 @@ For cloud-init support, you will need to specify `CLOUD_INIT="Yes"` in your `env
171
187
172
188
The `build-image` script relies on the following directory structure:
173
189
174
-
- distr: directory for all Oracle Linux distribution
190
+
- distr: directory for all Oracle Linux distributions
175
191
- _distribution name_
176
192
- env.properties: distribution parameters
177
193
- _name_-ks.cfg: kickstart file for the distribution
@@ -203,13 +219,11 @@ The builder will process the directories in the following order:
203
219
- distr::kickstart
204
220
- cloud_distr::kickstart
205
221
- custom::kickstart
206
-
1. Select a packer configuration file and customise it. The following hooks are called if defined:
207
-
- distr::packer_conf
208
-
- cloud_distr::packer_conf
209
-
- custom::packer_conf
210
-
1. Stage files from the _files_ directories. These files are copied during provisioning in `/tmp/packer_files` in the VM.
211
-
1. Run packer to provision the VM image.
212
-
During provisioning the `provision.sh` scripts run in the following order:
222
+
1. Stage files from the _files_ directories. These files are copied during provisioning in`PROVISION_DIR`in the VM.
223
+
1. Run `virt-install` to create the image as described in the kickstart file.
224
+
1. Run `virt-customize` to actually provision the image.
225
+
The optional `::customize_args` hooks in the `image_scripts.sh` files are invoked to provide additional arguments to `virt-customize`.
226
+
The `provision.sh` scripts run in the following order:
213
227
- distr::provision
214
228
- cloud::provision
215
229
- cloud_distr::provision
@@ -218,23 +232,14 @@ The builder will process the directories in the following order:
218
232
- cloud_distr::cleanup
219
233
- cloud::cleanup
220
234
- distr::cleanup
221
-
- distr::seal[^1]
222
-
1. Image cleanup: the generated image is mounted on the host and the `image-scripts` scripts are run[^1]:
223
-
- custom::cleanup
224
-
- cloud_distr::cleanup
225
-
- cloud::cleanup
226
-
- distr::cleanup
235
+
1. Run `virt-sysprep` to _seal_ the image (final cleanup).
236
+
The optional `::sysprep_args` hooks in the `image_scripts.sh` files are invoked to provide additional arguments to `virt-sysprep`.
227
237
1. Image packaging: the generated image is packaged in its final format.
228
238
Only the first script found is executed:
229
239
- custom::image_package
230
240
- cloud_distr::image_package
231
241
- cloud::image_package
232
242
233
-
[^1]: `provision``seal` vs. `image-scripts``cleanup`.
234
-
These functions have the same purpose: _seal_ the image before packaging.
235
-
The difference is that the former runs in the VM while the latter runs on the host.
236
-
Sealing on the host might be more efficient, but when it is not possible to mount the image disk on the host, in-VM sealing can be used. When no `image-scripts``cleanup` are defined, no attempt will be made to mount the filesystem on the host.
237
-
238
243
## Feedback
239
244
240
245
Please provide feedback of any kind via GitHub issues on this repository.
0 commit comments