Commit graph

1395 commits

Author SHA1 Message Date
Christian Kellner
c3dbbc7b4d NEWS: update for osbuild release 29 2021-06-16 21:43:58 +02:00
Christian Kellner
15a18a1b75 stages/sfdisk: don't inform the kernel
Use the `--no-tell-kernel` option to avoid invoking the `ioctl` call to
tell the kernel to reload the partition table. Since we are not using
the kernel to access the partitions this introduces unnecessary i/o and
might also lead to spurious warnings when a partition without dos label
is written, like:
  Re-reading the partition table failed.: Invalid argument
2021-06-14 14:15:20 +01:00
Christian Kellner
98133add11 stages/sfdisk: use device instead of file
Instead of operating directly on a file, which was previously specified
by `filename`, operate on a device. This is more flexible since a file
can be accessed via a loop back device; but the inverse is obviously
not true, like other devices can not be accessed via a plain file.
Therefore, re-factor the stage to use a device and adapt the existing
test (`fedora-ostree-image`).
2021-06-14 14:15:20 +01:00
Christian Kellner
386ff713cc stages/sfdisk: remove unneeded helper functions
This was left over from the old qemu assembler and is not really
needed anymore. Also removes some defaults that are not valid
according to the new schema of the stage.
2021-06-14 14:15:20 +01:00
Tomas Hozza
21fe0375cd stages/logind: add new stage for configuring systemd-logind
Add new stage `org.osbuild.systemd-logind` allowing to create
systemd-logind configuration drop-ins in `/usr/lib/systemd/logind.conf.d`.
Currently only the `NAutoVTs` option in the `Login` section can be
configured.

The schema mandates that:
 - There must be at least one configuration file defined.
 - The 'Login' section is required, as it is the only one in the
   systemd-logind configuration.
 - At least one option must be configured in the 'Login' section.

Add test for the new stage.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-14 08:50:51 +02:00
Tomas Hozza
89775fefb8 stages/modprobe: add new stage for configuring modprobe
Add new stage `org.osbuild.modprobe` allowing to create modprobe
configuration files in `/usr/lib/modprobe.d`. Currently only the
`blacklist` command can be used in the configuration files.

The schema mandates, that at least one configuration file must be
defined.

Add test for the new stage.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-14 08:50:25 +02:00
Christian Kellner
ce53fa0bbf stages/qemu: honour coroutines env variable
The `OSBUILD_QEMU_IMG_COROUTINES` was introduced to allow specifying
the number of coroutines used in `qemu-img convert` by the runner,
or osbuild directly. This can be useful in various scenarios, but
is specifically used by the rhel 8.2+ runner to limit the number of
coroutines used for Aarch64 to one, since a bug in `qemu-img` leads
to random hangs on that platform.
2021-06-13 18:21:16 +02:00
Christian Kellner
c9b74b4022 test/osbuild: fix type in assembler
It is `assembler` not `assmelber`. Ups.
2021-06-11 16:55:45 +02:00
Tomas Hozza
b5ef8066e5 stages: extend org.osbuild.sysconfig to create network-scripts/ifcfg-* files
Extend the `org.osbuild.sysconfig` stage to create `ifcfg-*` files
under `network-scripts` subdirectory. It is possible to set only values
currently set in RHEL AMI images, specifically:
 - BOOTPROTO
 - DEVICE
 - IPV6INIT
 - ONBOOT
 - PEERDNS
 - TYPE
 - USERCTL

Change all `configure_*` functions to raise ValueError exception,
instead of returning values. As a follow up change, remove all checks of
the returned value from these functions.

Update the `org.osbuild.sysconfig` stage test case to create ifcfg
configuration files for two interfaces.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-10 16:10:53 +02:00
Tomas Hozza
1fef6e76fb stages: extend org.osbuild.systemd to create .service unit drop-ins
Extend the `org.osbuild.systemd` stage to create drop-in configuration
files for Systemd `.service` units under `/usr/lib/systemd/system`.
Currently only the `Environment` option in the `Service` section can be
configured.

