Aggiunta di estensioni OS al sistema host
Fedora CoreOS mantiene l’immagine di base il più semplice e piccola possibile per motivi di sicurezza e mantenibilità. Ecco perché, in generale, dovresti preferire l’uso dei container podman
piuttosto che aggiungere software stratificato. Tuttavia, in alcuni casi è necessario aggiungere software al sistema operativo di base. Ad esempio, i driver o il software VPN sono potenziali candidati perché sono più difficili da containerizzare e possono essere aggiunti come estensioni al sistema operativo.
Se stai apportando modifiche significative al sistema operativo di base, potresti invece considerare l’utilizzo di [Fedora Bootc](https://docs.fedoraproject.org/en-US/bootc/), che è orientato alla creazione di build personalizzate del sistema operativo partendo da un’immagine di base. Maggiori informazioni sulla relazione tra Fedora CoreOS e Fedora Bootc sono disponibili nel nostro FAQ. |
Per aggiungere software aggiuntivo a un sistema Fedora CoreOS, puoi utilizzare [rpm-ostree install
](https://coreos.github.io/rpm-ostree/). Considera questi pacchetti come "estensioni": estendono la funzionalità del sistema operativo base piuttosto che, ad esempio, fornire runtime per applicazioni utente. Detto questo, non ci sono restrizioni sui pacchetti che si possono effettivamente installare. Di default, i pacchetti vengono scaricati dai [repository di Fedora](https://docs.fedoraproject.org/en-US/quick-docs/repositories/).
Per iniziare il layering di un pacchetto, devi scrivere un’unità systemd che esegua il comando rpm-ostree
per installare i pacchetti desiderati. Le modifiche vengono applicate a un nuovo deployment ed è necessario un riavvio affinché abbiano effetto.
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/
.
In the future, we will have a more Ignition-friendly method of doing this with stronger guarantees. See upstream issues butane#81 and fedora-coreos-tracker#681 for more information. |
variant: fcos
version: 1.6.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 -y --allow-inactive vim
ExecStart=/bin/touch /var/lib/%N.stamp
ExecStart=/bin/systemctl --no-block reboot
[Install]
WantedBy=multi-user.target
storage:
files:
# Imposta vim come editor predefinito
# Usiamo il prefisso `zz-` per assicurarci che questo venga elaborato per ultimo
# in modo da sovrascrivere qualsiasi valore predefinito impostato in precedenza.
- path: /etc/profile.d/zz-default-editor.sh
overwrite: true
contents:
inline: |
export EDITOR=vim
Want to help? Learn how to contribute to Fedora Docs ›