{"id":17548795,"url":"https://github.com/lslezak/yast-container","last_synced_at":"2025-03-29T06:30:26.442Z","repository":{"id":73224603,"uuid":"490734699","full_name":"lslezak/yast-container","owner":"lslezak","description":"Experimental YaST management container","archived":false,"fork":false,"pushed_at":"2022-05-30T07:23:30.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T19:13:56.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lslezak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-10T14:32:42.000Z","updated_at":"2022-05-19T11:55:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"f59f1e09-3442-4fc7-ac5c-ea203245e3dd","html_url":"https://github.com/lslezak/yast-container","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lslezak%2Fyast-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lslezak%2Fyast-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lslezak%2Fyast-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lslezak%2Fyast-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lslezak","download_url":"https://codeload.github.com/lslezak/yast-container/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246149981,"owners_count":20731406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-21T02:44:01.472Z","updated_at":"2025-03-29T06:30:26.416Z","avatar_url":"https://github.com/lslezak.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Experimental YaST Management Container\n\n[![CI](https://github.com/yast/yast-container/actions/workflows/ci.yml/badge.svg)](\nhttps://github.com/yast/yast-container/actions/workflows/ci.yml)\n\nThis is a proof of concept (PoC) project for testing how to run YaST in\na container to manage the host system.\n\n## :warning: Warning :warning:\n\n**This is an experimental project, do not use it in production systems! It is\nrecommended to use a virtual machine for testing! There is a high risk of\nbreaking the system or data loss!**\n\n## Purpose\n\nThe goal of this project is to decrease the size of the system and to avoid\nunnecessary dependencies.\n\nUsing a separate container would also make upgrading the tools, libraries\nand languages easier, possibly without affecting the users. We could use a newer\nRuby in the YaST container and keep the old one in SLE/Leap for backward\ncompatibility.\n\n## Proof of Concept\n\n*Note: The built containers use the openSUSE Leap 15.4 system and should be used\nonly for managing openSUSE Leap 15.4 or SLE-15-SP4 systems!*\n\nYou can disable this product check by setting `VERSION_CHECK=0` environment\nvariable. Be very carful when doing this, use it on your own risk!!\n\n## Pre-requisites\n\nA container runtime is required to run YaST in a container. Both [podman](\nhttps://podman.io/) and [Docker](https://www.docker.com/) are supported.\n\n### Podman\n\nNote: Podman is automatically recommended by the `yast-in-container` package.\n\n```shell\n# install the package\nzypper install podman\n```\n\n### Docker\n\nAlternatively the scripts can use [Docker](https://www.docker.com/) for\nmanaging and running containers.\n\n```shell\n# install the package\nzypper install docker\n# enable and start the Docker service\nsystemctl enable docker\nsystemctl start docker\n```\n\nIf you want to use Docker as a non-root user you can add yourselves into the `docker`\nuser group. *(Security note: Be careful, such users become equivalent to `root`!)*\n\n## Installing the Scripts\n\nThe scripts can be installed either from YaST OBS YaST:Head repository or can be\nstarted directly from the Git sources.\n\n```sh\n# add the YaST:Head repository\nzypper addrepo -f 'https://download.opensuse.org/repositories/YaST:/Head/openSUSE_Leap_${releasever}/' YaST:Head\n# install the package\nzypper install yast-in-container\n# disable the repository to not accidentally install some other YaST packages\nzypper modifyrepo -d YaST:Head\n# run the script\nsudo /usr/sbin/yast2_container repositories\n```\n\n```sh\n# download the scripts\ngit clone https://github.com/yast/yast-in-container.git\ncd yast-in-container/src/scripts\n# run the script\nsudo ./yast2_container repositories\n```\n\n## Details\n\nThis repository provides two helper scripts, `yast_container` and\n`yast2_container`. The first runs the specified YaST module using text (ncurses)\nUI, the second one uses graphical UI (Qt), just like the usual `yast` and\n`yast2` scripts do.\n\nThe scripts download the container image from OBS and then run the specified\nYaST module in the container.\n\nThe container is automatically deleted after finishing YaST, if you want to\ninspect the container you have to start it manually.\n\n## Debugging\n\nIf you need to run a different command than YaST in the container for testing\npurposes you can specify it with the `CMD` environment variable.\n\n```sh\n# run shell for an interactive session instead of running YaST\nsudo CMD=bash /usr/sbin/yast2_container\n```\n\nThe script prints the executed `podman` or `docker` command, if you need to\nrun the container with different options just copy\u0026paste the printed command\nto the terminal.\n\n## Tested Modules\n\nThis is a list of YaST modules which you can try with the testing image:\n\n- `yast2_container scc` - can register the system against SCC, RMT/SMT are also\n  supported, importing a self-signed SSL certificate works properly\n- `yast2_container repositories` - shows and edits the repositories from\n  the host system, should fully work\n- `yast2_container sw_single` - package installation works fine,\n  tha packages are correctly installed in the host system\n- `yast2_container key_manager` - displays the imported GPG keys\n  known by the package management\n\n## Implementation Details\n\n### Accessing the Host System\n\nThe host system is mounted to `/mnt` directory in the container. YaST must use\nthis subdirectory instead of the root directory for reading/writing files.\n\nBut that's usually not supported, esp. for modules designed to run only in\nan installed system.\n\n### Package Management\n\nLibzypp supports installing into a chroot directory, that's used during standard\ninstallation. That means the package management should work fine.\n\nBut the problem is that YaST needs to distinguish between the packages needed\nin the management container and the packages needed in the host system.\n\nFor example the partitioner suggests installing `btrfstools` package for handling\nBtrFs operations. But it should be enough to have that package in the container,\nit's not needed in the host.\n\nOn the other hand, configuring NetworkManager requires it in the host system\nso it can set the network after reboot.\n\nUnfortunately this distinction is missing in YaST...\n\n### Executing commands\n\nSimilarly to the package management, it is important to know where the executed\ncommand is available and where it needs to run.\n\n- Run the command in the container (e.g. `fdisk` can be used from a container\n  and does not need access to the host files)\n- Run it in the container and pass it `/mnt` option if that is possible so\n  it modifies the host system\n- Run it in the container but copy the result into the target system\n- Run it in the host system using `chroot` (but that requires the command to be\n  available in the host system)\n- Run the command using SSH, this would ensure it is fully executed in the host\n  system context, but that would require SSH to be installed and running.\n\n### Other Interactions with the System\n\nIt is a question which other interactions with the host system are possible\nor not. It turned out that even loading kernel modules works with\n`chroot /mnt modprobe \u003cmodule\u003e`...\n\n### Logging and Locking\n\nThe YaST log is written into `/var/log/YaST2/y2log` in the host as usually.\n\nThe libzypp lock (`/var/run/zypp.pid`) is also created in the hosts system,\nthis avoids running multiple instances of the package management at once.\n\n## Summary\n\nIt seems that it should be possible to fully manage the host system from\na container.\n\nHowever, the current YaST is not fully prepared for that. The adjustments seem to\nbe small but a lot of places would need to be updated. It should be similar\nto moving some configuration steps from the second installation stage\n(running in `/`) to the first stage (running in `/mnt`) as we did some time ago.\n\nAlso some YaST modules do not make sense in a containerized world,\nfor example the module for HTTP server. It is supposed that the HTTP server\nwould run in a separate container, possibly managed by other tools.\n\n## Links\n\n- https://github.com/yast/yast-ruby-bindings/pull/284 - automatic chroot support\n  in the YaST starting script\n- https://github.com/yast/yast-yast2/pull/1258 - automatically set the target\n  system location when chrooted\n- https://github.com/yast/yast-registration/pull/577 - adapt the registration\n  module to run in a chroot\n- https://github.com/yast/yast-packager/pull/621 - adapt the repository and package\n  management modules to run in a chroot\n- https://build.opensuse.org/package/show/YaST:Head/yast-mgmt-ncurses-leap_latest - this\n  OBS project builds the base container image with ncurses UI\n- https://build.opensuse.org/package/show/YaST:Head/yast-mgmt-qt-leap_latest - this\n  OBS project extends the ncurses container image with Qt and X libraries so it can\n  run the graphical UI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flslezak%2Fyast-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flslezak%2Fyast-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flslezak%2Fyast-container/lists"}