Commit graph

111 commits

Author SHA1 Message Date
Antonio Murdaca
ed4d12fe33 ignition: enable systemd firstboot condition through kargs
This is a workaround to make the systemd believe it's firstboot
when ignition runs on real firstboot.
Right now, since we ship /etc/machine-id, systemd thinks it's not firstboot
and ignition depends on it to run on the real firstboot to enable services from presets.
Since this only applies to artifacts with ignition and changing machineid-compat at
commit creation time may have undesiderable effect, we're doing it here as a stopgap.
We may revisit this in the future.
This patch also pins the version of osbuild because it depends on a fix
for the ignition stage.

Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-02-28 18:35:45 +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
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
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
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
Tomáš Hozza
2e54557cd4 osbuild/copy: support files input
Add support for files input in the copy stage. This will enable copying
inline sources as a custom files in the image filesystem tree.

Add a simple unit test covering the use of this stage input.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
772a131d35 osbuild/copy: add TODO comment related to GenCopyFSTreeOptions()
The `GenCopyFSTreeOptions()` function has unused argument
`inputPipeline`. After discussing this with @achilleas-k, we determined
that it would be for the best to refactor this function and split out
the part that generates Mounts and Devices and instead return the actual
Stage from it. The reason for splitting out Mounts and Devices is that
these are then reused also by other stages when constructing pipelines
inside composer.

This would be a bigger change, so just adding the comment to the code to
capture this future work.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Brian C. Lane
d12447408b Change RepoConfig.GPGKey to an array of key strings
DNF supports more than one GPG key. It is possible that one may be used for
signing packages, and another to sign the repository metadata. This
renamed GPGKey to GPGKeys internally. It does not change the on-disk
repository json format.
2023-02-01 10:27:58 +01:00
Tomáš Hozza
1667e6e859 osbuild: rework RPM stage inputs
Rework the stage to not reimplement `FilesInput` as
`RPMStageInput`, but instead use the one common
`FilesInput` implementation and its supported
references.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00
Tomáš Hozza
b25e4bfa8b osbuild: rework Ignition stage inputs
Rework the stage to not reimplement `FilesInput` as
`IgnitionStageInput`, but instead use the one common
`FilesInput` implementation and its supported
references.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00
Tomáš Hozza
645956d203 osbuild: rework QEMU stage inputs
Rework the stage to not reimplement `FilesInput` as `QEMUStageInput`,
but instead use the one common `FilesInput` implementation and its
supported references.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00
Tomáš Hozza
3f90a32661 osbuild: rework FDO stage inputs
Rework the stage to not reimplement `FilesInput` as
`FDOStageInput`, but instead use the one common
`FilesInput` implementation and its supported
references.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00
Tomáš Hozza
dd59ce6a16 osbuild: rework XZ stage inputs
The `FilesInputs` was since the beginning an XZ-specific implementation
of the input, but it was implemented in the `files_input.go` in a false
hope that it could be used as a generic stage inputs by any stages. It
turned out that various stages require different implementation of
its input. Specifically there is usually a stage-specific key, which has
assigned a common input type. For XZ stage, the key is `file`.

Remove `FilesInputs` and instead implement `XzStageInputs` which is now
accepted by the XZ stage.

Fix all affected pipeline implementations that use XZ stage.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00
Tomáš Hozza
413538a18e osbuild: rework files input
Rework files input implementation to support all reference types
supported by the input schema. Also implement helper functions to
generate supported reference types. In some cases, the reference
supports e.g. referencing multiple pipelines in the stage inputs, but
this is currently not implemented, since no pipeline in composer uses
it.

Rework the files input unit tests to cover the new functionality.

Adjust all code affected by the changes made to files input.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-30 11:24:08 +01:00
Tomáš Hozza
8d0f2d7e79 osbuild/mkdir: make Mode a pointer
The default value for the `os.FileMode` is zero, but the actual default
value used by the stage if no value is specified in the options is
`0777`. By using the pointer, we'll allow one to specify `0000`
permissions as a value which won't be omitted from the stage options.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-19 11:15:33 +01:00
Tomáš Hozza
c1c26b2817 osbuild/mkdir: support exist_ok stage option
Add support for `exist_ok` stage option added as part of
PR#1224 [1], which allows to gracefully handle existence of a directory
path specified to the stage.

This will be helpful when creating custom directories in the image via
customizations, because one can't know in advance whether the directory
path won't be created by a package installed in the image.

Not bumping the requires on osbuild, because this new option is not yet
used by any image definition or customization.

[1] https://github.com/osbuild/osbuild/pull/1224

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-19 11:15:33 +01:00
Tomáš Hozza
7021c305e2 osbuild/mkdir: support parents stage option
The stage supports a `parents` property in stage path options, which
allows one to auto-create any parent directories as needed.

