There are various images available for Compute instances in Oracle Cloud, As of January 17, 2021, there is no CentOS Stream image available.
Therefore, create a Compute instance of CentOS8 and use CentOS Stream by updating with cloud-init. It was almost the same as when I created a Compute instance, and it was very easy to create.
In addition, this article is very easy to understand and I referred to how to use cloud-init when initializing OCI.
■ Articles that I referred to Complete the initial setup of OCI Compute with cloud-init
・ OCI Compute ・ Cloud-init ・ CentOS Stream
Mac OS X 10.15.7
Create a Compute instance. This time, I created it with "VM.Standard.E3.Flex 1 core OCPU, 16 GB memory, 1 Gbps network bandwidth".
Select "CentOS 8" instead of the default "Oracle Linux 7.9".
This time, we have selected the pre-registered VCN and public subnet and assigned a buprick IP address.
Click Show Advanced Options to view the advanced options.
Select "Paste Cloud-init Script" under "Initialization Script" on the "Administration" tab of the extended options. Paste the following script in the input field of the cloud-init script.
Since cloud-init runs with root privileges, there is no problem without sudo. Since you will be prompted to enter [Y/N] during command execution, all [-y] options are added.
#!/bin/bash
dnf install centos-release-stream -y
dnf swap centos-{linux,stream}-repos -y
dnf distro-sync -y
After entering cloud-init, click "Create" and wait until the instance is created.
The status of the instance became "Starting", and the operation was confirmed after a few minutes or more had passed.
Log in to the instance created by ssh. Enter the following command and confirm that "CentOS Stream release 8" is displayed.
cat /etc/centos-release
CentOS Stream release 8
The log when cloud-init is executed is saved in the following.
/var/log/cloud-init-output.log
If you check the log, the following log will be output, Since osmsplugin is a plugin used in Oracle Linux 6/7/8, it has no effect. Failed loading plugin "osmsplugin": No module named 'librepo'
When the following line is displayed, cloud-init processing is complete.
Cloud-init v. 19.4 running 'modules:final' at Sun, 17 Jan 2021 14:54:04 +0000. Up 28.87 seconds.
Cloud-init v. 19.4 finished at Sun, 17 Jan 2021 15:00:08 +0000. Datasource DataSourceOracle. Up 393.38 seconds
■ cloud-init official manual cloud-init Documentation
■ Articles that I referred to Complete the initial setup of OCI Compute with cloud-init