Use this procedure to add Google Compute Engine (GCE) as a compute resource in {Project}. To use the CLI instead of the {ProjectWebUI}, 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 {ProjectWebUI}, 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 {ProjectServer}:
# scp My_GCE_Key.json root@{foreman-example-com}:/etc/foreman/My_GCE_Key.json
-
On {ProjectServer}, change the owner for your service account key to the
foreman
user:# chown root:foreman /etc/foreman/My_GCE_Key.json
-
On {ProjectServer}, configure permissions for your service account key to ensure that the file is readable:
# chmod 0640 /etc/foreman/My_GCE_Key.json
-
On {ProjectServer}, 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 {Project}:# hammer compute-resource create \ --key-path "/etc/foreman/My_GCE_Key.json" \ --name "My_GCE_Compute_Resource" \ --provider "gce" \ --zone "My_Zone"