Add the property to stage options implementation.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-19 11:15:33 +01:00
Tomáš Hozza
5ff2f997f6 osbuild/mkdir: fix copy&paste error in function comment
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-19 11:15:33 +01:00
Tomáš Hozza
30c3ea791e osbuild/mkdir: rename Path struct to MkdirStagePath
The plain `Path` name was a bit unfortunate, since it was specific to
the `mkdir` stage, but it was used outside of the `osbuild` package as
`osbuild.Path` which was making a wrong impression of it being a generic
path structure. This is not true.

Rename the structure to contain the stage name.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-01-19 11:15:33 +01:00
Antonio Murdaca
cca0e773f6 support ignition in edge simplified-installer and raw-image
Signed-off-by: Antonio Murdaca <runcom@linux.com>
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
Signed-off-by: Irene Diez <idiez@redhat.com>
Co-authored-by: Irene Diez <idiez@redhat.com>
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-01-17 14:02:02 +01:00
Ondřej Budai
b997142db0 common: merge all *ToPtr methods to one generic ToPtr
After introducing Go 1.18 to a project, it's required by law to convert at
least one method to a generic one.

Everyone hates IntToPtr, StringToPtr, BoolToPtr and Uint64ToPtr, so let's
convert them to the ultimate generic ToPtr one.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-01-09 14:03:18 +01:00
Irene Diez
76728818c9 internal/distro/rhel9: handle ignition.embedded for edge
Signed-off-by: Irene Diez <idiez@redhat.com>
2022-12-15 11:34:17 +00:00
Achilleas Koutsou
a0528d2e53 osbuild: remove 'users' boolean argument from NewAnacondaStageOptions()
Drop the argument altogether.
2022-12-13 20:33:27 +00:00
Irene Diez
6cb8216f09 internal: update firewall stage to allow zones
Updates firewall stage customizations to allow zones
as per the changes made on osbuild/osbuild#1157

Relevant tests and pipelines for rhel8+9 updated.

Signed-off-by: Irene Diez <idiez@redhat.com>
2022-12-06 16:39:00 +01:00
Antonio Murdaca
80a6b1bd23 Extend firewall customizations to add sources
Signed-off-by: Antonio Murdaca <runcom@linux.com>
Co-authored-by: Irene Diez <idiez@redhat.com>
2022-12-06 16:39:00 +01:00
Sayan Paul
5ce3de214d build:create systemd_journald stage
Creates new stage to configure
journald to persist the journal.
Instead of creating the `/var/log/journal`
directory we explicitly configure journald
via the new stage.This is done in
according to the FCOS norms.
Unit tests also added for functionality
check.

Co-authored-by: Irene Diez <idiez@redhat.com>
Signed-off-by: Sayan Paul <saypaul@redhat.com>
2022-12-06 12:15:09 +01:00
Achilleas Koutsou
8c75975917 osbuild: add masked services to systemd stage 2022-12-02 19:04:26 +00:00
Achilleas Koutsou
5d760c48ad osbuild: remove Timeservers slice from chrony stage
The org.osbuild.chrony stage was extended to allow additional directives
alongside time servers [1].  The old Timeservers string slice was kept
for backwards compatibility.  Removing support for it in
osbuild-composer makes working with the stage's options simpler.  Using
the new struct slice Servers field and only specifying a Hostname for
each element is equivalent to the old behaviour, so no functionality is
lost.

This simplifies the chrony stage since no validation is required
anymore.
It also simplifies the propagation of configuration options through the
pipeline generation code which doesn't need to check for both types of
stage options.

[1] https://github.com/osbuild/osbuild/pull/692
2022-11-28 17:20:49 +01:00
Simon de Vlieger
d4d100383e image: create installer image types for fedora
This adds the `fedora-image-installer` and
`fedora-image-installer-preview` images.

The image installer type installs anaconda-webui on Fedora >= 38 to use
the new UI. It also writes its setting to
`/usr/share/anaconda/interactive-defaults.ks` as the current
anaconda-webui has not yet been tested in kickstart mode.

To do so manifest.Anaconda was expanded to take a (subset) of options
for a KickstartStage which is will write into interactive-defaults.ks.
And to take a list of additional modules to enable, so we can set up
Anaconda with all default modules.
2022-11-21 09:45:26 +01:00
Sanne Raymaekers
500341a25f internal/osbuild: contenturl and rhsm secrets for ostree sources 2022-10-28 16:14:30 +02:00
Achilleas Koutsou
abdddc6e55 osbuild: fix gpgkeys json key in ostree source 2022-10-12 03:07:40 +02:00
Achilleas Koutsou
1324f7fb8c osbuild: simplify copy stage test 2022-10-11 10:00:22 +02:00
Achilleas Koutsou
c6b999f178 ostree: rename CommitSource to CommitSpec and add Ref
The CommitSource was used to specify the source URL and checksum of a
commit for use in manifest sources.  Renaming to CommitSpec and adding a
Ref parameter generalises the type so that we can use it to specify
commits in various situations.  This is building towards separating when
ostree parameters are used for fetching a commit, fetching a parent
commit, and building one.

