Commit graph

70 commits

Author SHA1 Message Date
Achilleas Koutsou
f2849e2165 blueprint: sanitize user home directories
If a home directory has a trailing slash, the `useradd` command fails to
set the correct selinux contexts for the home directory on creation.
This can lead to various issues, but the one that we came across was
that the ~/.ssh directory and authorized_keys file cannot be read by
sshd and we couldn't log in to the system.

This only manifests if the user is created through the kickstart file
because:
1. `useradd` does not set the selinux contexts when creating the
   directory
2. Anaconda runs `restorecon` on the home directory and authorized_keys
   file when it creates them, but uses the install-time mount path
   `/mnt/sysroot/...` for which selinux does not have contexts.

In most cases we get around this bug because we run `setfiles` on the
tree at the end of our pipelines.
For the ostree case, the relabeling in Anaconda is done correctly.
2022-03-28 14:08:57 +02:00
Antonio Murdaca
e2bd3506e2 distro/rhel86: add fido dracut module and enable customizing onboarding
This patch also introduces customizations to fully enable onboarding
options for FDO.

Co-Authored-By: Christian Kellner <christian@kellner.me>
2022-02-24 17:07:34 +01:00
Antonio Murdaca
5005ff6184 internal: mandate installation device for the simplified installer
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-11-18 18:10:09 +01:00
Martin Sehnoutka
708d985194 internal/blueprint: allow filesystem size specified with units
Allow users to specify filesystem size with units such as kB, MB, etc.
2021-11-02 18:32:47 +01:00
Martin Sehnoutka
f84beee04d internal/blueprint: introduce custom fs customization parser
The automatically generated parser can only parse integers into the size
field. Introduce a new one, which will be able to handle strings as
well.
2021-11-02 18:32:47 +01:00
Martin Sehnoutka
f2f078acd6 internal/blueprint: introduce new test for parsing blueprints
Test case like this was completely missing. A similar one is present in
the Weldr package, but this one is specific to testing blueprints and
thus easier to understand and extend.
2021-11-02 18:32:47 +01:00
Gianluca Zuccarelli
b8c14a5689 blueprints: change minsize from int to uint64
thozza pointed out that `int` is platform dependent which results in
a fs size that is too small for 32-bit machines. This commit changes
the filesystem custimizations to use `uint64` instead of `int`
2021-09-29 15:08:12 +02:00
Christian Kellner
4e80c1bc82 distro/rhel85: add simplified edge installer
This adds a new installer called the "Simplified Installer" for Edge.
In contrast to the existing insaller, which is based on Anaconda, this
new installer based on the CoreOS installer project[1], a small rust
based binary that is executed in the initramfs and will flash a raw
image to a specified installation device. For this a new blueprint
option is introduced. The raw image is created from an existing OSTree
commit and embedded into the resulting bootable iso. When booting the
iso the installation will automatically start witout any interaction
from the user.
NB: As with the existing edge installer, support is currently limited
to x86. The new installer also does not support non-uefi boot.

[1] https://github.com/coreos/coreos-installer

Co-Developed-by: Achilleas Koutsou <achilleas@koutsou.net>
Co-Developed-by: Antonio Murdaca <runcom@linux.com>
2021-08-28 09:20:19 +02:00
Christian Kellner
6d08418107 blueprint: add CheckAllowed helper
New helper to check if a blueprint containts only a set of allowed
customization. If not an error is returned.
2021-08-28 09:20:19 +02:00
Gianluca Zuccarelli
fa15541ea5 blueprint: test minsize and sector-size validation 2021-07-28 21:44:03 +01:00
Gianluca Zuccarelli
90733e79f3 blueprint: add filesystem minsize function 2021-07-28 21:44:03 +01:00
Gianluca Zuccarelli
d0e4558b2b blueprint: add filesystem customisations support 2021-07-28 21:44:03 +01:00
Brian C. Lane
1abdd9a1f7 weldr: Add distro field to blueprints
An optional distribution name can be included with the blueprint. If is
is not then the blueprint will be depsolved/built using the current host
distribution.

