Commit graph

71 commits

Author SHA1 Message Date
Ondřej Budai
3a0a480792 stages: Drop the remove-uniqueness stage
We don't need this stage anymore, random-seed has never been in
the tree and machine-id is now handled by dnf stage.
2019-09-26 23:47:33 +02:00
Ondřej Budai
fd8eb9492f stages/dnf: Remove random seed after dnf run
Some dnf packages introduce random seed file. If we leave in the tree
it would mean all systems running from the created image would use
the same random seed. This can be potentially dangerous, therefore we
just remove the generated random seed from our images.
2019-09-26 23:47:33 +02:00
Ondřej Budai
cc73fa5d10 stages/dnf: Improve dnf stage reproducibility
Normally, machine ID is generated randomly when dnf installs @Core
group. Unfortunately this isn't helping us with reproducibility
of images.

This commit introduces the concept of fake machine ID. Before dnf
command is run in dnf stage, we set the machine ID to a fake one.
This ensures all the scriptlets requiring machine ID have predictable
outputs.

For example GRUB uses machine-id in file names inside
/boot/loader/entries. With fixed machine ID the file names are always
the same and totally predictable.
2019-09-26 23:47:33 +02:00
Lars Karlitski
3009b9255f stages: remove org.osbuild.anaconda
We haven't used or tested it.
2019-09-24 20:17:04 +02:00
Lars Karlitski
bbe4129f36 stages/dnf: remove dnf cache directory
The repository used to install the image might be unrelated to any
repository that's ever used on a system running that image.
2019-09-24 20:17:04 +02:00
Lars Karlitski
57c82a00d0 stages/dnf: verify repository checksum
Require "checksum" option for each repository, which contains the
checksum of the `repodata/repomd.xml` file. This file (indirectly)
contains checksums for all packages.

Verify that the metadata dnf downloaded to install packages matches that
checksum. This way, this stage will give an error when a reposiory
changed between putting together the pipeline and running it.
2019-09-24 20:17:04 +02:00
Lars Karlitski
e23b5a32a2 stages/yum: only write known options to repo file
This is similar to the previous commit for the dnf stage.

Don't pass through arbitrary options. This means that pipeline repo
objects don't have the same options as yum repo files anymore:

1. Hard code repo name to repo id. The name has no influence on the
resulting image and should thus not appear in a pipeline.

2. Set gpgcheck=1 when gpgkey is given. It defaults to false, which
means that all sample and test pipelines didn't verify packages. It
would have failed anyway, because the container doesn't have the key
referenced in /etc. Change all gpgkeys to refer to the key id and import
them manually.

3. Don't allow lists for baseurl and gpgkey. We can add that if we need
it at some point.

Also be less verbose.
2019-09-24 20:17:04 +02:00
Lars Karlitski
0dd939b658 stages/dnf: only write known options to repo file
Don't pass through arbitrary options. This means that pipeline repo
objects don't have the same options as dnf repo files anymore:

1. Hard code repo name to repo id. The name has no influence on the
resulting image and should thus not appear in a pipeline.

2. Set gpgcheck=1 when gpgkey is given. It defaults to false, which
means that all sample and test pipelines didn't verify packages. It
would have failed anyway, because the container doesn't have the key
referenced in /etc. Change all gpgkeys to refer to the key id and import
them manually.

3. Don't allow lists for baseurl and gpgkey. We can add that if we need
it at some point.
2019-09-24 20:17:04 +02:00
Lars Karlitski
93da5caa69 stages/dnf: add mandatory basearch argument
We've been effectively using the basearch of the host, making the stage
non-reproducible: if the same pipeline was run on machines with
different architectures, it would produce different results. However,
pipelines producing different outputs must be different. Thus, this
patch includes the basearch in the pipeline.

In principle, this allows cross-arch builds. dnf should be the only
stage running binaries from the target tree. This is not yet tested.
2019-09-24 20:17:04 +02:00
Lars Karlitski
cd59b94ded tree-wide: always explicitly pass check to subprocess.run
pylint recently started recommending this.
2019-09-24 20:17:04 +02:00
Martin Sehnoutka
27bbb02265 make firewall options optional
there is no need to require all arguments in the firewall stage, so
let's reflect this in the code
2019-09-10 15:40:13 +02:00
Ondřej Budai
7fabcfe333 stages/locale: Refactor locale stage to look like similar ones
The locale stage now cannot be used to set the keymap. Use the keymap
stage instead. Also, the stage was refactored to look like keymap and
timezone stages just to be consistent (systemd-firstboot is now used).
2019-09-10 09:22:26 +02:00
Ondřej Budai
57bdfef754 stages/ansible: Drop the ansible stage
We use chroot connection type to "connect" to the target filesystem
where ansible should run the playbook. However, the target is not booted
system, it's just an image of not-yet-booted one. Unfortunately, many
ansible modules cannot be used inside not-booted system. Also, the core
principle of osbuild is to never boot the currently built image.
Therefore we decided to remove the ansible stage.

