This repo is to use Amazon Linux 2023 images for use with Openstack Cloud
There are few ways that I have tried to use the Amazon Linux 2023 image on Openstack cloud :
- First we need to download the Amazon Linux 2023 image for use with Kvm using the below link in the format qcow2
- Upload the qcow2 image to the image repository (glance) using the openstack dashboard or CLI
openstack image create --tag al2023 --disk-format qcow2 --container-format bare --file <al2023-kvm-2023.5.20240819.0-kernel-6.1-x86_64.xfs.gpt.qcow2> --private amazon-linux-2023-image --progress
- Once the image has been uploaded, create a volume out of this image
openstack volume create --size 40 --image amazon-linux-2023-image amazon-linux-2023-volume
-
Attached the volume to any running linux vm instance on Openstack cloud using the dashboard GUI
-
Once attached the volume you will see it in the lsblk command then mount the volume and then chroot the mount point to access the file system.
mkdir /als
mount /dev/vdf1 /als
chroot /als
note: in my case volume was /dev/vdf1
-
make changes to the /etc/cloud/cloud.cfg as per the standard image like adding the “devops/itops/cloud” user instead of the ec2-user and other config changes like installing packages etc as per your company image standards.
-
edit the /etc/cloud/cloud.cfg.d/02_amazon-onprem.cfg and add openstack as datasource
datasource_list: [ OpenStack, NoCloud, AltCloud, ConfigDrive, OVF, VMware, None ]
cloud-init clean
cloud-init init
-
exit the file system and detach the volume from the existing vm instance
-
create image out of the volume using dashboard or CLI :
openstack image create --container-format bare --disk-format qcow2 --volume amazon-linux-2023-volume amazon-linux-2023-image-updated
-
You can make this image as public, private or shared as per your needs.
-
Create a vm instance using this image “”amazon-linux-2023-image-updated” and do a ssh and type the below command to check the output
[root@amazon-linux-2023-updated home]# cloud-id
openstack
[root@amazon-linux-2023-updated home]# cat /etc/system-release
Amazon Linux release 2023.5.20240819 (Amazon Linux)
- First we need to download the Amazon Linux 2023 image for use with Kvm using the below link in the format qcow2
- Upload the qcow2 image to the image repository (glance) using the openstack dashboard or CLI
openstack image create --tag al2023 --disk-format qcow2 --container-format bare --file <al2023-kvm-2023.5.20240819.0-kernel-6.1-x86_64.xfs.gpt.qcow2> --private amazon-linux-2023-image --progress
-
Create a vm with the Amazon Linux 2023 image and it will not allow you to ssh to the machine without any user data
-
You need to create seed.iso so that the instance can access user-data and meta-data
-
You need to create files user-data and meta data and enter the details for the cloud config
#cloud-config #vim:syntax=yaml users:
- default
- name: devops groups: sudo sudo: ALL=(ALL) NOPASSWD:ALL plain_text_passwd: lock_passwd: false ssh_pwauth: True ssh-authorized-keys:
- Create a seed.iso using the below command:
mkisofs -output seed.iso -volid cidata -joliet -rock user-data meta-data
-
Create a seed-iso-volume from the iso image and attach the seed-iso-volume to running vm instance as the volume .
-
Reboot the instance for the seed-iso-volume to take affect.
-
SSH to the instance using the cloud config data from the user-data . Datasource will show” nocloud” and seed=/dev/vdb
[itops@al2023-ec2 ~]$ cloud-id
nocloud
[itops@al2023-ec2 ~]$ cloud-init status --long
status: done time: Thu, 05 Sep 2024 08:23:56 +0000 detail: DataSourceNoCloud [seed=/dev/vdb][dsmode=net]
-
In order to vm to boot without the seed.iso volume you need to create a file under /var/lib/cloud/seed by name of “nocloud” and under this create user-data and meta-data with the above config.
-
Reboot the vm instance and make changes to the /etc/cloud/cloud.cfg as per the standard image like adding the “devops” user instead of the ec2-user and other config changes like installing packages etc as per your company image standards.
edit the /etc/cloud/cloud.cfg.d/02_amazon-onprem.cfg and add openstack as datasource
datasource_list: [ OpenStack, NoCloud, AltCloud, ConfigDrive, OVF, VMware, None ]
cloud-init clean
cloud-init init
-
Detach the seed.iso volume from the instance and reboot the vm instance and this time it will pick from the /var/lib/cloud/seed/nocloud/user-data
-
ssh to the instance and check the cloud datasource and it will show openstack and :
[itops@al2023-bare ~]$ cloud-id
openstack
- Now remove /var/lib/cloud/seed/nocloud directory to remove the user-data and meta-data from the instance so that next time it can pick cloud-config data from the cloud.cfg .
Run the commands:
cloud-init clean
cloud-init init
- Create a snapshot of the vm and the upload to the image client glance
NOte: You can make this image as public, private or shared as per your needs.
- First we need to download the Amazon Linux 2023 image for use with Kvm using the below link in the format qcow2
- Add the module nbd to the qemu
modprobe nbd max_part=8
- Connect the qcow2 file we just downloaded to the nwtwork block device on the host
qemu-nbd --connect=/dev/nbd0 al2.qcow2
- Check the device partition on the disk :
fdisk /dev/nbd0 -l
- mount the Linux filesystem partition to the directory
mount /dev/nbd0p1 /als/
-
chroot /als to access the file system
-
You can now make changes to the /etc/cloud/cloud.cfg as per the standard image like adding the “devops/itops/cloud” user instead of the ec2-user and other config changes like installing packages etc as per your company image standards.
-
edit the /etc/cloud/cloud.cfg.d/02_amazon-onprem.cfg and add openstack as datasource
datasource_list: [ OpenStack, NoCloud, AltCloud, ConfigDrive, OVF, VMware, None ]
cloud-init clean
cloud-init init
- exit the file system and detach the volume from the existing vm instance .
qemu-nbd --disconnect /dev/nbd0
- unmount the directory
umount /als/