depsolveBlueprint and depsolveBlueprintForImageType check for the empty
Distro name and set it to the host distro before using it. The function
signatures have also been changed to use the value instead of a pointer
so that changes don't effect anything outside the depsolve function.
2021-07-12 08:58:42 +02:00
Tom Gundersen
0efc345b2d rhel84/grub2: set saved_entry
Explicitly set the kernel to boot into.

Also change the blueprint/kernenl handling:

Rather than only falling back to the default kernel name for
getting the package list, let GetKernel() always return the
correct result so we can rely on this being consistent.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-02-20 20:01:15 +01:00
Achilleas Koutsou
d0923af70d blueprint: test kernel customization
Edit GetPackages test to expect automatic kernel inclusion.

New test for all combinations of adding a kernel to customizations and
package list.
2021-02-16 13:51:26 +00:00
Achilleas Koutsou
b861042032 blueprint: add kernel name customization
Blueprints can now be used to specify a kernel as part of the kernel
customizations.  Specifying a kernel adds it to the package list.

If no known kernel is specified (neither in the customizations nor the
package list), the default "kernel" is included automatically.

If kernels are specified in both the package list and the
customizations, both are added (even if they're duplicates).
2021-02-16 13:51:26 +00:00
Ondřej Budai
6e6eae24eb blueprint: do not append "-" to name-version if version is empty
Previously, bash with empty version was converted to name-version "bash-"
that is obviously ill-formed. This commit fixes it.
2020-06-10 17:40:30 +02:00
Tom Gundersen
dc794a6d31 blueprint: DeepCopy() cannot fail
Don't return an error value, as it is always nil.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00
Jakub Rusz
703039495b tests: add coverage for internal/blueprint/customizations.go 2020-03-31 16:47:00 +02:00
Tom Gundersen
895a4769e3 osbuild: remove dead code
The helper functions were never used, we should aim to use the
osbuild types just as regular structs for serialization purposes.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-26 00:31:37 +01:00
Lars Karlitski
ee752b0ab8 tree-wide: panic when json marshalling fails
According to the new guidelines in docs/errors.md.

Note that this does not include code that marshals to a writer that
might fail (when a connection drops, for example).
2020-03-25 10:22:16 +01:00
Jakub Rusz
6f1c461c32 tests: use testify for existing blueprint_test functions 2020-03-24 20:37:10 +01:00
Jakub Rusz
833e798f1b tests: test for blueprint.GetPackages()
This also tests Package with "*" specified as version
2020-03-24 20:37:10 +01:00
Tom Gundersen
7957feff48 distro.Manifest: take Customizations rather than Blueprint as argument
This makes two changes simultaneously, to avoid too much churn:
 - move accessors from being on the blueprint struct to the
   customizations struct, and
 - pass the customizations struct rather than the whole blueprint
   as argumnet to distro.Manifest().

@larskarlitski pointed out in a previous review that it feels
redundant to pass the whole blueprint as well as the list of
packages to the Manifest funciton. Indeed it is, so this
simplifies things a bit.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 23:48:42 +01:00
Jacob Kozol
4690320503 blueprint: add default version
If the user creates a new blueprint with no version specified, the
blueprint struct uses "0.0.0" as the default version. Blueprint tests
for a blueprint with an empty version now expect no error.
2020-03-04 19:20:58 +01:00
Brian C. Lane
cce9a2712c Fix Blueprint Revision, it is an integer not a string
This changes it to an int pointer so that the JSON will output null.
This means it needs to be checked for nil or for 0 in go.

0 is not a valid revision in the WELDR response, they always start at 1
and increment for each new revision tag so either way is a valid way
to indicate it isn't set.
2020-03-03 12:21:40 +01:00
Ondřej Budai
d7cbc22da4 lint: fix unhandled errors 2020-03-02 14:28:55 +01:00
Brian C. Lane
58839cf927 Use semver to enforce blueprint version numbers
This changes osbuild-composer's behavior to match lorax-composer when
encountering invalid versions. Instead of leaving them as-is it will
return a BlueprintError explaining the problem. eg.

"errors": [
    {
        "id": "BlueprintsError",
        "msg": "Invalid 'version', must use Semantic Versioning:  is not in dotted-tri format"
    }
]

This is enforced on new blueprints (including the workspace). If a
previously stored blueprint has an invalid version and a new one is
pushed it will use the new version number instead of trying to bump the
invalid one.

This also moves the version bump logic into blueprint instead of store,
and adds an Initialize function that will make sure that the blueprint
has sane default values for any missing fields.

This includes tests for the Initialize and BumpVersion functions.
2020-02-25 09:00:35 +01:00
Brian C. Lane
3ce066a91a Add DeepCopy function to Blueprint struct
The Blueprint struct is complex, deep, and full of references. This
means that any changes to it in memory will persist. Sometimes you need
an actual copy of it, so this adds DeepCopy which uses the json.Marshal
and Unmarshal functions to create a deep copy with no references to the
original.

This is not very efficient, but the alternative is adding Copy functions
to all the member structs and then calling them to build the copy.
2020-02-19 23:44:17 +01:00
Tom Gundersen
93b13e3fa7 blueprints: fix group handling
When group names are passed on to dnf, they must be prefixed with an
ampersand, or they are treated as a regular package, potentially
causing the build to fail.

Add a testcase to verify this behavior.

This resolves rhbz#1784035.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-17 09:24:15 +01:00
Lars Karlitski
ea70d9dfc5 blueprint: don't set omitempty for toml groups and modules
The integration tests expect the empty arrays to be there.
2019-12-10 20:21:47 +00:00
Lars Karlitski
b1c65bb671 blueprint: tag all struct fields for toml
This is repetitive, but there doesn't seem to be another way to export
lower-case field names.
2019-12-04 19:15:33 +01:00
Lars Karlitski
673d3ff14b blueprint: remove unused error
It was moved to the distro package a while ago.
2019-11-29 00:46:05 +01:00
Lars Karlitski
da311f13eb distro: add rhel82
This takes a different approach to outputs and customizations, which is
much shorter and duplicates less code.

This uses links to internal repositories for now, because 8.2 hasn't
been released yet.

Add a `distro` flag to `osbuild-pipeline`.
2019-11-27 17:08:51 +01:00
Tom Gundersen
de93ddc757 distro/f30: rework customizations
This slightly changes the customizations logic. We now make sure
that each stage is appended exactly once.

customizations.go are now responsible only for the things that are
completely generic, and not per-ouput-type. helpers.go contain more
high-level helpers that combine customziations and per-output-type
defaults.

This does not change the behaviour, though some pipelines are slightly
reordered to make them consistent.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-11-26 22:00:04 +01:00
Jacob Kozol
5fe42f13d7 blueprint: add change object for blueprints
Add a struct to store changes made to a blueprint. Each change contains
a commit which is a hex string based off of an sha1 hash, a message
describing the change, a revision which will usually be null, a
timestamp, and the blueprint at the time of the change.
2019-11-13 14:51:06 +01:00
Lars Karlitski
b33ed9e5d2 blueprint: move pipeline generation into its own package
Introduce the `distro` package, which contains an interface for OS
implementations. Its main purpose is to convert a blueprint to a
distro-specific pipeline.

Also introduce the `distro/fedora30` package. It is the first
implementation of the distro interface. Most of its code has been copied
with minimal modifications from the blueprint package.

The `blueprint` package is now back to serving a single purpose:
representing a weldr blueprint. It does not depend on the `pipeline`
package anymore.

Change osbuild-composer and osbuild-pipeline to use the new API,
hard-coding "fedora-30". This looks a bit weird now, but is the same
behavior as before.

All test cases now also take an "distro" key in the "compose" object.
2019-11-07 17:13:20 +01:00
Ondřej Budai
913dc8d6c9 blueprint: integrate customizations with all output types
Customizations are ready to be used, this commit enables them. There are still
some unresolved TODOs to be solved in future. Also, tests are missing.
2019-11-02 14:10:13 +01:00
Ondřej Budai
4b546f1bbf blueprint: don't create group with the same as one of the users 2019-10-31 21:51:02 +01:00
Ondřej Budai
dc359fca3a blueprint: add support for extra packages, "modules" and groups
"modules" because they're not actual modules. Currently, it's just
a synonym to packages. This is the same behavior as lorax-composer has.
2019-10-31 21:49:09 +01:00
Ondřej Budai
93e7a26785 blueprint: fix groups definition
Group has no version field, remove it.
2019-10-31 21:49:09 +01:00
Ondřej Budai
705338c5b3 blueprint: add support for unencrypted passwords in user customization 2019-10-31 21:46:39 +01:00
Lars Karlitski
e7ae3b4c47 test: move image-info tests to test/
These tests (will) test more than just image-info: they'll take a
blueprint, verify that `osbuild-pipeline` generates the correct
pipeline, run osbuild with that pipeline and verify that the resulting
image has the expected image-info output.

This change only includes the latter half (i.e., only moves the already
existing tests).

Also drop python's unittest. It was hard to control output (important
for quickly spotting failures and to make travis happy). This introduces
test/run, which runs all test cases in test/cases or the ones given on
the command line.

