Commit graph

5392 commits

Author SHA1 Message Date
Achilleas Koutsou
b8fc241755 gen-manifests: copy whole repo config when generating tests
The bug wasn't caught because the PackageSets field of the repository
wasn't being copied after parsing the compose request for the test
manifest.

This should now catch future occurrences of this bug.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
b0a6b486a1 distro/test: set dnf-json path for solver
The value comes from the command line args of the test binary
(osbuild-composer-manifest-tests).  It works in our tests because we use
the default value, but if it was set differently it would have been
ignored.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
114ed20fab distro/test: include package sets field in manifest test repos
The test previously ignored the package-sets field in the repos in the
compose request.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
2a4cd1966d distro: pass all repos to initializeManifest
Pass through all repos to the initalizeManifest() function.  Each
pipeline will then select which repositories it needs based on the
PackageSets field of each repository.

Before, we only passed global repos down to the manifest generators and
pipeline-specific repositories would only be used if they were attached
to package sets and were handled explicitly by a pipeline generator.

The repositories of the "blueprint" package set are explicitly added to
the workload and returned by the "os" pipeline.
The repositories of the "installer" package set are explicitly added to
the "anaconda-tree" pipeline.

If a repository was specified for any other pipeline, for example
"build", the repositories for the that package set were never added to
the pipeline.

Fixes #3290
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
c7e0b69704 manifest: add only necessary repositories to each pipeline
Each pipeline constructor receives the full list of repositories and
filters the list based on its own internal name.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
a66003e513 manifest: helper function for collecting pipeline repos
Function that filters a list of repositories to return only the global
repos and any that define a given pipeline or package set name in their
list of PackageSets.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
50f578924c distro: rename osPkgsKey from "packages" to "os"
Match the key for the OS packages to the name of the OS pipeline ("os").
We will use this key to identify package sets that are returned from the
OS pipeline since the manifest returns package sets indexed by each
pipeline's name.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
942d807877 weldr: fix payload repos package sets assignment
The PayloadPackageSets() was being added to the wrong field in each
payload repository.
Also updated the outdated docstring.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
b918dc8a8c distro/test: add new test for pipeline-specific repos
New test that runs through a few different scenarios of assigning
repositories to specific package sets.  Each scenario defines a set of
global repositories (or none) and a set of pipeline-specific
repositories (or none) and an expected result.  It then calls the
distro's PackageSets() method.  The test checks that the package sets
that are returned are assigned the correct repositories based on the
test case's expected result.

A basic string-set struct is implemented to help with merging and
comparing string slices.

This test should currently fail due to #3290.
2023-02-23 16:22:42 +01:00
Achilleas Koutsou
777d27efbf distro/test: remove RHEL 7 exception from PipelineNames test
RHEL 7 rewrite makes this exception obsolete.
2023-02-23 16:22:42 +01:00
schutzbot
cd8898842c Post release version bump
[skip ci]
2023-02-22 14:01:35 +00:00
Xiaofeng Wang
eaee7870ba test: Add user in simplified installer blueprint
Run ansible playbook with user configured in simplified installer
blueprint
2023-02-22 12:18:12 +01:00
Irene Diez
38b6b9cdcf distro/rhel8+9: allow User/Group customizations on edge-si
Signed-off-by: Irene Diez <idiez@redhat.com>
2023-02-22 12:18:12 +01:00
Irene Diez
dbadd42a01 distro/rhel8+9: deprecate User/Group customi. on edge-commit/container
Signed-off-by: Irene Diez <idiez@redhat.com>
2023-02-22 12:18:12 +01:00
Tomáš Hozza
f5580b1f3e Test: regenerate image manifest that use files customization
Regenerate image manifests which use the files customization and are
affected by the recent change to `osbuild/fsnode.go`, specifically to
always setting the `RemoveDestination` to `true`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
9bebd98d5b osbuild/fsnode: default to removing destination for custom files
Default to always remove the destination before copying when generating
the copy stage options for custom files in the image. This will ensure
that if the destination is an existing symlink to another file, it won't
be followed.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
d9f8dcdd44 Schutzfile: pin osbuild v80 on all distros
Commit is taken from:
https://github.com/osbuild/osbuild/releases/tag/v80

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
145e89211d SPEC: depend on osbuild v80
Set the dependency to osbuild version 80, which contains the
`remove_destination` option in the copy stage.

