Skip to main content

Updating the instance OS upon creation

·258 words·2 mins
Orlando Gentil
Author
Orlando Gentil
Jack of all trades, master of none
“Every time I create a Linux instance, I spend time updating and upgrading the base installation on the first login. How could I make it faster?”

Originally posted at the Oracle University Learning Community

A basic install contains hundreds of packages, and they are frequently updated. The best practices recommend that you update your installation images or update the system as soon as it becomes online.

If you have some automation using Puppet, ansible, and others, you most likely have that taken care of, but sometimes you need something more straightforward that you can do in a snap. I have a tip for you.

OCI supports cloud-init. Cloud-init runs scripts to initialize and configure instances. You will know how to trigger the catalog’s update and package upgrade with some simple instructions.

When you are creating the instance, expand the Advanced options at the bottom of the screen, go to the cloud-init section, select “Paste cloud-init script,” and paste the following:

#cloud-config
# Upgrade the instance on the first boot
#
package_upgrade: true

It will look like this:

instance creation advanced options

Proceed to create the instance, and when you log in, it will be updated without any intervention (it can take a couple of minutes).

It is a simple thing that can save time when creating an instance and frees you up for the next task.

This is the most straightforward cloud-init script I know, and I hope it sparks your curiosity to explore cloud-init possibilities. If you have used cloud-init already, share how it helped you automate the instance provisioning process.