Adicionando extensões de sistema operacional ao sistema hospedeiro

O Fedora CoreOS mantém a imagem base tão simples e pequena quanto possível por razões de segurança e manutenção. É por isso que você deve, em geral, preferir o uso de contêineres podman em vez de software de camadas.

No entanto, em alguns casos, é necessário adicionar software ao próprio sistema operacional de base. Por exemplo, drivers ou software VPN são candidatos potenciais porque são mais difíceis de colocar em contêineres.

Para fazer isso, você pode usar rpm-ostree install. Considere esses pacotes como "extensões": eles estendem a funcionalidade do sistema operacional básico em vez de, por exemplo, fornecendo tempos de execução para aplicativos de usuário. Dito isso, não há restrições sobre quais pacotes alguém pode realmente instalar. Por padrão, os pacotes são baixados de repositórios do Fedora.

To start the layering of a package, you need to write a systemd unit that executes the rpm-ostree command to install the wanted package(s). By default, with rpm-ostree install, changes are queued for the next boot. The -A/--apply-live option can be used to apply changes live and have them persist.

Example: Layering vim and setting it as the default editor

Fedora CoreOS includes both nano and vi as text editors, with the former set as default (see the corresponding Fedora change).

This example shows how to install the fully fledged vim text editor and how to set it up as default for all users by setting up the required configuration in /etc/profile.d/.

No futuro, teremos um método de Ignition mais amigável para fazer isso com garantias mais fortes. Veja os problemas do upstream butane#81 e fedora-coreos-tracker#681 para obter mais informações.
variant: fcos
version: 1.5.0
systemd:
  units:
    # Installing vim as a layered package with rpm-ostree
    - name: rpm-ostree-install-vim.service
      enabled: true
      contents: |
        [Unit]
        Description=Layer vim with rpm-ostree
        Wants=network-online.target
        After=network-online.target
        # We run before `zincati.service` to avoid conflicting rpm-ostree
        # transactions.
        Before=zincati.service
        ConditionPathExists=!/var/lib/%N.stamp

        [Service]
        Type=oneshot
        RemainAfterExit=yes
        # `--allow-inactive` ensures that rpm-ostree does not return an error
        # if the package is already installed. This is useful if the package is
        # added to the root image in a future Fedora CoreOS release as it will
        # prevent the service from failing.
        ExecStart=/usr/bin/rpm-ostree install --apply-live --allow-inactive vim
        ExecStart=/bin/touch /var/lib/%N.stamp

        [Install]
        WantedBy=multi-user.target
storage:
  files:
    # Set vim as default editor
    # We use `zz-` as prefix to make sure this is processed last in order to
    # override any previously set defaults.
    - path: /etc/profile.d/zz-default-editor.sh
      overwrite: true
      contents:
        inline: |
          export EDITOR=vim