Commit graph

314 commits

Author SHA1 Message Date
Christian Kellner
21ad9fa399 stages/qemu: fix 'compat' option
The option got renamed to `compat` (and moved into the `qemu`
object) when the stage was extracted from the `qemu` assembler;
but the code, taken from the assembler, still used the old
`qcow2_compat` name for the option. Fix this.
2021-09-23 11:00:47 +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
Achilleas Koutsou
f5a048e7b4 stages/kickstart: set passwords with --iscrypted
The password is assumed to be encrypted so the `--iscrypted` option is
required.
2021-09-03 15:13:00 +02:00
Christian Kellner
3c565347a3 stages/kickstart: quote ssh-key
Surround the ssh key by quotes since it might contain spaces.
2021-08-29 20:09:30 +02:00
Christian Kellner
4a5508e086 stages/bootiso.mono: support for aarch64 tempates
Use the aarch64 templates if the efi architecture was set to AA64.
NB: since we only support efi booting for aarch64 this should be
good enough for aarch64 selection.
2021-08-29 16:33:13 +02:00
Christian Kellner
597f5f9ea7 stages/kickstart: add schema for remote option
The code of the `org.osbuild.kickstart` stage already supported
adding the `--remote` option for `ostreesetup` via the `remote`
option but it was not included in the schema.
2021-08-29 16:33:06 +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
7a676667d6 Don't save name or timestamp for compressed file 2021-08-24 20:47:00 +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
Christian Kellner
f3f3904368 stages/lvm2.metadata: fix typo in regex
It is zero to nine, not zero and nine.

Reported-b: Achilleas Koutsou <achilleas@koutsou.net>
2021-08-21 09:10:42 +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
23d3981d50 stages: add org.osbuild.lvm2.metadata
Add a new stage that allows the modification of LVM2 metadata,
most importantly it allows for renaming of the volume group.
It internally uses the new `utils.lvm2` module.
2021-08-13 12:20:54 +02:00
Christian Kellner
56d9dea416 stages: add org.osbuild.lvm2.create 2021-08-13 12:20:54 +02:00
Christian Kellner
234997eeb3 stages/grub2.inst: fix prefix for dos layouts
When the partition layout is `dos` or `mbr`, the correct name for
it in the prefix is `msdos`. The function to convert the option
to the label already existed but was not used. Fix it by actually
using said function.

Reported-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-08-10 20:19:06 +02:00
Christian Kellner
569697e9a9 stages: add org.osbuild.untar
Add a new stage that can be used to extract a tarball.
2021-08-07 11:50:00 +02:00
Christian Kellner
ff63bb6b51 stages/fstab: fix partabel option
Use the `partlabel` value for the `partlabel` option instead of
the `label` option.
2021-08-07 11:50:00 +02:00
Ondřej Budai
7fc8ac231d stages/grub2.inst: add location to required properties
The location property is required, otherwise the stage will fail due to
KeyError at line 261:

location = options["location"]

This commit adds the property to the list of required ones.
2021-08-05 09:58:23 +02:00
Christian Kellner
9977c4e1f9 stages/nm.conn: allow creating files anywhere
Introduce a new `path` property that can be used instead of
`filename` to create files anywhere in the file system.
2021-07-28 22:01:54 +01:00
Christian Kellner
bfcc92a92e stages/nm.conn: set 0o600 permission for files
NetworkManager will refuse to load connection files that have the
to wide permsisions set. Restrict the files we create to 0o600.
2021-07-28 22:01:54 +01:00
Christian Kellner
6f7382b885 stages: add org.osbuild.nm.conf
New stage to create NetworkManager configuration files. Currently
only a subset of settings are supported. Include a simple stage
test case for it.
2021-07-28 22:01:54 +01:00
Tomas Hozza
152b14a0d6 stages/cloud-init: configuration file must contain at least one option
Add back a schema constrain, that at least one configuration must be
specified for the configuration file.

This has been forgotten/missed as part of
https://github.com/osbuild/osbuild/pull/739.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-07-27 10:40:04 +02:00
Christian Kellner
873defb330 stages/tar: option to not include the root node
When building the tar archive, the command that is used normally
includes the root node as `./` and also leads to all files having 
a "./" prefix. On the other hand, the oci stage as well as the 
old ostree.commit assembler, with the tarball option, would
enumerate the contents instead of passing `.`, thus not including
the rood node and also avoiding the `./` prefix. 
Add a new option `root-node` that controls whether the rood node
is included or node. 

mkdir test
touch test/file

tar -c -C test file | tar tv
-rw-r--r-- root/root         0 2021-07-22 10:39 file

