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.

Prerequisites
  • 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 or user_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 plug-in

Install the Microsoft Azure plug-in to attach an Azure compute resource provider to orcharhino. This allows you to manage and deploy hosts to Azure.

Procedure
  1. Install the Azure compute resource provider on your orcharhino Server:

    $ orcharhino-installer --enable-foreman-plugin-azure
  2. Optional: In the orcharhino management UI, navigate to Administer > About and select the compute resources tab to verify the installation of the Microsoft Azure plug-in.

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.

Procedure
  1. In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click Create Compute Resource.

  2. In the Name field, enter a name for the compute resource.

  3. From the Provider list, select Azure Resource Manager.

  4. Optional: In the Description field, enter a description for the resource.

  5. By default, the Cloud is set to Public/Standard. Azure Government Cloud supports the following regions:

    • US Government

    • China

    • Germany

  6. In the Client ID field, enter your Application or client ID.

  7. In the Client Secret field, enter your client secret.

  8. In the Subscription ID field, enter your subscription ID.

  9. In the Tenant ID field, enter your Directory or tenant ID.

  10. Click Load Regions. This tests if your connection to Azure Resource Manager is successful and loads the regions available in your subscription.

  11. From the Azure Region list, select the Azure region to use.

  12. Click Submit.

CLI procedure
  • 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.

Procedure
  1. In the orcharhino management UI, navigate to Infrastructure > Compute Resources and click the name of the Microsoft Azure Resource Manager connection.

  2. Click Create Image.

  3. In the Name field, enter a name for the image.

  4. From the Operating System list, select the base operating system of the image.

  5. From the Architecture list, select the operating system architecture.

  6. In the Username field, enter the SSH user name for image access. You cannot use the root user.

  7. Optional: In the Password field, enter a password to authenticate with.

  8. 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.

  9. Optional: Select the User Data checkbox if the image supports user data input, such as cloud-init data.

  10. Click Submit to save the image details.

CLI procedure
  • 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 the root 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.

Procedure
  1. In the orcharhino management UI, navigate to Infrastructure > Compute Profiles.

  2. In the Compute Profiles window, click the name of an existing compute profile, or click Create Compute Profile, enter a Name, and click Submit.

  3. Click the name of the Azure compute resource.

  4. From the Resource group list, select the resource group to provision to.

  5. From the VM Size list, select a size of a virtual machine to provision.

  6. From the Platform list, select Linux.

  7. 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.

  8. 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.

  9. Optional: If you want the virtual machine to use a premium virtual machine disk, select the Premium OS Disk checkbox.

  10. From the OS Disk Caching list, select the disc caching setting.

  11. Optional: In the Custom Script Command field, enter commands to perform on the virtual machine when the virtual machine is provisioned.

  12. 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.

  13. Optional: You can add a NVIDIA Driver by selecting the NVIDIA driver / CUDA checkbox. For more information, refer to the following Microsoft Azure documentation:

  14. 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.

  15. Click Add Interface.

    The maximum number of interfaces depends on the VM Size selected. For more information, see the Microsoft Azure documentation link above.

  16. From the Azure Subnet list, select the Azure subnet to provision to.

  17. From the Public IP list, select the public IP setting.

  18. Optional: If you want the virtual machine to use a static private IP, select the Static Private IP checkbox.

  19. Click Submit.

CLI procedure
  1. Create a compute profile to use with the Azure Resource Manager compute resource:

    $ hammer compute-profile create --name compute_profile_name
  2. 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 contain sudo 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.

Procedure
  1. In the orcharhino management UI, navigate to Hosts > Create Host.

  2. In the Name field, enter a name for the host.

  3. Optional: Click the Organization tab and change the organization context to match your requirement.

  4. Optional: Click the Location tab and change the location context to match your requirement.

  5. From the Host Group list, select a host group that you want to assign your host to. That host group will populate the form.

  6. From the Deploy on list, select the Microsoft Azure Resource Manager connection.

  7. From the Compute Profile list, select a profile to use to automatically populate virtual machine settings.

  8. From the Lifecycle Environment list, select the environment.

  9. Click the Interfaces tab, and on the interface of the host, click Edit.

  10. 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.

  11. Click OK to save. To add another interface, click Add Interface. You can select only one interface for Provision and Primary.

  12. Click the Operating System tab, and confirm that all fields automatically contain values.

  13. For Provisioning Method, ensure Image Based is selected.

  14. From the Image list, select the Azure Resource Manager image that you want to use for provisioning.

  15. In the Root Password field, enter the root password to authenticate with.

  16. Click Resolve in Provisioning templates to check the new host can identify the right provisioning templates to use.

  17. 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.

  18. Click the Parameters tab, and ensure that a parameter exists that provides an activation key. If not, add an activation key.

  19. Click Submit to save the host entry.

CLI procedure
  • 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.

The text and illustrations on this page are licensed by ATIX AG under a Creative Commons Attribution–Share Alike 3.0 Unported ("CC-BY-SA") license. This page also contains text from the official Foreman documentation which uses the same license ("CC-BY-SA").