Commit graph

191 commits

Author SHA1 Message Date
Ondřej Budai
092f886904 stages/users: support a dot inside a username
From IEEE Std 1003.1-2017:

 3.437 User Name:
A string that is used to identify a user; see also User Database. To be
portable across systems conforming to POSIX.1-2017, the value is composed
of characters from the portable filename character set. The <hyphen-minus>
character should not be used as the first character of a portable user name.

 3.282 Portable Filename Character Set
The set of characters from which portable filenames are constructed.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9 . _ -

The last three characters are the <period>, <underscore>, and <hyphen-minus>
characters, respectively.

---

The regex checking the username in org.osbuild.users stage omitted the
<period> character before. This commit adds it and modifies the stage
test in order to cover this change.

Fixes: rhbz#2104464
2022-07-21 14:52:57 +02:00
Christian Kellner
6e66c69608 stages: add org.osbuild.containers.storage.conf
New stage to  create or modify `containers-storage.conf` config
files. The currently implement strategy is to merge the given
and existing configuration options.
2022-07-11 16:25:56 +02:00
Christian Kellner
07a45ba34c test/data: include python3-toml in v2 build root
Prepares for testing stages that use python3-toml to edit config
files.
2022-07-11 16:25:56 +02:00
Gianluca Zuccarelli
c379dccdf1 test/data: update oscap.remediation tests
The oscap.remediation stage now runs the
remediation during build time rather than
creating the necessary files to run the
remediation on first-boot. The tests have
been updated to reflect these changes.
2022-07-06 09:59:00 +02:00
Christian Kellner
4c12967c0d stages/dnf.config: add support for tsflags
Add support for specifying rpm transaction flags via the `tsflags`
options. See `dnf.conf(5)` for more details.
2022-06-30 09:37:27 +01:00
Christian Kellner
f078420879 manifests/fedora-container: persist _install_langs
Persist the `_install_langs` via the new `org.osbuild.rpm.macros`
stage.
2022-06-30 00:17:23 +01:00
Christian Kellner
10b8c0dcdc stages/rpm.macros: new stage to set rpm macros
This is to persistently set specific RPM macros. Currently only
`_install_langs` is supported.
2022-06-30 00:17:23 +01:00
Christian Kellner
5fbfd710e4 manifests/fedora-container: only install en locale
This will shrink the container by around 13MB.
2022-06-30 00:17:23 +01:00
Christian Kellner
4d39f9ec2b stages: add new org.osbuild.rpmkeys.import stage
Add a new stage to import public keys into the RPM database via the
`rpmkeys` command. This is similar as to what the `org.osbuild.rpm`
stage already does but it uses inputs instead of inline data.
2022-06-25 13:19:11 +01:00
Jelle van der Waa
923cc60fdb stages: add vagrant stage for libvirt
This commit introduces a new vagrant stage and initially only supports
the libvirt backend. The vagrant stage takes a disk image as input
generates a Vagrantfile and metadata.json.
2022-06-23 11:06:12 +02:00
Christian Kellner
86123da599 stages/qemu: expose vpc options
Currently we hard code the vpc options `subformat=fixed` and
`force_size`, which are needed to generate valid azure images
with newer versions of qemu. But for other use cases or other
versions of qemu these options might not be wanted or valid.
Expose all the options but with defaults corresponding to the
old behavior.
Add a unit test for the `force_size` option to check its
effect. Also add a check for the correct size to the existing, 
default value (i.e. `force_size` being `true`).
2022-06-15 13:41:11 +02:00
Gianluca Zuccarelli
4ede85f176 test/data: add oscap.remediation tests
Add new tests for the `oscap.remediation`
stage.
2022-05-31 01:32:49 +02:00
Christian Kellner
16b187f5d9 test: add grub2.legacy test
Add a basic check for the org.osbuild.grub2.legacy stage.
2022-05-29 14:02:16 +02:00
Christian Kellner
e0fbbdaa5e stages: add new sgdisk stage
Can be used to create partition tables via GPT laypout via `sgdisk(8)`.
The schema of `partitions` is intentionally kept identical to the one
in `org.osbuild.sfdisk`.
Add corresponding tests.
2022-05-23 13:00:44 +02:00
Christian Kellner
5edb54bc2d test/data: add gdisk to fedora 34 v2 build root
Will be use in later test. Separated as its own commit for clarity.
2022-05-23 13:00:44 +02:00
Thomas Lavocat
441e67a6f6 ostree: show commit metadata
This new API call allows one to check (among other things) if a commit
exists in a repo. It'll throw a RuntimeException if the commit is
missing.
2022-05-11 04:32:42 -05:00
Christian Kellner
d04ce2e1ef stages: add new org.osbuild.udev.rules stage
Add new stage to create udev rules files; add a simple stage test
to check for basic functionality.
2022-05-06 12:46:03 +02:00
Tomas Hozza
bbe6127ddb Stages: support vmdk subformat in the qemu stage
Support specifying the subformat for the `vmdk` image type in the
`org.osbuild.qemu` stage.
2022-04-05 15:01:34 +02:00
Tomas Hozza
b4593f0f2b Add unit test for org.osbuild.qemu stage
The unit test consists of a manifest creating an empty file, which
is then converted to various formats using the `org.osbuild.qemu` stage
in separate pipelines.

