Automating VM creation: Difference between revisions

Jump to navigation Jump to search
no edit summary
mNo edit summary
No edit summary
Line 5: Line 5:


<!--T:2-->
<!--T:2-->
To automate the creation of cloud VMs, volumes, etc., the [[OpenStack Command Line Clients|command-line interface]], [https://wiki.openstack.org/wiki/Heat Heat], [[Terraform]], or the [[OpenStack Python API]] can be used. To install and configure settings and software within the VM [https://cloudinit.readthedocs.io/en/latest/ cloud-init] is used.
To automate the creation of cloud VMs, volumes, etc. the [[OpenStack Command Line Clients | OpenStack CLI]], [[#Using Heat Templates|Heat]], [[Terraform]], or the [[OpenStack python API]] can be used. Both the OpenStack CLI and Terraform are command line tools. While Heat is used through the OpenStack web dashboard, horizon. To install and configure settings and software within the VM, [[#Using cloud-init | cloud-init]] is used.


Cloud-init files are used to initialize a particular VM and run within that VM. They can be thought of as a way to automate tasks you would perform at the command line while logged into your VM. They can be used to perform tasks such as updating the operating system, installing and configuring applications, creating files, running commands, and create users and groups. Cloud-init can be used to setup other provisioning tools such as [https://docs.ansible.com/ ansible] or [https://puppet.com/ puppet] to continue with the software and VM configuration if desired.
In addition to these tools to create and provision your VMs, you can also gain access to the Compute Canada software stack (CVMFS) that is availble on our general purpose computing clusters, within your VM. See the [[#Enabling CVMFS on your VM| Enabling CVMFS]] section below.
 
Heat templates are even more powerful, they can be used to automate tasks performed in the OpenStack dashboard such as creating multiple VMs at once, configuring security groups, creating and configuring networks, and creating and attaching volumes to VMs. Heat templates can be used in conjunction with Cloud-init files, once Heat has created the VM it can pass a cloud-init file to that VM to perform setup tasks and even include information about other resources dynamically in the CloudInit files (e.g. floating IPs of other VMs).
 
Both cloud-init and Heat templates use the [https://en.wikipedia.org/wiki/YAML YAML] file format.


==Enabling CVMFS on your VM== <!--T:3-->
==Enabling CVMFS on your VM== <!--T:3-->
Line 21: Line 17:


==Using cloud-init== <!--T:4-->
==Using cloud-init== <!--T:4-->
The creation of Cloud-init YAML files is not covered here, instead see the official cloud-init [https://cloudinit.readthedocs.io/en/latest/ documentation] . When you are creating a new VM a Cloud-init file can be used to describe how the VM is to be configured after the selected image has been loaded. Cloud-init files can be used with the Horizon dashboard (OpenStack's web GUI), Terraform, the CLI, or the Python API. Here we describe how to use a CloudIinit file with Horizon.
Cloud-init files are used to initialize a particular VM and run within that VM. They can be thought of as a way to automate tasks you would perform at the command line while logged into your VM. They can be used to perform tasks such as updating the operating system, installing and configuring applications, creating files, running commands, and create users and groups. Cloud-init can be used to setup other provisioning tools such as [https://docs.ansible.com/ ansible] or [https://puppet.com/ puppet] to continue with the software and VM configuration if desired.


===Specifying a Cloud-init File=== <!--T:5-->
Cloud-init configuration is specified using plain text in the [https://en.wikipedia.org/wiki/YAML YAML] format. To see how to create cloud-init files see the official cloud-init [https://cloudinit.readthedocs.io/en/latest/ documentation]. cloud-init files can be used with the Horizon dashboard (OpenStack's web GUI), Terraform, the CLI, or the Python API. Here we describe how to use a cloud-iinit file with Horizon.
 
===Specifying a cloud-init File=== <!--T:5-->
# Start as normal when launching an instance, by clicking [[File:Launch-Instance-Button-Kilo.png|125px]] under ''Project''->''Compute''->''Instances'' and specifying your VM's configuration as described in [[Cloud Quick Start#Launching a VM | Launching a VM]].
# Start as normal when launching an instance, by clicking [[File:Launch-Instance-Button-Kilo.png|125px]] under ''Project''->''Compute''->''Instances'' and specifying your VM's configuration as described in [[Cloud Quick Start#Launching a VM | Launching a VM]].
# '''Before''' clicking ''Launch'', select the ''Post-Creation'' tab and specify your ''Customization Script Source'', in this case a Cloud-init YAML file, by either copying and pasting into a text box (''Direct Input'' method) or uploading from a file from your desktop computer (''File'' method). Older versions of OpenStack, in particular IceHouse, only provide a text box to copy and past your CloudInit file into.
# '''Before''' clicking ''Launch'', select the ''Post-Creation'' tab and specify your ''Customization Script Source'', in this case a Cloud-init YAML file, by either copying and pasting into a text box (''Direct Input'' method) or uploading from a file from your desktop computer (''File'' method). Older versions of OpenStack, in particular IceHouse, only provide a text box to copy and past your CloudInit file into.
Line 44: Line 42:


==Using Heat Templates== <!--T:10-->
==Using Heat Templates== <!--T:10-->
As with CloudInit the creation of Heat Orchestration Template (HOT) files is not covered here, instead see the official [http://docs.openstack.org/developer/heat/template_guide/hot_guide.html documentation]. Heat allows automation of operations performed in the OpenStack dashboard (Horizon) as well as the ability to pass information into the embedded CloudInit files, such as an IP of another server. Before using a Heat template there is usually no need to create any resources in advance. In fact it is often good practice to remove any resources you are not currently using before hand, as using a Heat template consumes resources towards your quota and will fail if it tries to exceed your quota.
Heat templates are even more powerful, they can be used to automate tasks performed in the OpenStack dashboard such as creating multiple VMs at once, configuring security groups, creating and configuring networks, and creating and attaching volumes to VMs. Heat templates can be used in conjunction with cloud-init files, once Heat has created the VM it can pass a cloud-init file to that VM to perform setup tasks and even include information about other resources dynamically in the cloud-init files (e.g. floating IPs of other VMs).
 
As with cloud-init the creation of [https://wiki.openstack.org/wiki/Heat Heat] Orchestration Template (HOT) files is not covered here, instead see the official [http://docs.openstack.org/developer/heat/template_guide/hot_guide.html documentation]. HOT files are also written in the [https://en.wikipedia.org/wiki/YAML YAML] format. Heat allows automation of operations performed in the OpenStack dashboard (Horizon) as well as the ability to pass information into the embedded CloudInit files, such as an IP of another server. Before using a Heat template there is usually no need to create any resources in advance. In fact it is often good practice to remove any resources you are not currently using before hand, as using a Heat template consumes resources towards your quota and will fail if it tries to exceed your quota.


<!--T:11-->
<!--T:11-->
cc_staff
1,486

edits

Navigation menu