Update the `org.osbuild.systemd` stage test case to create drop-in
configuration `10-rh-enable-for-ec2.conf` for `nm-cloud-setup.service`
unit, as used in RHEL AMI images.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-10 13:52:00 +02:00
Ondřej Budai
7765c53ecc mockbuild: use s3cmd put instead of sync to speed up the RPM upload
s3cmd sync actually downloads metadata for all objects in a s3 bucket.
We have built a lot of RPMs, thus this takes 5 minutes on AWS and 25 minutes
on my laptop (!!!).

Let's use recursive put instead. This doesn't delete any files on the remote
side. As we upload RPMs only once, this also shouldn't fail on "the
object already exists". Using this method, we should be able to upload the
RPMs in seconds.

The same patch was applied in osbuild-composer cf73edd2
2021-06-10 09:35:04 +01:00
Tomas Hozza
73420b4f27 stages: extend org.osbuild.rhsm stage to configure subscription-manager
Extend the `org.osbuild.rhsm` stage to configure selected options in the
subscription-manager configuration (in `/etc/rhsm/rhsm.conf`). It is
possible to set only values currently set in RHEL AMI images,
specifically:
 - `manage_repos` option in `rhsm` section
 - `auto_registration` option in `rhsmcertd` section

Ensure that the stage does not "touch" any configuration files, unless
it actually changes them. This prevents changing the file modification
time.

Update the `org.osbuild.rhsm` stage test case to set the additional
configuration options.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-10 10:32:50 +02:00
Christian Kellner
d62c8294e1 stages/groups: fix group name schema validation
Use `patternProperties` instead of `propertyNames` and `pattern`,
which is not in draft 4 and so did not work (but also did not
throw an error).
2021-06-09 20:33:27 +02:00
Christian Kellner
690a8fc42a stages/users: fix user names schema validation
Use `patternProperties` instead of `propertyNames` and `pattern`,
which is not in draft 4 and so did not work (but also did not
throw an error).