If ansible is needed in the future, there is a possibility to add a new
ansible stage, which would run the playbook during the first boot.
2019-09-09 09:11:52 +02:00
Tom Gundersen
fc838a8e20 stages: add test stage
Adds a new systemd unit to the image that will be pulled in by default,
run a given command, forward the output to a virtio serial port and
shutdown the machine.

We add a sample that uses this to verify that systemd conciders the
machine successfully booted. A simple way to run this test from the
commandline is to use
  `$ socat UNIX-LISTEN:qemu.sock -`
to listen for either `running` for success or `degraded` or
`maintenance` for failure.

The image should then be booted using something like
  `$ qemu-kvm -m 1024 -nographic -monitor none -serial none -chardev socket,path=qemu.sock,id=char0 -device virtio-serial -device virtserialport,chardev=char0,id=test0 -snapshot  base.qcow2`

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-29 10:25:15 +02:00
Tom Gundersen
a914627c89 stages: add debug shell
This gives shell access into the image on a given tty. Useful for
testing and debugging, while minimally affecting the image.

Note that this must never be used in production, as it allows root
access without a password.

For instance this could be used to verify that an image was fully
booted:

```
[teg@teg-x270 osbuild]$ qemu-kvm -m 1024 -nographic -serial mon:stdio -snapshot  base.qcow2
sh-5.0# systemctl is-system-running --wait
running
```

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-27 23:32:04 +03:00
Tom Gundersen
5854ceea42 stages/grub2: make booting in ro/rw mode configurable
Move the decision whether the root fs should be mounted ro or rw
into the pipeline configuration.

Update the pipelines accordingly.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Tom Gundersen
17d562e75f stages/fstab: add a stage to specify the fstab to be installed
This will allow us to boot in 'ro' mode, and remount later on.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Tom Gundersen
9af32f1aae stages/dnf: make install_weak_deps optional
Default to True, which is what dnf defaults to, but allow it to be
overridden in the pipeline. Whether this option should be used should
be a distro policy, but for now we just want it to get images compatible
with the official fedora ones.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Tom Gundersen
b348d858b8 stagse/dnf: don't make verbosity configurable
We don't want non-functional configuration in the pipelne, we want to
restrict ourselves to options that changes the final image.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-08-26 09:25:42 +03:00
Lars Karlitski
f54fbe2912 stages/fix-bls: add workaround for grub2-mkrelpath
grub2-mkrelpath uses /proc/self/mountinfo to find the source of the file
system it is installed to. This breaks in a container.

Add org.osbuild.fix-bls which goes through /boot/loader/entries and
fixes paths by removing anything before /boot.
2019-08-15 09:43:28 +03:00
Lars Karlitski
29c396584f stages/dnf: use nspawn's vfs tree
dracut stumbled over the one we set up (errors about not being able to
access /dev/kmsg). Use the one that systemd-nspawn sets up instead.
2019-08-14 13:49:27 +02:00
Martin Sehnoutka
c27cdd5928 introduce hostname stage
this stage will set /etc/hostname in the image. it uses
systemd-firstboot to perform the change
2019-08-13 13:24:36 +02:00
Lars Karlitski
4c91a23e98 stages/org.osbuild.users: manage users
This stage allows to add or modify users. For now, this includes all
fields available in passwd, setting auxiliary groups, and setting an ssh
key.

