Provisioning Cloud Instances on Google Compute Engine
orcharhino can interact with Google Compute Engine (GCE), including creating new virtual machines and controlling their power management states.
-
Provide the installation medium for the operating systems that you want to use to provision hosts. You can use synchronized content repositories for Red Hat Enterprise Linux. 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.
-
In your GCE project, configure a service account with the necessary IAM Compute role. For more information, see Compute Engine IAM roles in the GCE documentation.
-
In your GCE project-wise metadata, set the
enable-oslogin
toFALSE
. For more information, see Enabling or disabling OS Login in the GCE documentation. -
Optional: If you want to use Puppet with GCE 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, see Provisioning Templates in Provisioning Hosts.
Adding a Google GCE Connection to orcharhino Server
Use this procedure to add Google Compute Engine (GCE) as a compute resource in orcharhino. To use the CLI instead of the orcharhino management UI, see the CLI procedure.
-
In Google GCE, generate a service account key in JSON format. For more information, see Create and manage service account keys in the GCE documentation.
-
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 Google.
-
Optional: In the Description field, enter a description for the resource.
-
In the JSON key field, click Choose File and locate your service account key for upload from your local machine.
-
Click Load Zones to populate the list of zones from your GCE environment.
-
From the Zone list, select the GCE zone to use.
-
Click Submit.
-
In Google GCE, generate a service account key in JSON format. For more information, see Create and manage service account keys in the GCE documentation.
-
Copy the file from your local machine to orcharhino Server:
$ scp My_GCE_Key.json root@orcharhino.example.com:/etc/foreman/My_GCE_Key.json
-
On orcharhino Server, change the owner for your service account key to the
foreman
user:$ chown root:foreman /etc/foreman/My_GCE_Key.json
-
On orcharhino Server, configure permissions for your service account key to ensure that the file is readable:
$ chmod 0640 /etc/foreman/My_GCE_Key.json
-
On orcharhino Server, restore SELinux context for your service account key:
$ restorecon -vv /etc/foreman/My_GCE_Key.json
-
Use the
hammer compute-resource create
command to add a GCE compute resource to orcharhino:$ hammer compute-resource create \ --key-path "/etc/foreman/My_GCE_Key.json" \ --name "My_GCE_Compute_Resource" \ --provider "gce" \ --zone "My_Zone"
Adding Google Compute Engine 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 Google Compute Engine 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. Specify a user other than
root
, because theroot
user cannot connect to a GCE instance using SSH keys. The username must begin with a letter and consist of lowercase letters and numbers. -
From the Image list, select an image from the Google Compute Engine compute resource.
-
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. With the--username
option, specify a user other thanroot
, because theroot
user cannot connect to a GCE instance using SSH keys. The username must begin with a letter and consist of lowercase letters and numbers.$ hammer compute-resource image create \ --name 'gce_image_name' \ --compute-resource 'gce_cr' \ --operatingsystem-id 1 \ --architecture-id 1 \ --uuid '3780108136525169178' \ --username 'admin'
Adding Google GCE Details to a Compute Profile
Use this procedure to add Google GCE hardware settings to a compute profile. When you create a host on Google GCE 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 GCE compute resource.
-
From the Machine Type list, select the machine type to use for provisioning.
-
From the Image list, select the image to use for provisioning.
-
From the Network list, select the Google GCE network to use for provisioning.
-
Optional: Select the Associate Ephemeral External IP checkbox to assign a dynamic ephemeral IP address that orcharhino uses to communicate with the host. This public IP address changes when you reboot the host. If you need a permanent IP address, reserve a static public IP address on Google GCE and attach it to the host.
-
In the Size (GB) field, enter the size of the storage to create on the host.
-
Click Submit to save the compute profile.
-
Create a compute profile to use with the Google GCE compute resource:
$ hammer compute-profile create --name My_GCE_Compute_Profile
-
Add GCE details to the compute profile:
$ hammer compute-profile values create \ --compute-attributes "machine_type=f1-micro,associate_external_ip=true,network=default" \ --compute-profile "My_GCE_Compute_Profile" \ --compute-resource "My_GCE_Compute_Resource" \ --volume "size_gb=20"
Creating Image-based Hosts on Google Compute Engine
In orcharhino, you can use Google Compute Engine provisioning to create hosts from an existing image. The new host entry triggers the Google Compute Engine 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 Google Compute Engine 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. Google Compute Engine assigns a MAC address to the host during provisioning.
-
The Name from the Host tab becomes the DNS name.
-
The Domain field is populated with the required domain.
-
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.
-
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 "gce_profile_name" \ --compute-resource "My_GCE_Compute_Resource" \ --image "My_GCE_Image" \ --interface "type=interface,domain_id=1,managed=true,primary=true,provision=true" \ --location "My_Location" \ --name "GCE_VM" \ --operatingsystem "My_Operating_System" \ --organization "My_Organization" \ --provision-method 'image' \ --puppet-ca-proxy-id 1 \ --puppet-environment-id 1 \ --puppet-proxy-id 1 \ --root-password "My_Root_Password"
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"). |