Commit graph

487 commits

Author SHA1 Message Date
Tomas Hozza
0df902d6bb sshd.config stage: support PermitRootLogin option
Add support for `PermitRootLogin` option in the
`org.osbuild.sshd.config` stage.

I kept the "yes" and "no" values for consistency with other stage
options. While it will make the implementation in osbuild-composer
harder, it won't be impossible as we already have a precedence for doing
it this way (e.g. in the `org.osbuild.pam.limits.conf`).

Modify the stage unit tests to check the new option.

Remove the empty `org.osbuild.sshd.config` stage from `a.mpp.json`
since it does not add any value and it actually made the `tree-diff`
tool provide a weird tree diff results.

Fix #910

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-07 15:20:50 +00:00
Christian Kellner
3958a6140c test/buildroot: test timeout at the run level
Check the timeout functionality at the `Buildroot.run` level not at
the `read_with_timeout` level, which is an implementation detail.
2021-12-07 09:47:01 +00:00
Christian Kellner
2129f3d68b test/osbuild: add order check for on_demand
Add a check that ensures the order of inputs to `depsolve` is
preserved in the result.
2021-12-03 17:09:33 +00:00
AaronH88
99c739fd60 test: test buildroot read_with_timeout function
- Added a new stage that is stuck in an infinite loop
- Added two tests that use this stage and force a timeout
2021-12-03 14:29:36 +00:00
Christian Kellner
29f2a68eeb osbuild: on-demand building of pipelines
Use the new Manifest.depsolve function to only build the pipelines that
were explicitly requested and their dependencies, taking into account
what is already present in the store.
Since now not all pipeline will be built, there wont be a result entry
for all the pipelines, thus the format version 2 result formatting was
changed to not require the pipeline to be present in result set.
2021-12-02 12:51:30 +00:00
Christian Kellner
749912c75a manifest: implement pipeline depsolving
New function that take a list of pipelines and return the list of
pipelines that need to be build, i.e. the pipelines and all their
dependencies that are not already present in the store.
Add corresponding test.
2021-12-02 12:51:30 +00:00
Christian Kellner
8770bdf10a formats/v1: remove implicit assembler export
When building a version 1 manifest, the assembler would always be
exported, even when not requested via the `--export` command line
option. This was done for backwards compatibility so to not break
tools relying on that behavior. The problem is that support for
this uses a completely different code path and might also now be
confusing behavior. Thus remove the implicit and really only ever
export what was explicitly requested by the caller.
2021-12-02 12:51:30 +00:00
Christian Kellner
80414299cd test/stages: export tree and compare that
Instead of checkpointing the tree and then accessing the generated
tree inside the store via the `map_object` function we not just
export the tree and use that. This better hides the internals of
the store and also allows us to activate on-demand building that
does not rely on checkpoints being implicitly built like exports.
2021-12-02 12:51:30 +00:00
Christian Kellner
d502157d7e test/stages: ensure we always have a tree
Ensure that all our stage tests always have at least one stage,
even it is just a `noop` stage, so that we can checkpoint and
export the `tree`.
2021-12-02 12:51:30 +00:00
Christian Kellner
7ae4a7e785 test: use and require explicit exports
Require all the tests that compile a manifest to either specify
checkpoints or exports. Convert all the tests that were relying
on implicit exports with v1 manifests to use explicit exports.
2021-12-02 12:51:30 +00:00
Christian Kellner
36356342b0 buildroot: mask /proc/cmdline
Since we bind `/proc` inside the container, we leak certain information
that comes with it. One of this is the kernel command line. None of the
decisions done by software running inside the container should depend
on the kernel command line on the host, so overwrite the kernel command
line by creating a temporary directory and mapping it inside the build-
root. For now we default to a simple `root=/dev/osbuild` fake kernel
command line.
Add a simple check for it as well.
2021-11-30 12:01:13 +01:00
Christian Kellner
4c54f7e4a6 test/buildroot: convert to pytest
Semantics should be unchanged.
2021-11-30 12:01:13 +01:00
Christian Kellner
03232f1899 test/stages: basic gunzip stage test
Add a simple check for the new `org.osbuild.gunzip` stage.
2021-11-19 00:16:04 +00:00
Christian Kellner
ac529563c3 test: use new mpp-embed in tests
This is to showcase it as much as to test its functionality. For this
the tar and xz stage tests have been converted. NB: only the mpp file
for each test is changed but the corresponding manifest is not.
The `sources/org.osbuild.inline` section has been kept otherwise the
ordering in the result manifest would change.
2021-11-18 13:41:06 +01:00
Christian Kellner
280aca8f07 test/lvm2: use LoopControl.loop_for_fd
Instead of having custom code that basically duplicates the
functionality of `LoopControl.loop_for_fd` use that instead.
Additionally, the version used in the test had a bug where
it did not re-create the Loop device in the main loop when
it was close due to an error, leading errors in subsequent
usages of the device that would often manifest in CI runs:
  fcntl.ioctl(self.fd, self.LOOP_SET_FD, fd)
  ValueError: file descriptor cannot be a negative integer (-1)
