CentOS Stream 9
Sponsored Link

OpenStack Yoga : イメージを登録する2022/06/09

 
Glance に イメージの登録をします。
例として、CentOS Stream 9 のイメージを作成して Glance へ登録します。
[1]
[2] Glance サービス稼働ホストで CentOS Stream 9 のイメージを作成します。
CentOS Stream 9 のインストール用 ISO イメージは前もって任意のディレクトリへダウンロードしておきます。
# ディスクイメージ格納ディレクトリ作成

[root@dlp ~(keystone)]#
mkdir -p /var/kvm/images
# ディスクイメージ作成

[root@dlp ~(keystone)]#
qemu-img create -f qcow2 /var/kvm/images/centos-st9.img 10G
# インストール

[root@dlp ~(keystone)]#
virt-install \
--name centos-st9 \
--ram 4096 \
--disk path=/var/kvm/images/centos-st9.img,format=qcow2 \
--vcpus 2 \
--os-variant centos-stream9 \
--network network=default \
--graphics none \
--console pty,target_type=serial \
--location /home/CentOS-Stream-9-latest-x86_64-dvd1.iso \
--extra-args 'console=ttyS0,115200n8'
Starting install...
# 仮想マシン起動後、ログインして最低限必要な設定を適用

CentOS Stream 9
Kernel 5.14.0-101.el9.x86_64 on an x86_64

Activate the web console with: systemctl enable --now cockpit.socket

localhost login: root

[root@localhost ~]#
useradd centos

[root@localhost ~]#
passwd centos
# 既存インターフェースは削除

[root@localhost ~]#
nmcli device

]DEVICE  TYPE      STATE      CONNECTION
enp1s0  ethernet  connected  enp1s0
lo      loopback  unmanaged  --
[root@localhost ~]#
nmcli connection del enp1s0

Connection 'enp1s0' (9aeaf811-32ea-31e4-9e4f-4e01c009c66b) successfully deleted.
[root@localhost ~]#
dnf -y install cloud-init openssh-server

[root@localhost ~]#
vi /etc/cloud/cloud.cfg
# 5行目 : パスワード認証での SSH ログインを許可したい場合は変更
ssh_pwauth:   1

# 57, 58行目 : デフォルトユーザーを追加した [centos] に変更
# [centos] にパスワード認証での SSH 認証を許可する場合は変更
system_info:
  default_user:
    name: centos
    lock_passwd: false

[root@localhost ~]#
systemctl enable cloud-init sshd

[root@localhost ~]#
shutdown -h now

[3] 作成したディスクイメージを Glance へ登録します。
[root@dlp ~(keystone)]#
openstack image create "CentOS-Stream9" --file /var/kvm/images/centos-st9.img --disk-format qcow2 --container-format bare --public

+------------------+-----------------------------------------------------------------------------+
| Field            | Value                                                                       |
+------------------+-----------------------------------------------------------------------------+
| container_format | bare                                                                        |
| created_at       | 2022-06-08T07:56:12Z                                                        |
| disk_format      | qcow2                                                                       |
| file             | /v2/images/1044ab46-c42b-4cf6-ab1f-aaeb011fb3b9/file                        |
| id               | 1044ab46-c42b-4cf6-ab1f-aaeb011fb3b9                                        |
| min_disk         | 0                                                                           |
| min_ram          | 0                                                                           |
| name             | CentOS-Stream9                                                              |
| owner            | 9c8b7457e8db4cbc995a767706804b70                                            |
| properties       | os_hidden='False', owner_specified.openstack.md5='', owner_specified.ope... |
| protected        | False                                                                       |
| schema           | /v2/schemas/image                                                           |
| status           | queued                                                                      |
| tags             |                                                                             |
| updated_at       | 2022-06-08T07:56:12Z                                                        |
| visibility       | public                                                                      |
+------------------+-----------------------------------------------------------------------------+

[root@dlp ~(keystone)]#
openstack image list

+--------------------------------------+----------------+--------+
| ID                                   | Name           | Status |
+--------------------------------------+----------------+--------+
| 1044ab46-c42b-4cf6-ab1f-aaeb011fb3b9 | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+
[4] インターネット上で配布されているディスクイメージを利用する場合は、ダウンロードしたものを登録すれば OK です。
[root@dlp ~(keystone)]#
wget http://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img
[root@dlp ~(keystone)]#
openstack image create "Ubuntu2204-Official" --file ubuntu-22.04-server-cloudimg-amd64.img --disk-format qcow2 --container-format bare --public

+------------------+-----------------------------------------------------------------------------+
| Field            | Value                                                                       |
+------------------+-----------------------------------------------------------------------------+
| container_format | bare                                                                        |
| created_at       | 2022-05-31T01:21:20Z                                                        |
| disk_format      | qcow2                                                                       |
| file             | /v2/images/2c1c506d-53f7-4a19-8ac9-9fe20fc1cc5a/file                        |
| id               | 2c1c506d-53f7-4a19-8ac9-9fe20fc1cc5a                                        |
| min_disk         | 0                                                                           |
| min_ram          | 0                                                                           |
| name             | Ubuntu2204-Official                                                         |
| owner            | 0609d3b3b398456187fb705ec9224c4a                                            |
| properties       | os_hidden='False', owner_specified.openstack.md5='', owner_specified.o..... |
| protected        | False                                                                       |
| schema           | /v2/schemas/image                                                           |
| status           | queued                                                                      |
| tags             |                                                                             |
| updated_at       | 2022-05-31T01:21:20Z                                                        |
| visibility       | public                                                                      |
+------------------+-----------------------------------------------------------------------------+
関連コンテンツ