When a failure occurs, it prints a diff of the actual and the expected
image info.
2019-10-30 01:25:44 +01:00
Lars Karlitski
fabd40da1c blueprint: always run selinux stage last
A few output types had it before the fix-bls stage.
2019-10-29 16:01:37 +01:00
Lars Karlitski
6a6144c2d9 blueprint: always exclude the rescue kernel
Its BLS entry always expects a separate boot partition. Skip it on all
images until the rescue kernel package is usable.
2019-10-29 16:01:37 +01:00
Lars Karlitski
930347c56e blueprint: move vmdk towards lorax parity
The main difference (according to image-info) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.

Also, lorax generates an image with a separate /boot partition. This is
not yet addressed here, because osbuild doesn't support it yet.
2019-10-29 16:01:37 +01:00
Lars Karlitski
cde1325bc3 blueprint: move tar towards lorax parity
The main difference (according to `rpm -qa`) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.
2019-10-29 16:01:37 +01:00
Lars Karlitski
d4e1ecea7e blueprint: move partitioned-disk towards lorax parity
The main difference (according to image-info) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.

Also, lorax generates an image with a separate /boot partition. This is
not yet addressed here, because osbuild doesn't support it yet.
2019-10-29 16:01:37 +01:00
Lars Karlitski
fe46fd3a89 blueprint: move ext4-filesystem towards lorax parity
The main difference (according to image-info) is an additional package
containing a gpg key which was used to verify packages. The one
generated by lorax-composer doesn't have this, because it doesn't verify
signatures.
2019-10-29 16:01:37 +01:00
Tom Gundersen
8c0561c054 blueprint/test: express test-cases in json
A test case is now expressed purely by dropping in a json document in
`tools/test_image_info/pipelines`. It should contain the input compose
(output format and blueprint) as well as the expected pipeline. All the
existing tests are moved over to this format.

This shares the same infrastructure as the image tests, ideally we want
to run the blueprint tests and the image tests against the same pipelines.

For now, test cases are skipped from the blueprint tests if they do not
contain a 'compose' section, and from the image tests if they do not
cotain an 'expected' section. In the future we may want to make both
mandatory.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-28 17:32:45 +01:00