https://github.com/osbuild/osbuild/releases/tag/v80

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
ad860a6dd4 osbuild/copy: add support for remove_destination option
Add support for newly added `remove_destination` option in the copy
stage.

Related to https://github.com/osbuild/osbuild/pull/1241

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
19e38621c9 Test/ostree-ng: test dirs and files customizations
Test the directories and files customization with the ostree container
image type deployed using the (Anaconda-based) installer image.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
3cf77187d6 Test: reformat parts of ostree-ng.sh
Reformat calls of `ansible-playbook` by splitting them into multiple
lines. This makes it easier to read.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
6cd7892c47 Test/ostree: test dirs and files customizations
Test the directories and files customization with the ostree commit
image type.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
50fc6cc29c Test: reformat part of ostree.sh
Split the call to `ansible-playbook` to multiple lines.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
55c3abe842 Test/ansible/check_ostree: test dirs and files customization
Extend the `check_ostree.yaml` to check the result of directories
and files customizations on a running ostree-based system. The test
also checks if a custom systemd unit `custom.service` got enabled
and started on boot.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
c528948b71 Test/API: use directories and files customization for supported images
Use directories and files customization in the compose request for image
types that support this customization (only ostree installer and raw
image do not support it).

Extend the instance verification to check for the custom directories and
files.

Extend the ostree commit verification to check for the custom
directories and files.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
d1325aaf45 Test/API/GCP: don't set gcloud format to JSON by default
Previously, the `--format=json` was always set in the `$GCP_CMD`. This
was working OK in general, but it is creating issues when using
`$GCP_CMD compute ssh` to execute commands on the provisioned VM. In
such case, an extra `[]` is added to the output, which then causes
various checks to fail, since the captured stdout is different than
expected.

Instead remove the `--format=json` by default from `$GCP_CMD` and use it
explicitly only in cases when `jq` is used to parse the command's
output. In all other cases, it should be OK to not set the output format
to JSON and it is very much desirable to do so when SSH-ing to the VM.

Also by default pass the `--quiet` option to `gcloud` when using it from
the container. This was previously done only when using the tool
installed on the system.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
1c64d15a61 Test/fedora: add iot-container test manifests with customizations
Add `iot-container` test manifests with customizations. Specifically with
files, directories and services.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
df26be35cc Test/fedora: add iot-commit test manifests with customizations
Add `iot-commit` test manifests with customizations. Specifically with
files, directories and services.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
e16fdeb7ed Test/el/cs: add edge-container test manifests with customizations
Add `edge-container` test manifests with customizations. Specifically with
files, directories and services.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
5a7092bfd5 Test/el/cs: add edge-commit test manifests with customizations
Add `edge-commit` test manifests with customizations. Specifically with
files, directories and services.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
1ea58566ff tools/tc-generators/format-req-map: drop all rhel-edge-* requests
Drop unused `rhel-edge-*` requests, which are not used any more. They
have been replaced by `edge-*` requests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
aa9373cb18 Test: use dir and file customizations in qcow2 image manifests
Add the new directories and files customization to the customized qcow2
image manifests used for testing.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
e9af3bda64 Cloud API: expose directory and file customizations
Expose the Directory and File customizations in the Cloud API. Also
validate the provided customizations while processing the compose
request by trying to convert them to internal representations
`fsnode.File` and `fsnode.Directory`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
15f1962c34 Cloud API: add error for failed customization validation
Add new error `ErrorInvalidCustomization` used in situations when the
user-provided customization values don't pass validation. This will be
used by the Directory  / File customization.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
ffd0bdb7ad distro: add dir / files customizations policy check
Add a default policy for custom directories and files to constrain what
users can do. The intention is to ensure that directories and files can
be created only in `/etc` and also that none of the important
configuration files can be overwritten by this customization.

Add the policy validation to all distro implementation.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
3ee973c8ee blueprint: add functions checking dir / file customizations policy
Add helper functions for checking directory and file blueprint
customizations against the policy of allowed paths.