2021-11-12 17:40:00 +01:00
Tom Gundersen
f7bf23faba stages/authconfig: run authconfig
This applies the default authconfig settings to the tree.

Note that the `/backups` directory is removed. The tool creaset
this, and by default it should not exist, so this should be a
noop. However, if you run this on a tree with existing backups,
they would be lost.
2021-11-08 20:43:51 +01:00
Ondřej Budai
306fd3ed96 stages/yum.config: add an option to configure langpacks plugin
The new stage enables users to configure the langpacks plugin of YUM.
Currently, only locales option is supported.
2021-11-08 17:17:02 +01:00
Tom Gundersen
9da89de8b5 stages/pwquality.conf: set pwquality configuration
This allows the password policy to be configured.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-11-05 16:53:54 +01:00
Tomas Hozza
58ec1c9a83 Add new org.osbuild.yum.config stage
Add a new stage for modifying YUM global configuration.

Add a unit test case for the newly added stage.

Because we test stages on Fedora, where there is no YUM, and this stage
is mostly intended for being used with RHEL-7 images, the stage does not
produce error in case the `/etc/yum.conf` file does not exist. It rather
produces a warning and creates the file. Ideally the stage would produce
an error in case the configuration file does not exist, but that would
be impossible to test on recent Fedora.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-05 12:10:33 +01:00
Achilleas Koutsou
66a1fbad9d test/cloud-init: add new options to stage test 2021-11-05 12:08:38 +01:00
Christian Kellner
12eb14378a stages: add new org.osbuild.cron.script stage
New stage to schedule a script via a /etc/cron.{hourly, daily ...}.
Currently only a simple command that will be put into an generated
script with the given name. Later more options might be added.
2021-11-05 11:53:11 +01:00
Ondřej Budai
266c3d1953 stages/grub2: add support for terminal, serial and timeout config
This commit adds options to the org.osbuild.grub2 stage to configure
terminal input and output, serial console and timeout.

The functionality and configuration schema is the same as in the legacy
grub2 stage.
2021-11-04 17:35:24 +01:00
Tom Gundersen
36176ab377 stages/waagent.conf: set WALinuxAgent configuration
This is requried to comply with Azure marketplace best
practices. The WALinuxAgent should not handle formating or
swap, as that is done by cloud-init.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-11-03 18:32:40 +01:00
Tom Gundersen
304f1e3f9f stages/sshd.config: set sshd configuration
This is required for images to be importable to the AWS
marketplace. Both PasswordAuthentication and
ChallengeResponseAuthentication must be disabled.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-11-03 18:32:40 +01:00
Tomas Hozza
daacf002fe Support 'install' command in org.osbuild.modprobe stage
Add support for new 'install' command in the org.osbuild.modprobe stage.

