.. _Creating Linux Templates: Creating Linux Templates ------------------------ If you do not have a ready Linux template, you can build one with the ``diskimage-builder`` tool. The disk image is created with only the root user that has neither password nor SSH keys. You can use the ``user data`` and ``cloud-init`` methods 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 create a template and deploy a VM from it, do as follows: #. Install the ``diskimage-builder`` package: :: # 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= #. Execute the following command to build a disk image with installed ``cloud-init`` for the desired Linux guest. For example: :: # disk-image-create vm centos7 -t qcow2 -o centos7 where - ``centos7`` is the name of a guest OS. Can be one of the following: ``centos6``, ``centos7``, ``debian``, ``rhel7``, or ``ubuntu``. By default, using the ``ubuntu`` element will create a disk image for Ubuntu 16.04. To build the Ubuntu 18.04 disk image, add the ``DIB_RELEASE=bionic`` to the command as follows: ``DIB_RELEASE=bionic disk-image-create vm ubuntu -t qcow2 -o ubuntu18``. - ``-o`` sets the name for the resulting disk image file. #. Upload the created disk image using the ``vinfra`` tool to the compute cluster: :: # vinfra service compute image create centos7-image --os-distro centos7 \ --disk-format qcow2 --file centos7.qcow2 where - ``centos7-image`` is the name of a new image. - ``centos7`` is the corresponding OS version. Can be one of the following: ``centos6``, ``centos7``, ``debian9``, ``rhel7``, ``ubuntu16.04``, and ``ubuntu18.04``. - ``centos7.qcow2`` is the QCOW2-image created on step 3. #. Create the ``user-data`` configuration file with a custom user account: :: # cat < user-data #cloud-config users: - name: user lock-passwd: false sudo: ALL=(ALL) NOPASSWD:ALL passwd: $6$CjI58V.q7gFvBlMU$9lvue5t8l/VD/tR9L8VTgaRnIksr7ZkSvjtxGxAelJaa.\ WWAmJwRKLjbJwjikOSO2P5DCEYSX/Uf.MuvvhrCE/ EOF where ``user`` is the name of a custom user and ``$6$CjI58V<...>`` is a hashed password for the account. #. Launch the deployment of a VM from the disk image 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=10 where - ``centos7-vm`` is the name of a new VM, - ``user-data`` is the configuration file created in step 5, - ``centos7-image`` is the image added to the compute cluster in step 4. For more information on using the ``vinfra`` tool, see *Command Line Reference*.