Based on a patch by Martin Sehnoutka <msehnout@redhat.com>.
2019-08-12 13:45:30 +02:00
Lars Karlitski
a394e975c1 stages/dnf: supress error from completion module
Disable the module. There's no need to update the completion databse in
the container.
2019-08-12 13:07:11 +02:00
msehnout
dc1466eeca
introduce firewall stage (#61)
as described in lorax documentation, we need to support raw
ports/protocols and services as defined by firewalld:
https://weldr.io/lorax/lorax-composer.html#customizations-firewall
2019-08-07 09:34:22 +02:00
Martin Sehnoutka
28e33c07ce introduce support for user-defined kernel options 2019-08-01 14:59:37 +02:00
Tom Gundersen
8b659ae638 travis: add a test for a yum-based pipeline
Travis uses Ubuntu, which does not ship dnf, so introduce a yum
stage that allows us to test actual generation of trees on Travis.

We use this to generate a tree containing the tools necessary to
create abritrary Fedora-based build images in the future. We base
this on Fedora 27, as that is the last version that is installable
using yum rather than dnf.

In the future, once we support pipelines with nested build-images,
rather than just using the host OS as the build image, this will
allow us to bootstrap arbitrary pipelines on Travis.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-31 01:34:31 +02:00
Martin Sehnoutka
0cf93934eb unify messages about files to be removed 2019-07-29 20:13:36 +02:00
Martin Sehnoutka
1ca4d8e6bb introduce keymap stage 2019-07-29 12:39:38 +02:00
Martin Sehnoutka
593c6de385 add timezone stage 2019-07-29 12:05:42 +02:00
Lars Karlitski
f4862457a3 rename io.weldr to org.osbuild (#39) 2019-07-26 09:40:55 +02:00
Tom Gundersen
a17ecd0fca stages/assemblers: symlink the osbulid python library
This way the assemblers/stages are valid in isolation, even without
osbulid installed system-wide. This would be needed to have this work
when --libdir is not the system-wide one, as the library would
otherwise not be in sys.path.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-25 21:28:23 +02:00
Martin Sehnoutka
f04cb3836f fix warnings generated by pylint 2019-07-17 13:08:22 +02:00
Tom Gundersen
a428572382 stages/io.weldr.grub2: drop unused functions and options
Since we no longer use grub2-mkconfig, but write static configuration
we can drop most of the helpers.

The partitin table id was never used in the first place. We use
filesystem UUIDs, not partition UUIDs to name our root/boot partitions.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-11 15:01:44 +02:00
Martin Sehnoutka
5ca90dc052 mount filesystems as rw
d-bus service was unable to start with the previous setup
2019-07-09 10:29:48 +02:00
Martin Sehnoutka
9ea6150ee7 introduce disabled services into the systemd stage 2019-07-09 10:29:48 +02:00
Lars Karlitski
34d620feea stages/dnf: don't use configparser to write dnf.conf
configparser writes strings with quotes and lists with enclosing
brackets, both of which may not appear in dnf.conf.

dnf.conf(5) defines the format loosely.
2019-07-08 14:22:25 +02:00
Tom Gundersen
cebed27cd9 osbuild: drop the concept of an input_dir
This removes the possibility of passing in arbitrary input data. We
now restrict ourselves to explicitly specified files/directories or
a base tree given by its pipeline id.

This drops the tar/tree stages/assemblers, as the tree/untree ones
are implicit in osbuild, and if we wish to also support compressed
trees, then we should add that to osbuild core as an option.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-03 13:11:37 +02:00
Tom Gundersen
9f5ce324b0 stages/grub2: use static grub.cfg/grubenv files
Afetr discussions with Javier Martinez Canillas and Alberto Ruiz
from the grub team, it was clear that we want move to a static
configuration shipped in the grub rpm in the future. For now,
we use our own, but the aim is to use the same as upstream.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-02 20:05:19 +02:00
Tom Gundersen
037f439d01 stages/grub2: fix defaults/grub
This file was missing new-lines.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-07-01 22:18:05 +02:00
Tom Gundersen
ecaed3bbfa stages/grub2: don't set up a partition table
We only need the filesystem with the correct fs-UUID to chroot into,
there is no need to set up a whole partition table.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-27 16:22:30 +02:00
Tom Gundersen
779e5c40ea stages/grub2: set default entry
Without a default and/or timeout set, grub refuses to boot.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-26 13:46:19 +02:00
Tom Gundersen
d9488e5f8b losetup: make sure image sizes are multiples of 512K sectors
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-26 12:57:20 +02:00
Tom Gundersen
b540eb5ee7 losetup: create and attach images to loopback devices in one operation
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-26 12:45:35 +02:00
Tom Gundersen
63a4f795dc stages/selinux: add an selinux stage
This stage labels the target tree based on an SELinux policy already
installed in the target.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-21 13:36:49 +02:00
Tom Gundersen
a428ff05ad assemblers/qcow2: move from the old stage and make it work again
Minor ajustments needed after we changed the internal API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 19:49:53 +02:00
Tom Gundersen
4742ae1e72 stages/locale: fix typo
Add missing quotes around a string.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 18:49:21 +02:00
Tom Gundersen
a2441bf112 stages/dnf: allow both operation and verbosity to be configurable
This is for the sake of debuggability, but I figure dnf is the most
complex of our tools, so instrumenting that a bit makes sense.

The defaults are "install" and "info", as before.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-19 16:08:29 +02:00
Tom Gundersen
4b69d02dc8 stages/systemd: minor fixes
We cannot use the tool from within the tree unless we chroot
(library versions ay be wring etc). If possible we want to
always use tools from the build image, in order to avoid forcing
the contenst of the target tree, so do that instead.

Finally, add a missing include.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-18 23:54:23 +02:00
Tom Gundersen
b38506a702 stages/dnf: allow other operations on the provided packages than 'install'
We would like to avoid 'upgrading', but let's allow it in the tools.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-06-18 23:53:27 +02:00