The CommitSpec is (very roughly) analogous to the rpmmd.PackageSpec.
2022-10-11 10:00:22 +02:00
Achilleas Koutsou
14f608de0a osbuild: use internal users package structs in stages
Don't pass blueprint Users and Groups options all the way down to the
osbuild stage bindings.  Instead, convert them to the internal
users.User and users.Group structs.
Ideally we would do this even higher up in the code path, before
reaching the distro, but this is the first step towards that.
2022-09-29 18:09:38 +02:00
Achilleas Koutsou
c0fcbfc5c2 osbuild: add isolinux stage
Add support for the org.osbuild.isolinux stage.
2022-09-29 18:09:38 +02:00
Achilleas Koutsou
204b4177ec osbuild: add squashfs stage
Add support for the org.osbuild.squashfs stage.
2022-09-29 18:09:38 +02:00
Achilleas Koutsou
3d772b6846 osbuild: simplify and unify tree stage inputs
- Remove stage-specific input types when they are org.osbuild.tree input
  types.
- Use PipelineTreeInputs when stage requires a single tree input
  reference with an arbitrary key.
- For Stages that require a specific key with a tree input, make the key
  part of the NewXStage() function and only allow specifying the name of
  the pipeline from which to copy the tree as part of the function
  arguments.
2022-09-29 18:09:38 +02:00
Achilleas Koutsou
ca0175c82b osbuild: function for creating named pipeline tree inputs
Convenience function for creating a map with a single input pointing to
a pipeline's tree with a given key.
Different stages use different keys in the map (often "tree").
Functions will be added for each stage to create a map with the
appropriate key when necessary.
2022-09-29 18:09:38 +02:00
Achilleas Koutsou
58966e4b13 osbuild: fix tree input schema
The references field in org.osbuild.tree inputs currently supports one
of three forms, all of which are functionally equivalent:
- Array of one string
- Array of one object with key "id" and string value
- Single object with no properties (only key/name)

We use the first form which is the simplest.

The string should refer to a pipeline by name (as name:<pipelinename>),
which means the input refer to the final tree of the named pipeline.
2022-09-29 18:09:38 +02:00
Irene Diez
0f8ed4e04b distro/rhel90: edge images default to LVM
Change partition tables on edgeBase images to use
'LVM partitioning'. We need to ensure that LVM
stages are done before LUKS stages (e.g. remove-key)
or the pipelines will break (we cannot open a device
when its password has changed).

Add relevant tests on device_test.go plus a new
test partition table on common_test.go
2022-09-22 10:20:27 +02:00
Achilleas Koutsou
86d9611f98 osbuild: generator functions for UsersStage and GroupsStage
Generators for creating UsersStage and GroupsStage from the new internal
types.
These are almost identical to the existing stage option creation
functions.  Those will be removed once every use is replaced with the
new generators.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0b3bfd0d02 osbuild: update rpm stage with new options
- db path: set alternative rpm database path [1]
- ostree-booted: create the /run/ostree-booted marker which marks an
  install as ostree.  Install-time scripts in packages use this marker
  to treat ostree installations differently.

[1] https://github.com/osbuild/osbuild/pull/666
[2] https://github.com/osbuild/osbuild/pull/1085
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0750049739 osbuild: update org.osbuild.ostree.remotes stage
New options added to stage in osbuild [0].

[0] https://github.com/osbuild/osbuild/pull/1097
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0ff1c3241c osbuild: add mount ostree helper method to Stage
A convenience method that adds an ostree deployment mount to any Stage.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
4a68df45c7 osbuild: add ostree.deployment mount type
New mount type added: org.osbuild.ostree.deployment.

Adding this to a stage will setup all needed bind mounts so that a given
`tree` will look like an active OSTree deployment, very much as OSTree
does during early boot.

This is often necessary when making changes to files in /etc for an
ostree image.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
7246f8fdd5 osbuild: fix base Mount struct properties
Source and Target are not required -> omitempty
Options is of type MountOptions which is an interface, so we don't need
to make it a pointer.
2022-09-13 16:06:19 +01:00
fkolwa
1fbdb21f6b internal/osbuild: Add GCP guest-agent conf stage
Add GCP guest-agent conf stage test
2022-08-30 22:21:29 +02:00
Simon de Vlieger
c5f335bceb Add the rhsm.facts stage.
We initially provide a Facts file that stores the `ApiType`. This is the
API that was used to request the compose.
2022-08-25 18:56:35 +02:00
Gianluca Zuccarelli
512cbd6089 osbuild: new stage oscap remediation 2022-08-04 18:19:06 +02:00