Tags Archives: VM

Introduction to cloud-init

To quote from the official cloud-init project website:

 

Cloud-init is the industry standard multi-distribution method for cross-platform cloud instance initialization.

 

It is supported across all major public cloud providers, provisioning systems for private cloud infrastructure, and bare-metal installations.

 

Cloud-init will identify the cloud it is running on during boot, read any provided metadata from the cloud and initialize the system accordingly.

 

This may involve setting up the network and storage devices to configuring SSH access key and many other aspects of a system.

 

Later on the cloud-init will also parse and process any optional user or vendor data that was passed to the instance.

 

 

The official cloud-init project site is at https://cloudinit.readthedocs.io/en/latest/topics/availability.html

 

cloud-init automates the initialization of cloud instances during VM system startup.

 

You can configure cloud-init to perform various tasks, such as:

 

setting a host name
installing software packages on a VM
running scripts
suppressing or modifying default VM behaviour
generate ssh private keys
adding ssh keys to user’s .ssh/authorized_keys for ssh logins
setting up mount points

 

cloud-init uses YAML-formatted file instructions to perform its tasks.

 

When an instance boots, the cloud-init service starts and searches for and executes the instructions for cloud-init.

 

You define the cloud-init tasks by configuring the /etc/cloud/cloud.cfg file and adding directives into the /etc/cloud/cloud.cfg.d/ directory with files named *.cfg which must contain a #cloud-config at the start of the file.

 

cloud-init runs through five stages during a system boot. Those stages determine whether cloud-init runs and where it will will seek its datasources:

 

The cloud-init generator stage: this runs via the systemd service, determines whether to run cloud-init on bootup.

 

The local stage: in which cloud-init finds local datasources and activates the defined network configuration.

 

The network stage: in which cloud-init processes user data and runs the modules listed under cloud_init_modules in the cloud.cfg file.

 

This allows you to enable, disable, or add modules to the cloud_init_modules section.

 

The config stage: in which cloud-init runs the modules listed under cloud_config_modules in the cloud.cfg file. Yoou can enable, disable, or add modules to the cloud_config_modules section.

 

The final stage: in which cloud-init runs what you have included under cloud_final_modules in the cloud.cfg file.

 

You can include package installations that you want to run after booting, as well as configuration management plug-ins and user scripts. You can also enable, disable, or add modules to the cloud_final_modules section.

 

 

 

How To Install cloud-init

 

On Ubuntu/Debian systems:

 

check if installed:

 

dpkg –get-selections | grep cloud-init

 

root@gemini:~#
root@gemini:~# dpkg –get-selections | grep cloud-init
cloud-init install
cloud-initramfs-copymods install
cloud-initramfs-dyn-netconf install
root@gemini:~#

 

 

if you wish to remove a default version from the OS and reinstall a fresh version:

 

apt remove –purge cloud-init

 

then do

 

apt install cloud-init

 

root@gemini:/etc/cloud# ll
total 32
drwxr-xr-x 4 root root 4096 Mar 23 11:49 ./
drwxr-xr-x 123 root root 12288 Mar 23 06:42 ../
-rw-r–r– 1 root root 3819 Feb 8 05:55 cloud.cfg
drwxr-xr-x 2 root root 4096 Feb 8 05:55 cloud.cfg.d/
-rw-r–r– 1 root root 3819 Mar 23 11:48 cloud.cfg.orig
drwxr-xr-x 2 root root 4096 Mar 23 11:52 templates/
root@gemini:/etc/cloud#

 

the main config file is /etc/cloud/cloud.cfg:

 

you can disable items/functionality that you do not want the VM to use.

 

 

 

Troubleshooting cloud-init

 

check the /etc/systemd/network directory

 

if this directory contains a symlink to /dev/null then this must be removed, else cloud-init will not work!

 

After changing the config, you can activate it in the existing VM session by running these two commands:

 

 

cloud-init clean

cloud-init init

 

 

Continue Reading

How To Resolve Oracle VirtualBox error : kernel driver not installed(rc=-1908)

When trying to start an Oracle virtual box, the start fails with the following error:

Oracle VirtualBox error : kernel driver not installed(rc=-1908)

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a
permission problem with /dev/vboxdrv. Please reinstall the kernel module by
executing


‘/etc/init.d/vboxdrv setup’

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv
kernel module if necessary.

 

How to Resolve

running

/etc/init.d/vboxdrv setup

as suggested by the error did not resolve the problem.

You need to do the following:

sudo apt-get remove virtualbox-dkms
sudo apt-get install virtualbox-dkms


The Oracle virtual box machine can then be started without error.

Continue Reading