本文將介紹如何構建定製化系統,使用命令和瀏覽器建立系統鏡像
Image Builder能夠建立RHEL定製系統,經過模板定義文件構建本身須要的系統鏡像,Image Builder能夠經過Composer-cli命令行工具來構建鏡像,也能夠經過web console使用圖形化界面操做。
Image Builder以系統服務lorax-composer運行,能夠經過Image Builder構建出多種格式的系統鏡像,好比iso,tar,img,vmdk等。html
首先添加RHEL8的DNF軟件源linux
wget -O /etc/yum.repos.d/rhel-9-beta.repo https://mirrors.tuna.tsinghua.edu.cn/redhat/rhel/rhel-8-beta/rhel-8-beta.repo
經過vim修改源文件web
:%s/enabled=0/enabled=1/g
$ dnf clean all $ dnf makecache
修改/etc/selinux/config爲disabledshell
$ yum install lorax-composer composer-cli cockpit-composer bash-completion
配置開機啓動vim
$ systemctl enable lorax-composer.socket $ systemctl enable cockpit.socket
配置防火牆瀏覽器
$ firewall-cmd --add-service=cockpit && firewall-cmd --add-service=cockpit --permanent
加載命令行補全bash
$ source /etc/bash\_completion.d/composer-cli
如今composer-cli命令行工具就能夠使用了app
imagebuilder的工做流以下:composer
1.建立模板blueprint定義文件ssh
name = "BLUEPRINT-NAME" description = "LONG FORM DESCRIPTION TEXT" version = "0.0.1" modules = [] groups = [] [[packages]] name = "package-name" version = "package-version" [[customizations.user]] name = "USER-NAME" description = "USER-DESCRIPTION" password = "PASSWORD-HASH" key = "ssh-rsa (...) key-name" home = "/home/USER-NAME/" shell = "/usr/bin/bash" groups = ["users", "wheel"] uid = NUMBER gid = NUMBER [[customizations.kernel]] append = "nosmt=force"
blueprint是以TOML格式定義的,能夠有許多定製選項,imagebuilder會根據blueprint中的定義來構建系統。
2.將模板文件保存爲BLUEPRINT-NAME.toml
3.使用命令行工具導入blueprint
$ composer-cli blueprints push BLUEPRINT-NAME.toml
4.查看已導入的blueprint
$ composer-cli blueprints list
5.檢查組件依賴
$ composer-cli blueprints depsolve BLUEPRINT-NAME
6.檢查blueprint內容
$ composer-cli blueprints show BLUEPRINT-NAME
7.列出支持的輸出類型
$ composer-cli compose types
8.開始構建
$ composer-cli compose start BLUEPRINT-NAME IMAGE-TYPE
IMAGE-TYPE爲支持的輸出類型
9.查看構建進度
$ composer-cli compose status
10.構建完成後導出鏡像
$ composer-cli compose image UUID
鏡像存放路徑爲/var/lib/lorax/composer/results/UUID/
其餘命令:
導出blueprint
$ composer-cli blueprints save BLUEPRINT-NAME
刪除blueprint
$ composer-cli compose delete BLUEPRINT-NAME
取消正在進行中的構建
$ composer-cli compose cancel COMPOSE-UUID
刪除已完成的構建
$ composer-cli compose delete COMPOSE-UUID
由於imagebuilder是以服務運行,所以默承認以經過本地瀏覽器訪問
https://localhost:9090/
經過web頁面的可視化操做能夠達到經過命令操做一樣的效果。
Image Builder on Red Hat Enterprise Linux 8