tar -c -C test . | tar tv
drwxr-xr-x root/root         0 2021-07-22 10:39 ./
-rw-r--r-- root/root         0 2021-07-22 10:39 ./file
2021-07-22 15:23:39 +02:00
Christian Kellner
e1df62fdc8 stages: add org.osbuild.nm.conn
Add a new stage to configure NetworkManger system connections.
Currently only ethernet connections are supported with a limited
set of options.
2021-07-22 15:18:33 +02:00
Christian Kellner
e0db66f624 stages/fstab: support device nodes and partlabel
For the fs spec field, support traditional device nodes as well
as partition labels. Adjust the test accordingly.
2021-07-22 12:05:02 +02:00
Christian Kellner
7fde451ecd stages: extract systemd.unit from systemd
Create a new `org.osbuild.systemd.unit` stage with the code for
create systemd drop-ins extracted from `org.osbuild.systemd`.
In contrast to the old code the new stage can only handle one
drop-in file. This makes the stage and its schema clearer
and simpler. If more than one config file is needed, the stage can
be repeated multiple times. It is also more flexible since we can
in the future specify additional options at the top level which
will then be per-file, like a top level comment.
The file is called `org.osbuild.systemd.unit` since in the future
it could also support creating unit files (not just drop-ins).
2021-07-22 01:05:29 +02:00
Christian Kellner
9a786ce4fc stages/logind: write only one drop-in file
Instead of supporting writing an arbitrary number of configuration
files, just write one. This makes the stage and its schema clearer
and simpler. If more than one config file is needed, the stage can
be repeated multiple times. It is also more flexible since we can
in the future specify additional options at the top level which
will then be per-file, like a top level comment.
2021-07-22 01:05:29 +02:00
Christian Kellner
79c6e65976 stages/logind: configuration_files → config
Rename the `configuration_files` key to `config` key.
2021-07-22 01:05:29 +02:00
Christian Kellner
9f1d97a8b7 stages/modprobe: write only one config file
Instead of supporting writing an arbitrary number of configuration
files, just write one. This makes the stage and its schema clearer
and simpler. If more than one config file is needed, the stage can
be repeated multiple times. It is also more flexible since we can
in the future specify additional options at the top level which
will then be per-file, like a top level comment.
2021-07-22 01:05:29 +02:00
Christian Kellner
0190c991ae stages/dracut: write only one config file
Instead of supporting writing an arbitrary number of configuration
files, just write one. This makes the stage and its schema clearer
and simpler. If more than one config file is needed, the stage can
be repeated multiple times. It is also more flexible since we can
in the future specify additional options at the top level which
will then be per-file, like a top-level comment.
2021-07-22 01:05:29 +02:00
Christian Kellner
a1703dc298 stages/cloud-init: write only one config file
Instead of supporting writing an arbitrary number of configuration
files, just write one. This makes the stage and its schema clearer
and simpler. If more than one config file is needed, the stage can
be repeated multiple times. It is also more flexible since we can
in the future specify the directory, `/etc` vs `/usr` via a new
top level `directory` key.
2021-07-22 01:05:29 +02:00
Christian Kellner
0becf66454 stages/dracut.conf: configuration_files → config
Rename the `configuration_files` key to `config` key.
2021-07-22 01:05:29 +02:00
Christian Kellner
f259b4e5ca stages/modprobe: configuration_files → config
Rename the `configuration_files` key to `config` key.
2021-07-22 01:05:29 +02:00
Christian Kellner
9e259ae0bc stages/cloud-init: configuration_files → config
Rename the `configuration_files` key to `config` key.
2021-07-22 01:05:29 +02:00
Christian Kellner
ae1296e33a formats/v2: mounts are arrays
The order of entries in a dictionary is not specified by the JSON
standard and hard to control when marshalling dictionaries in Go.
Since the order of mounts is important and the wrong order leads
to wrong mount trees change the `mounts` field to an array. This
breaks existing manifests but after careful deliberation it was
concluded that the original schema with mounts as dictionaries
is not something we want to support. Apologies to everyone.

Adjust the schema of the copy and zipl stage accordingly.
2021-07-21 13:28:22 +02:00
Christian Kellner
31943072c7 stages/noop: allow mounts and devices
Allow the noop stage to have mounts and devices, which is useful
for testing.
2021-07-21 13:28:22 +02:00
Christian Kellner
0910320e62 stages: add org.osbuild.isolinux
New stage to configure the isolinux boot loader.
2021-07-16 15:19:58 +01:00
Christian Kellner
228323f0dc stages: add org.osbuild.squashfs
New stage to create a squahfs image.
2021-07-16 15:19:58 +01:00
Christian Kellner
fb2786e4dd stages/grub2.iso: small refactoring
Small changes to the schema so it better aligns with the need of the
stage:
  move the efi properties to the top-level
  kernel information is under `kernel` object
  kernel command line options is an array now
Change `linuxefi` to `linux` which should work on RHEL 8 and is the
only thing that works on arm64.
Small PEP-8 fixes.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-07-16 13:20:45 +02:00
Antonio Murdaca
dd13ec24fb stages: add org.osbuild.grub2.iso stage
Add a new stage to build a boot filesystem tree

Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-07-16 13:20:45 +02:00
Christian Kellner
887e1bd8aa stages/kickstart: support for users and groups
Add support for creating groups and users during the installation
via the corresponding kickstart directives.
2021-07-15 23:08:51 +01:00