Obtaining Linux templates
As all Linux guests have OpenSSH Server preinstalled by default, you only need to make sure a Linux template has cloud-init installed.
The easiest way to get a Linux template with cloud-init installed is to obtain it from its official repository or build one with the diskimage-builder tool. You can also create a Linux template from an existing boot volume.
Limitations
- The disk image is created with only the root user that has neither password nor SSH keys. You can use the user dataandcloud-initmethods to perform initial configuration tasks on VMs that will be deployed from the disk image, for example, create custom user accounts. For more options to customize a VM during boot, refer to the cloud-init documentation.
To build a Linux template
- 
                                    Install the diskimage-builderpackage:# yum install diskimage-builder 
- 
                                    For the RHEL 7 guest OS, download the cloud image from the Red Hat Customer Portal (login required) and execute: # export DIB_LOCAL_IMAGE=<path_to_rhel7_image> 
- 
                                    Execute the disk-image-createcommand to build a disk image with installedcloud-initfor the desired Linux guest. For example:# disk-image-create vm centos7 -t qcow2 -o centos7 where - 
                                            centos7is the name of a guest OS. Can be one of the following:centos6,centos7,debian,rhel7, orubuntu.By default, using the ubuntuelement will create a disk image for Ubuntu 16.04. To build the Ubuntu 18.04 disk image, add theDIB_RELEASE=bionicto the command:DIB_RELEASE=bionic disk-image-create vm ubuntu -t qcow2 -o ubuntu18.
- 
                                            -osets the name for the resulting disk image file.
 
- 
                                            
- 
                                    Upload the created disk image by using the vinfratool to the compute cluster:# vinfra service compute image create centos7-image --os-distro centos7 \ --disk-format qcow2 --file centos7.qcow2 where - centos7-imageis the name of a new image.
- centos7is the OS distribution. Can be one of the following:- centos6,- centos7,- debian9,- rhel7,- ubuntu16.04, and- ubuntu18.04.
- centos7.qcow2is the QCOW2-image created on step 3.
 
To deploy a virtual machine from the uploaded template
- 
                                    Create the user-dataconfiguration file with a custom user account:# cat <<EOF > user-data #cloud-config user: myuser password: password chpasswd: {expire: False} ssh_pwauth: True EOFwhere myuseris the name of a custom user andpasswordis a password for the account.
- 
                                    Launch the deployment of a VM from the disk image by using the configuration file as user data: # vinfra service compute server create centos7-vm --flavor medium \ --network public --user-data user-data --volume source=image,\ 
 id=centos7-image,size=10where - centos7-vmis the name of a new VM.
- user-datais the configuration file created in step 5.
- centos7-imageis the image added to the compute cluster in step 4.
 
 What's next
What's next