Extend the unit test coverage to test the new command.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-03 16:11:54 +00:00
Christian Kellner
bd4ab1d36f stages/lvm2.create: fix 'size' and add 'extents'
The `size` option was using `-l`, which in fact was `--extents`.
Fix that to use `--size` and add a new option `extents` that
will in fact call translate to `--extents` and this replace the
current use of the `size` option.
Adapt the `fedora-ostree-image` test manifest to use `extents`.
2021-11-03 15:09:35 +00:00
Christian Kellner
5828da8d62 test/data: use ostree.deployment in fedora image 2021-10-30 15:32:44 +01:00
Christian Kellner
a5e07cf506 devices: introduce new device manager class
Introduce a new class to manage devices, `DeviceManger` and move the
code to open devices from the `Device` here. The main insight of why
the logic should be place here is that certain information is needed
to open the devices, independently of specific type: the path to the
device node directory, `devpath`, the actual `tree` and the service
manager instance to start the actual service. Instead of passing all
this information again and again to the `Device` class, we now have
a specialized (service) manager class for devices that has all the
needed information all the time. Additionally, the special handling
of parent devices is moved from the pipeline to the service manager,
which is where it belongs.
This will make even more sense for mounts, where the `DeviceManger`
can then be passed to access the individual devices.
Port the test to use the `DeviceManager`.
2021-10-30 15:32:44 +01:00
Christian Kellner
94d8fb1ff7 test/data: add RHEL 7 manifests
Add RHEL 7.9 example manifests. Add them to a `rhel` sub-directory in
the test/data/manifests directory since we cannot re-generate them
in the normal github actions, because they require access to RHEL
content.
2021-10-30 00:54:09 +01:00
Christian Kellner
074741cc27 test/stages: add check for parted stage
Include a new test that writes a partition table to a disk and
then reads it back via `sfdisk` compares it against an layout
that was generated.
NB: This test needs `sfdisk` with `--json` support on the use host.
2021-10-30 00:54:09 +01:00
Christian Kellner
662fe0feb9 test/host: checks for invalid fd handling
Check that we properly handle `dispatch` returning invalid fds and
that all fds are properly closed.
2021-09-24 12:14:04 +01:00
Christian Kellner
fe3bb30f4c test/host: add check for call with fds
Create a new test that checks method calls that pass file
descriptors in both directions.
2021-09-24 08:27:19 +01:00
Christian Kellner
c902a7a754 sources: port to host services
Port sources to also use the host services infrastructure that is
used by inputs, devices and mounts. Sources are a bit different
from the other services that they don't run for the duration of
the stage but are run before anything is built. By using the same
infrastructure we re-use the process management and inter process
communcation. Additionally, this will forward all messages from
sources to the existing monitoring framework.
Adapt all existing sources and tests.
2021-09-22 00:00:20 +02:00
Christian Kellner
99dd623383 stages: pam_limits.conf → pam.limits.conf
Mostly my personal preference, but we do not have any stage
with an underscore in the name, so let not start now.
2021-09-14 15:31:12 +02:00
Tomas Hozza
46ff53d5f4 Add a new stage for configuring pam_limits module
Add a new stage `org.osbuild.pam_limits.conf`, which created
configuration files for `pam_limits` module in /etc/security/limits.d.

Add unit test for the new stage.

Fix #788

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-09-09 15:00:30 +02:00
Christian Kellner
7ec305a343 ostree.config: add bootloader config option
Ability to set the bootloader backend that OSTree should use. NB:
normally this should be set to `none` since in modern distros and
bootloaders the BLS is used and the BLS snippets are generated on
`none` but none of the of the specific bootloader tools are run,
like `grub2-mkconfig` for grub.

Update the fedora image manifest to use that config setting.
2021-09-09 12:29:54 +02:00
Tomas Hozza
187681f17d Add a new stage for setting kernel parameters via sysctl.d
Add a new stage `org.osbuild.sysctld` for setting kernel parameters at
boot by creating a configuration file in /usr/lib/sysctl.d. At least
one parameter must be specified for the stage.

Add unit test for the new stage.

Fix #790

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-09-09 11:16:11 +02:00
Tomas Hozza
cf8f851f9c Add a new stage org.osbuild.tmpfilesd for configuring tmpfiles.d
Add a new stage `org.osbuild.tmpfilesd` for creating tmpfiles.d
configuration files in /usr/lib/tmpfiles.d. Provided list of
configuration directives is written as separate lines into
the configuration file. At least one configuration directive
must be specified.

Fix #786

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-09-08 14:08:40 +02:00
Tomas Hozza
8d85036689 Add a new stage for configuring SELinux state on the system
Add a new `org.osbuild.selinux.config` stage to configure the
SELinux state on the system.

The stage configures the SELinux state on the system in /etc/selinux/config.
The policy enforcement state and active policy type can be configured.

Fix #785

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-09-08 11:22:55 +02:00
Tomas Hozza
ac02244369 Add a new org.osbuild.dnf.config stage for configuring DNF
Add a new `org.osbuild.dnf.config` stage for changing persistent DNF
configuration. Currently only DNF variables can be defined.

