Provisioning cloud instances on Microsoft Azure Resource Manager
orcharhino can interact with Microsoft Azure Resource Manager, including creating new virtual machines and controlling their power management states. Only image-based provisioning is supported for creating Azure hosts. This includes provisioning using Marketplace images, custom images, and shared image gallery.
For more information about Azure Resource Manager concepts, see Azure Resource Manager documentation.
-
Provide the installation medium for the operating systems that you want to use to provision hosts. For more information, see Syncing Repositories in Managing Content.
-
Provide an activation key for host registration. For more information, see Creating An Activation Key in Managing Content.
-
Ensure that you have the correct permissions to create an Azure Active Directory application. For more information, see Check Azure AD permissions in the Microsoft identity platform (Azure Active Directory for developers) documentation.
-
You must create and configure an Azure Active Directory application and service principle to obtain Application or client ID, Directory or tenant ID, and Client Secret. For more information, see Use the portal to create an Azure AD application and service principal that can access resources in the Microsoft identity platform (Azure Active Directory for developers) documentation.
-
Optional: If you want to use Puppet with Azure hosts, navigate to Administer > Settings > Puppet and enable the
Use UUID for certificates
setting to configure Puppet to use consistent Puppet certificate IDs. -
Based on your needs, associate a
finish
oruser_data
provisioning template with the operating system you want to use. For more information about provisioning templates, see Provisioning Templates. -
Optional: If you want the virtual machine to use a static private IP address, create a subnet in orcharhino with the Network Address field matching the Azure subnet address.
-
Before creating RHEL BYOS images, you must accept the image terms either in the Azure CLI or Portal so that the image can be used to create and manage virtual machines for your subscription.
Installing Microsoft Azure plugin
Install the Microsoft Azure plugin to attach an Azure compute resource provider to orcharhino. This allows you to manage and deploy hosts to Azure.
-
Install the Azure compute resource provider on your orcharhino Server:
# orcharhino-installer --enable-foreman-plugin-azure
-
Optional: In the orcharhino management UI, navigate to Administer > About and select the compute resources tab to verify the installation of the Microsoft Azure plugin.
Adding a Microsoft Azure Resource Manager connection to orcharhino Server
Use this procedure to add Microsoft Azure as a compute resource in orcharhino. Note that you must add a separate compute resource for each Microsoft Azure region that you want to use.
To use the CLI instead of the orcharhino management UI, see the CLI procedure.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click Create Compute Resource.
-
In the Name field, enter a name for the compute resource.
-
From the Provider list, select Azure Resource Manager.
-
Optional: In the Description field, enter a description for the resource.
-
By default, the Cloud is set to Public/Standard. Azure Government Cloud supports the following regions:
-
US Government
-
China
-
Germany
-
-
In the Client ID field, enter your Application or client ID.
-
In the Client Secret field, enter your client secret.
-
In the Subscription ID field, enter your subscription ID.
-
In the Tenant ID field, enter your Directory or tenant ID.
-
Click Load Regions. This tests if your connection to Azure Resource Manager is successful and loads the regions available in your subscription.
-
From the Azure Region list, select the Azure region to use.
-
Click Submit.
-
Use
hammer compute-resource create
to add an Azure compute resource to orcharhino.# hammer compute-resource create \ --app-ident My_Client_ID \ --name My_Compute_Resource_Name \ --provider azurerm \ --region "My_Region" \ --secret-key My_Client_Secret \ --sub-id My_Subscription_ID \ --tenant My_Tenant_ID
Note that the value for the
--region
option must be in lowercase and must not contain special characters.
If you are using Azure Government Cloud then you must pass in the --cloud parameter.
The values for the cloud parameter are:
|
Name of Azure Government Cloud | Value for hammer --cloud |
---|---|
US Government |
azureusgovernment |
China |
azurechina |
Germany |
azuregermancloud |
Adding Microsoft Azure Resource Manager images to orcharhino Server
To create hosts using image-based provisioning, you must add information about the image, such as access details and the image location, to your orcharhino Server.
To use the CLI instead of the orcharhino management UI, see the CLI procedure.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click the name of the Microsoft Azure Resource Manager connection.
-
Click Create Image.
-
In the Name field, enter a name for the image.
-
From the Operating System list, select the base operating system of the image.
-
From the Architecture list, select the operating system architecture.
-
In the Username field, enter the SSH user name for image access. You cannot use the
root
user. -
Optional: In the Password field, enter a password to authenticate with.
-
In the Azure Image Name field, enter an image name in the format
prefix://UUID
.-
For a custom image, use the prefix
custom
. For example, custom://image-name. -
For a shared gallery image, use the prefix
gallery
. For example, gallery://image-name. -
For public and RHEL Bring Your Own Subscription (BYOS) images, use the prefix
marketplace
. For example, marketplace://OpenLogicCentOS:7.5:latest.For more information, see Find Linux VM images in the Azure Marketplace with the Azure CLI.
-
-
Optional: Select the User Data checkbox if the image supports user data input, such as
cloud-init
data. -
Click Submit to save the image details.
-
Create the image with the
hammer compute-resource image create
command. Note that the username that you enter for the image must be the same that you use when you create a host with this image. The--password
option is optional when creating an image. You cannot use theroot
user.# hammer compute-resource image create \ --name Azure_image_name \ --compute-resource azure_cr_name \ --uuid 'marketplace://RedHat:RHEL:7-RAW:latest' \ --username 'azure_username' \ --user-data no
Adding Microsoft Azure Resource Manager details to a compute profile
Use this procedure to add Microsoft Azure hardware settings to a compute profile. When you create a host on Microsoft Azure using this compute profile, these settings are automatically populated.
To use the CLI instead of the orcharhino management UI, see the CLI procedure.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Profiles.
-
In the Compute Profiles window, click the name of an existing compute profile, or click Create Compute Profile, enter a Name, and click Submit.
-
Click the name of the Azure compute resource.
-
From the Resource group list, select the resource group to provision to.
-
From the VM Size list, select a size of a virtual machine to provision.
-
From the Platform list, select Linux.
-
In the Username field, enter a user name to authenticate with. Note that the username that you enter for compute profile must be the same that you use when creating an image.
-
To authenticate the user, use one of the following options:
-
To authenticate using a password, enter a password in the Password field.
-
To authenticate using an SSH key, enter an SSH key in the SSH Key field.
-
-
Optional: If you want the virtual machine to use a premium virtual machine disk, select the Premium OS Disk checkbox.
-
From the OS Disk Caching list, select the disc caching setting.
-
Optional: In the Custom Script Command field, enter commands to perform on the virtual machine when the virtual machine is provisioned.
-
Optional: If you want to run custom scripts when provisioning finishes, in the Comma separated file URIs field, enter comma-separated file URIs of scripts to use. The scripts must contain
sudo
at the beginning because orcharhino downloads files to the/var/lib/waagent/custom-script/download/0/
directory on the host and scripts require sudo privileges to be executed. -
Optional: You can add a NVIDIA Driver by selecting the NVIDIA driver / CUDA checkbox. For more information, refer to the following Microsoft Azure documentation:
-
Optional: If you want to create an additional volume on the VM, click the Add Volume button, enter the Size in GB and select the Data Disk Caching method.
-
Note that the maximum number of these disks depends on the VM Size selected. For more information on Microsoft Azure VM storage requirements, see the Microsoft Azure documentation.
-
-
Click Add Interface.
The maximum number of interfaces depends on the VM Size selected. For more information, see the Microsoft Azure documentation link above.
-
From the Azure Subnet list, select the Azure subnet to provision to.
-
From the Public IP list, select the public IP setting.
-
Optional: If you want the virtual machine to use a static private IP, select the Static Private IP checkbox.
-
Click Submit.
-
Create a compute profile to use with the Azure Resource Manager compute resource:
# hammer compute-profile create --name compute_profile_name
-
Add Azure details to the compute profile. With the
username
setting, enter the SSH user name for image access. Note that the username that you enter for compute profile must be the same that you use when creating an image.# hammer compute-profile values create \ --compute-attributes="resource_group=resource_group,vm_size=Standard_B1s,username=azure_user,password=azure_password,platform=Linux,script_command=touch /var/tmp/text.txt" \ --compute-profile "compute_profile_name" \ --compute-resource azure_cr_name \ --interface="compute_public_ip=Dynamic,compute_network=mysubnetID,compute_private_ip=false" \ --volume="disk_size_gb=5,data_disk_caching=None"
Optional: If you want to run scripts on the virtual machine after provisioning, specify the following settings:
-
To enter the script directly, with the
script_command
setting, enter a command to be executed on the provisioned virtual machine. -
To run a script from a URI, with the
script_uris
setting, enter comma-separated file URIs of scripts to use. The scripts must containsudo
at the beginning because orcharhino downloads files to the/var/lib/waagent/custom-script/download/0/
directory on the host and therefore scripts require sudo privileges to be executed.
-
Creating image-based hosts on Microsoft Azure Resource Manager
In orcharhino, you can use Microsoft Azure Resource Manager provisioning to create hosts from an existing image. The new host entry triggers the Microsoft Azure Resource Manager server to create the instance using the pre-existing image as a basis for the new volume.
To use the CLI instead of the orcharhino management UI, see the CLI procedure.
-
In the orcharhino management UI, navigate to Hosts > Create Host.
-
In the Name field, enter a name for the host.
-
Optional: Click the Organization tab and change the organization context to match your requirement.
-
Optional: Click the Location tab and change the location context to match your requirement.
-
From the Host Group list, select a host group that you want to assign your host to. That host group will populate the form.
-
From the Deploy on list, select the Microsoft Azure Resource Manager connection.
-
From the Compute Profile list, select a profile to use to automatically populate virtual machine settings.
-
From the Lifecycle Environment list, select the environment.
-
Click the Interfaces tab, and on the interface of the host, click Edit.
-
Verify that the fields are populated with values. Note in particular:
-
orcharhino automatically assigns an IP address for the new host.
-
Ensure that the MAC address field is blank. Microsoft Azure Resource Manager assigns a MAC address to the host during provisioning.
-
The Name from the Host tab becomes the DNS name.
-
The Azure Subnet field is populated with the required Azure subnet.
-
Optional: If you want to use a static private IP address, from the IPv4 Subnet list select the orcharhino subnet with the Network Address field matching the Azure subnet address. In the IPv4 Address field, enter an IPv4 address within the range of your Azure subnet.
-
Ensure that orcharhino automatically selects the Managed, Primary, and Provision options for the first interface on the host. If not, select them.
-
-
Click OK to save. To add another interface, click Add Interface. You can select only one interface for Provision and Primary.
-
Click the Operating System tab, and confirm that all fields automatically contain values.
-
For Provisioning Method, ensure Image Based is selected.
-
From the Image list, select the Azure Resource Manager image that you want to use for provisioning.
-
In the Root Password field, enter the root password to authenticate with.
-
Click Resolve in Provisioning templates to check the new host can identify the right provisioning templates to use.
-
Click the Virtual Machine tab and confirm that these settings are populated with details from the host group and compute profile. Modify these settings to suit your needs.
-
Click the Parameters tab, and ensure that a parameter exists that provides an activation key. If not, add an activation key.
-
Click Submit to save the host entry.
-
Create the host with the
hammer host create
command and include--provision-method image
. Replace the values in the following example with the appropriate values for your environment.# hammer host create \ --architecture x86_64 \ --compute-profile "My_Compute_Profile" \ --compute-resource "My_Compute_Resource" \ --domain "My_Domain" \ --image "My_Azure_Image" \ --location "My_Location" \ --name "My_Host_Name" \ --operatingsystem "My_Operating_System" \ --organization "My_Organization" \ --provision-method "image"
For more information about additional host creation parameters for this compute resource, enter the hammer host create --help
command.
Deleting a VM on Microsoft Azure
You can delete VMs running on Microsoft Azure from within orcharhino.
-
In the orcharhino management UI, navigate to Infrastructure > Compute Resources.
-
Select your Microsoft Azure provider.
-
On the Virtual Machines tab, click Delete from the Actions menu. This deletes the virtual machine from the Microsoft Azure compute resource while retaining any associated hosts within orcharhino. If you want to delete the orphaned host, navigate to Hosts > All Hosts and delete the host manually.
Uninstalling Microsoft Azure plugin
If you have previously installed the Microsoft Azure plugin but don’t use it anymore to manage and deploy hosts to Azure, you can uninstall it from your orcharhino Server.
-
Uninstall the Azure compute resource provider from your orcharhino Server:
# dnf remove rubygem-foreman_azure_rm rubygem-ms_rest_azure # orcharhino-installer --no-enable-foreman-plugin-azure
-
Optional: In the orcharhino management UI, navigate to Administer > About and select the Available Providers tab to verify the removal of the Microsoft Azure plugin.
The text and illustrations on this page are licensed by ATIX AG under a Creative Commons Attribution Share Alike 4.0 International ("CC BY-SA 4.0") license. This page also contains text from the official Foreman documentation which uses the same license ("CC BY-SA 4.0"). |