The unit test then builds and exports each pipeline with qemu stage and
inspects the resulting image file using `qemu-img info` command and checks
that the test data specified in `checks.json` is a subset of the data
returned by the command.
2022-04-05 15:01:34 +02:00
Christian Kellner
d8f36b55fa stages/grub2: option to configure GRUB_DEFAULT
Add a new attribute `config.default` that when set will be written to
`GRUB_DEFAULT`. This should be set to `saved` when a `saved_entry` is
specified so that the functionality will be preserved if the grub cfg
gets regenerated (which is really should not, but we can not prohibit
it).
2022-03-04 16:38:41 +01:00
Tomas Hozza
9054da7d25 stages/firewall: fix fail when setting only the default zone
When the firewall stage is provided with stage options, which set only
the default firewall zone, the `firewall-offline-cmd` command is
executed unconditionally without any parameters. This is because in this
case `ports`, `enabled_services` and `disabled_services` are all an
empty lists. This results in a failure with the following error message:

`Opening of '/etc/sysconfig/system-config-firewall' failed, exiting.`

Make sure that the second invocation of `firewall-offline-cmd` happens
conditionally, only when at least one of the `ports`, `enabled_services`
or `disabled_services` is a non-empty list.

Adjust the stage test to cover this scenario.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-03-04 10:02:27 +01:00
Tomas Hozza
e71a91f5d0 Extend firewall stage to set the default zone
Extend the firewall stage to allow setting the default firewall zone.
Modify the stage unit test accordingly.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-03-02 16:43:22 +01:00
Jelle van der Waa
00c6bf2376 test: update arch manifests for new stages 2022-03-01 16:07:27 +01:00
Christian Kellner
8f75d1e7a1 stages: add new org.osbuild.fdo stage
This stage is needed to write down the FDO DIUN pub key root certs
needed to talk to the manufacturer server to grab the device credentials
for provisioning and later onboarding

Co-Authored-By: Antonio Murdaca <runcom@linux.com>
2022-02-23 15:32:02 +00:00
Alexander Larsson
7c9944ee18 Update the skope test stage
Drop format and file options and convert the hello.img from
docker to oci format.
2022-02-10 14:43:17 +01:00
Alexander Larsson
13c0c1e59e test: Add skopeo tests
There is a source test that installs a pre-build, embeded image file
and ensure all the right files are installed. This uses the vfs driver
because then it works everywhere, including the CI (which doesn't do
overlayfs).

Then the is a source test that downloads a minimal image from
a faked registry on localhost.

For the registy API to work the "/v2" entry-point in the webserver has
to be at the root, so there is a symlink in test/data:

  v2 -> sources/org.osbuild.skopeo/data/v2

But otherwise the data is localized to sources/org.osbuild.skopeo.
2022-02-10 14:43:17 +01:00
Alexander Larsson
b6629de7b2 Add skopeo to f34-build-v2 manifest
This will be needed to test the container support.
Also update the test data
2022-02-10 14:43:17 +01:00
Thomas Lavocat
bb30ffa062 Add the option of compressing using lz4
Using lz4 in squashfs reduces the time to complete the stage from 446s
to 4s on my laptop while making the produced iso going from 1.6G to
2.0G.
2022-01-11 13:20:11 +01:00
Christian Kellner
26a250ca6e test/data: don't write cmdline in grub2
In the fedora-boot manifest, do not write the kernel command line
to the `grubenv` file.
2022-01-06 15:09:33 +00:00
Jelle van der Waa
97202e53b0 stages: Respect grub_home for grub legacy boot
Additionally add a new QEMU image output target for testing
grub2/mkinitcpio stages.
2022-01-06 16:01:26 +01:00
Jelle van der Waa
0cbd7898c7 Add mkinitcpio stage
This stage generates the initrd for Arch Linux and derivates.
2021-12-21 10:44:55 +01:00
Achilleas Koutsou
646dd238fe stages: add new org.os.build.pacman and org.osbuild.pacman.conf stage
Pacman is the default package manager for Arch Linux and derivates, the
pacman.conf stage generate a valid pacman.conf configuration file.

Co-Authored-By: Jelle van der Waa <jvanderwaa@redhat.com>
2021-12-15 23:22:15 +01:00
Tomas Hozza
d7989a5c26 Add new stage for configuring DNF Automatic
Add a new stage `org.osbuild.dnf-automatic.config` for configuring DNF
Automatic.

The stage changes persistent DNF Automatic configuration. Currently, only
a subset of options can be set:
  - 'commands' section
    - apply_updates
    - upgrade_type

Fix #908

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-15 18:49:13 +01:00
Tomas Hozza
cd4ac1c75a Add new stage for creating YUM / DNF repo files
Add a new stage `org.osbuild.yum.repos` for creating YUM / DNF `.repo`
files in `/etc/yum.repos.d`. All repo-specific options are supported but
only a subset of options which can be set for a repo as well as in the
[main] section are supported.

Add unit test for the new stage.

Fix #907

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-09 18:51:51 +01:00
Sanne Raymaekers
5b3ebd7912 stages/org.osbuild.dnf.config: Edit /etc/dnf/dnf.conf
Fixes #906
2021-12-09 15:53:57 +01:00
Christian Kellner
e62133a334 manifests/ostree-image: convert to LUKS
Wrap the LVM volume group in a LUKS container with the passphrase
`osbuild` (yes, really, super secure). NB: the kernel command line
is changed to include `luks.uuid` which is needed so that dracut
will attempt to open the luks container. This corresponds to an
crypttab entry `luks-uuid UUID`. We cannot use the /etc/crypttab
for ostree based images because the initrd is created at commit
time but they luks volume is created at deployment time, we have
to use the kernel command line instead. See the man page for the
systemd-cryptsetup-generator(8) for more information.

The `cryptsetup` package is included in the build root since it is
needed by the `org.osbuild.luks2.format` stage. All manifests that
are using the `f34-build-v2` build root change as a result.
2021-12-09 00:44:21 +00:00
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
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
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
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