Co-Developed-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-06-09 20:33:27 +02:00
Christian Kellner
97ff9eb780 test/ostree: build the ostree raw image
Build the newly included fedora ostree image artifact. This should
test the new devices and mounts.
2021-06-09 18:37:47 +01:00
Christian Kellner
8a7596c691 test/data: add fedora ostree image manifest
Add a new manifest that creates an ostree commit, deploys that,
creates a raw image and copies the deployment into it. The
resulting artefact is a bootlabel qcow2 image.
2021-06-09 18:37:47 +01:00
Christian Kellner
8dde9d9590 mounts/btrfs: mount support for btrfs
Host service to mount a btrfs at the given location.
2021-06-09 18:37:47 +01:00
Christian Kellner
7ecf592f5b mounts/ext4: mount support for ext4 file systems
Host service to mount an ext4 file system.
2021-06-09 18:37:47 +01:00
Christian Kellner
977eea6657 stages/mkfs.btrfs: new stage to create a btrfs
Stage to construct an btrfs on a specified device.
2021-06-09 18:37:47 +01:00
Christian Kellner
5dac944503 stages/mkfs.ext4: new stage to create an ext4 fs
Stage to construct an ext4 file system on a specified device.
2021-06-09 18:37:47 +01:00
Christian Kellner
9c2d0744a9 stages/ostree: fix stage to work with inputs
The stage was converted to use inputs, but its schema was not, which
means that although the stage requires inputs, they could not be
specified. Doh. Change the expected input to `commit`.
NB: This stage should be broken up, so *SHOULD NOT* be used in newly
created pipelines.
Fix a small whitespace change as well.
2021-06-09 18:37:47 +01:00
Christian Kellner
3735f090e7 stages: add qemu stage
Based on that part of the qemu assembler that converts the raw image
into different virtualization formats, like qcow2 and such. Supports
all the formats the old qemu assembler also supported.
2021-06-09 18:37:47 +01:00
Christian Kellner
f4a8770e58 inputs/files: support for pipeline origins
Currently the `org.osbuild.files` input only supports the source origin.
Extend support to mapping files from pipelines, using the recently added
sub-tree reading capability of `ObjectStore.reat_at`. Restructure the
JSON schema to keep is as readable as possible.
2021-06-09 18:37:47 +01:00
Christian Kellner
496d21de54 objectstore: sub-tree support for read_at
Add the ability to only read a sub-tree of a tree via `Object.read_at`.
Expose the functionality via the `Store{Server,Client}.read_tree_at`.
Extend the tests to check this new functionality.
2021-06-09 18:37:47 +01:00
Christian Kellner
659c139ed1 inputs/files: extract source options schema
This is mostly to prepare the support for pipeline options will be
different for pipeline origins than source origins.
2021-06-09 18:37:47 +01:00
Christian Kellner
e92b24229d inputs/files: extract origin definition
This is mostly to prepare the support for pipeline origins where
this node will get reused in more than one place.
2021-06-09 18:37:47 +01:00
Christian Kellner
a2c926654c inputs/files: rename refs to files
The `org.osbuild.files` input provides individual files to a stage.
Change the `refs` key in the returned dict to `files` to better
reflect that fact. Also adapt the documentation to indicate that
the keys actually paths and not necessarily checksums. This prepares
for future extension of the `files` input to pipeline origins.
2021-06-09 18:37:47 +01:00
Christian Kellner
a3ea8dc748 inputs/files: use os.link instead of ln binary 2021-06-09 18:37:47 +01:00
Christian Kellner
78ce4c2700 stages: add zip.inst stage
This is the stage that will actually install the Z initial program
loader, i.e. the boot loader for s390x.
2021-06-09 18:37:47 +01:00
Christian Kellner
54a5aec0a6 stages: add org.osbuild.grub2.inst
This stage is the part of the qemu assembler that generates and
installs the grub2 core image on non-uefi or hybrid systems,
like x86 legacy and PPC64LE (Open Firmware).
2021-06-09 18:37:47 +01:00
Christian Kellner
17124473be stages: add copy stage
This sage can be used to copy items, such as files or trees, from one
location to another. The only supported location for reading currently
is currently `input`. Supported locations for writing are `mount` and
`tree`.
2021-06-09 18:37:47 +01:00
Christian Kellner
546949fd00 mounts: add org.osbuild.fat
Mount host service for (v)fat filesystems.
2021-06-09 18:37:47 +01:00
Christian Kellner
ddb7aa4431 mounts: add org.osbuild.xfs
Mount host service for xfs filesystems.
2021-06-09 18:37:47 +01:00
Christian Kellner
367a044453 osbuild: introduce mount host service
Allows stages to access file systems provided by devices.
This makes mount handling transparent to the stages, i.e.
the individual stages do not need any code for different
file system types and the underlying devices.
2021-06-09 18:37:47 +01:00
Christian Kellner
92f936e15c stages: add mkfs.fat stage 2021-06-09 18:37:47 +01:00
Christian Kellner
819a094bc1 stages: add mkfs.xfs stage 2021-06-09 18:37:47 +01:00
Christian Kellner
f93dd9c397 stages: add sfdisk stage 2021-06-09 18:37:47 +01:00
Christian Kellner
0b330947cc stages: add truncate stage
Add a new stage that can be used to create, shrink or extend a file.
2021-06-09 18:37:47 +01:00
Christian Kellner
3085114ed7 devices: add support for loopback devices
Device service that provides support for bind files within the tree
to loopback devices. Valid parameters are the `filename`, `offset`
and `size`. This controls what part of the file to bind to the loop
device. The unit for `size` and `offset` is sectors and the sector
size can be configured via the `sector-size` parameter. The reason
behind the sector unit is so that numbers can easily be compared
with those specified in the partition table.
2021-06-09 18:37:47 +01:00
Christian Kellner
4f211eb0a5 osbuild: introduce device host service
A new host service that provides device functionality to stages.
Since stages run in a container and are restricted from creating
device nodes, all device handling is done in the main osbuild
process. Currently this is done with the help of APIs and RPC,
e.g. `LoopServer`. Device host services on the other hand allow
declaring devices in the manifest itself and then osbuild will
prepare all devices before running the stage. One desired effect
is that it makes device handling transparent to the stages, e.g.
they don't have to know about loopback devices, LVM or LUKS.
Another result is that specific device handling is now modular
like Inputs and Source are and thus moved out of osbuild itself.
2021-06-09 18:37:47 +01:00
Christian Kellner
26b15a062d format/v2: generalize stage module validation
Generalize the code that validates the stage `inputs`, so it can
be used for future extensions of the stage with new sub-modules.
2021-06-09 18:37:47 +01:00
Christian Kellner
1ed85dc790 inputs: convert to host service
Create a `InputService` class with an abstract method called `map`,
meant to be implemented by all inputs. An `unmap` method may be
optionally overridden by inputs to cleanup resources.
Instantiate a `host.ServiceManager` in the `Stage.run` section and
pass the to the host side input code so it can be used to spawn the
input services.
Convert all existing inputs to the new service framework.
2021-06-09 18:37:47 +01:00
Christian Kellner
08bc9ab7d8 inputs: pre-defined input paths
Instead of bind-mounting each individual input into the container,
create a temporary directory that is used by all inputs and bind-
mount this to the well known location ("/run/osbuild/inputs"). The
temporary directory is then passed to the input so that it can
make the requested resources available relative to that directory.
This is enforced by the common input handling code.
Additionally, pass the well known input path via a new "paths" key
to the arguments dictionary passed to the stage.
2021-06-09 18:37:47 +01:00
Christian Kellner
47fefe7e2d schema/v2: restrict input names
Ensure that input names start with a character and otherwise only
contain characters, numbers, `-`, `_` and `.`. Limit their length
to 255.
2021-06-09 18:37:47 +01:00
Christian Kellner
ef5e9364bb inputs: make inputs aware of their names
The name of the input here refers to its id within the manifest. This
is unique per stage and thus identifies a input for a given stage.
2021-06-09 18:37:47 +01:00
Christian Kellner
8c1a0a2eeb inputs: remove info.name proxy property
This helper property is misleading since it is not the name of the
input in the context of the manifest, but actually "type". Name is
a left-over from the nomenclature of format v1, where the type of
stages and inputs was called `name`.
2021-06-09 18:37:47 +01:00
Christian Kellner
463e67d61c api: root relative paths for stage arguments
Resolve relative paths for items the `api.arguments` call: Since paths
are different on the host and in the container, they can be transmitted
relative. Resolve the items for all groups that have paths registered.
2021-06-09 18:37:47 +01:00
Christian Kellner
3377f6c288 test/objectstore: add store server test
Include basic checks for the store server and client.
2021-06-09 18:37:47 +01:00
Christian Kellner
1743eceb41 objectstore: runtime exceptions for mount errors
Instead if using `check=True` for `subprocess.run`, which turns
a process failure (i.e. non-zero return codes) into generic a
`CalledProcessError` exception, use `check=False` and explicitly
handle mount errors, translating them into a `RuntimeError` with
a better error message.
2021-06-09 18:37:47 +01:00
Christian Kellner
f8428e56e2 objectstore: add Object.read_at method
Implement a new `read_at` method that will bind mount the tree of the
object to a specified location, instead of a temporary directory as
it done in the `read` method. Implement the latter via `read_at`.
Implement the corresponding methods for `Store{Client,Server}`. Since
the `ObjectStore.read_at` method will fail if the target directory
does not exist (or is of the wrong type), catch any exceptions in
the `StoreServer` and send those to the `StoreClient` via an `error`
entry.
This one is for David: also fix a missing blank line.
2021-06-09 18:37:47 +01:00