These functions are not yet used in the distro definitions.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b98f5dad70 distro: set dir / file BP customizations in OS customizations
Hook up the custom BP directories and files implementation with OS
pipeline implementation. The user-provided values are now set in the OS
customizations structure and will be used by the OS pipeline generator
when adding stages to the pipeline.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
4e2b369acf SPEC: depend on osbuid v78
The version 78 is needed in order to use the `chown` stage.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
0e2f221514 distro: validate directory / file BP customizations
Validate the user-provided directory and file BP customizations in
`checkOptions()`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
a6dd4943c5 blueprint: add function for validating dir and file customizations
Add a helper function for validating the user-provided directory and
file customizations. This is necessary to fail early on invalid input,
instead of when building the image.

The function ensures that:
- No file path is a prefix of another file or directory path
- There are no duplicate file or directory paths in the
  customizations

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
053c1b090f blueprint: add functions converting dir and file customizations
Add helper functions for converting slices of directory and file
customizations structures from the `blueprint` package to a slice of
structures from the `fsnode` package, which are used in image type
definitions.

These will be used to convert BP customizations to the os pipeline
customization then used by the pipeline generator.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
c1991b3d51 blueprint: add representation of Directories and Files customization
Extend the Blueprint customizations with the representation for custom
Directories and Files specified by the user.

Implement custom Unmarshalers for TOML and JSON. These ensure that all
user-provided values are validated before use and also handle the fact
that user and group ownership for directories and files can be
specifies as a string or as an integer.

Implement helper functions for converting the Blueprint-specific types
for these customizations to their internal representation from `fsnode`
package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
26e6983320 disk: move remaining mountpoint policy code to different packages
Move the `CheckMountpoints()` implementation to `blueprint` package,
since it does not operate on any data structures from the `disk`.

Move the default mountpoint allow list policy definition to the
`pathpolicy` package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
eb0531b89b blueprint: move FilesystemCustomization code to separate file
Move the `FilesystemCustomization` structure and its custom
unmarshallers to a dedicated file. This makes `customizations.go` easier
to read.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
3075d3a2ad disk: separate PathPolicies implementation to its own package
The `PathPolicies` implements a generic concept that can be fit on more
use cases than just mountpoints. Another one would be a policy for
creating custom files and directories in the image. Having the
implementation in the `disk` package and using data structures from the
`disk` and `blueprint` packages makes it impossible to use it for any
additional BP customization due to a circular dependencies that always
occurs.

Split out the implementation into a separate package `pathpolicy` as the
first step.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b3f695db72 manifest/os: support directories and files customization
Extend the `OSCustomizations` with a list of custom files and
directories, that should be created in the image. If any `Files` or
`Directories` are specified in the `OSCustomizations`, the appropriate
osbuild stages will be added to the `os` pipeline. In addition to that,
any custom files data will be returned by the `getInline()` method of
the `os` pipeline.

This customization can't be yet used by users, because the translation
from BP customization to the `OSCustomizations` is missing.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
acfceb74b2 osbuild: add variadic version of Pipeline.AddStage() method
This will allow to conveniently add multiple stages to the pipeline at
once, which is useful if a generator function wrapping some
functionality generates more than one `Stage`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b36c03f20c manifest/os: move the systemd services stage more to the end
Move the handling of the list of enabled and disabled systemd services
more to the end of the `os` pipeline, just before the SELinux stage.
This has no functional effect on produced images, but it will make it
nicer once the handling of the custom files and directories will be
added to the pipeline. Specifically it should be added right before the
services stage to allow enabling custom service files, but after all
other configurations that are applied to the image.

Regenerate all manifests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
fd79934843 osbuild: add helper functions generating stages from fsnode types
Implement helper functions for generating osbuild stages for a slices of
`fsnode` types, such as Files and Directories. The generated stages will
ensure that the provided FS nodes will be created in the FS tree and
will have their respective properties set (such as ownership, mode,
etc).

These functions are not yet used by any pipeline code, but the idea is
that they will be used in pipeline generator functions to create custom
directories and files based on the pipeline-specific customizations.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
0bd0ce9fc1 osbuild: add support for org.osbuild.chown stage
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00