Fix #791

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-09-07 14:10:09 +02:00
Tomas Hozza
1cab686f7a Add new org.osbuild.tuned stage for setting active TuneD profile
Add a new stage for setting active TuneD profile. The stage checks the
value of chosen TuneD profile(s) with the list of available TuneD
profiles installed in the filesystem root. If any of the chosen profiles
does not exist, the stage raises an exception.

Add unit tests for the new stage.

Fix #792

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-09-07 10:43:54 +02:00
Christian Kellner
82cc2aeb4e test/data: use cloud-init in ostree image
Although zezere is the official tool, cloud init is easier to use
for local testing so switch to that.
2021-08-28 16:34:37 +02:00
Christian Kellner
c788a74fb5 stages/ostree.deploy: add remote option
Add an optional `remote` to the deployment of the ostree so that
the it is tied to the specified remote. This is needed later for
updating the commit from that remote.
2021-08-28 16:34:37 +02:00
Christian Kellner
7ea9796d9b stages/ostree.pull: add remote parameter
Add an optional `remote` parameter that can be used to specify the
the remote to track for the pulled commits.
2021-08-28 16:34:37 +02:00
Christian Kellner
877f2ba3c3 stages/grub2: greenboot support
Greenboot is the idea of automatically rolling back bad updates,
i.e. updates that do not boot successfully. The implementation
is split between the boot loader and a user space component.
The latter sets two variables `boot_counter`, which indicates
the maximum number of boot attempts and `boot_success` which
tells the boot laoder if a previous boot was successful. The
bootloader on the other hand will decrement the counter variable
and reset the success indicator one.
An implementation of the user space component for rpm-ostree is
called `greenboot`.
2021-08-25 20:53:12 +02:00
Diaa Sami
b93dedf353 stages: add org.osbuild.gzip to compress files
Add a new stage that will take a file from the input and compress
it via gzip.
2021-08-24 20:47:00 +02:00
Christian Kellner
da8f45ef48 stages/grub2: add new uefi.unified option
Fedora 34 and thus RHEL 9 have adopted the unified grub config
scheme[1], where the main config is always placed in the same
location across all platforms, i.e. `boot/grub2`, and a stub
config that redirects to the main config is placed into the ESP.
osbuild has always done that in the case of hybrid boot, but not
for pure EFI systems. The new `uefi.unified` config option can
be used to select that new unified scheme even for the case of
pure EFI systems (aarch64 or non-hybrid boot).

Add a simple test for the grub stage.

[1] https://fedoraproject.org/wiki/Changes/UnifyGrubConfig
2021-08-23 13:55:32 +02:00
Martin Sehnoutka
8b0ea15817 stages: add org.osbuild.ostree.passwd
This stage takes /usr/lib/passwd and /usr/etc/passwd from an OSTree
checkout, merges them into one file, and store it as /etc/passwd in the
buildroot.

It does the same for /etc/group.

The reason for doing this is that there is an issue with unstable UIDs
and GIDs when creating OSTree commits from scratch. When there is a
package that creates a system user or a system group, it can change the
UID and GID of users and groups that are created later.

This is not a problem in traditional deployments because already created
users and groups never change their UIDs and GIDs, but with OSTree we
recreate the files from scratch and then replace the previous one so it
can actually change.

By copying the files to the build root before doing any other
operations, we can make sure that the UIDs and GIDs of already existing
users and groups won't change.

Co-author: Christian Kellner <christian@kellner.me>
2021-08-17 13:53:00 +02:00
Christian Kellner
dbfc04cbb0 test/data: use generic build for fedora-boot
Instead of using the version specific, pre-depsolved f34 build manifest,
use the new version agnostic build manifest (fedora-build.mpp). NB: this
is included directly as mpp so that its variables get defined by the
including manifest. This should make it even easier to update manifests
to new fedora releases.
2021-08-17 10:42:03 +02:00
Christian Kellner
bab3639731 test/data: add version agnostic build manifest
Include a build manifest that is itself not have tied to a specified
version and thus is meant to be included with the following vars
pre-defined as .mpp file:
  - arch          architecture (x86_64)
  - releasever    release version (f34)
  - snapshot      rpmrepo snapshot (20210326)
2021-08-17 10:42:03 +02:00