Deploy development virtual machines on Google Cloud
This page details the Terraform configuration for deploying development virtual machines (VMs) on Google Cloud Platform (GCP) with multiple operating system options and automated Netprobe deployment. This environment creates development VMs on GCP with:
- Multiple OS choices (Ubuntu 22.04/24.04 LTS, RHEL 8/9)
- Ansible deployment automation
- SSH key authentication
- Configurable VM specifications
- Resource labeling for organization
Template files Copied
The environment contains the following Terraform configuration files:
main.tf
— the main configuration that provisions VM instances and triggers the Ansible deploymentvariables.tf
— variable definitions for all configurable parametersoutputs.tf
— output definitions for deployment informationproviders.tf
— GCP provider configurationversions.tf
— Terraform and provider version constraintsterraform.tfvars.[os].example
— configuration file for your operating system
Prerequisites Copied
-
Terraform version 1.0 or higher installed
-
Google Cloud SDK version 400.0.0 or higher installed
-
GCP authentication configured
-
GCP project with required APIs enabled:
# Enable required APIs gcloud services enable compute.googleapis.com gcloud services enable oslogin.googleapis.com # Set default project gcloud config set project YOUR_PROJECT_ID
-
SSH key pair for VM access
# Generate SSH key pair if not already available ssh-keygen -t rsa -b 4096 -f ../../../../../resources/id_rsa
-
IAM permissions, where the user or service account must have:
- Compute Instance Admin
- Compute Security Admin
- Service Account User
Deployment setup Copied
-
Copy the example configuration.
# For Ubuntu 22.04 (default) cp terraform.tfvars.example terraform.tfvars # For Ubuntu 24.04 cp terraform.tfvars.ubuntu24.example terraform.tfvars # For RHEL 8 cp terraform.tfvars.rhel8.example terraform.tfvars # For RHEL 9 cp terraform.tfvars.rhel9.example terraform.tfvars
-
Update
terraform.tfvars
configuration file with your Google Cloud settings.nano terraform.tfvars
-
Deploy the infrastructure.
terraform init terraform plan terraform apply
Authentication overview Copied
This deployment requires two types of authentication:
-
Terraform authentication (infrastructure creation) to allow Terraform to create virtual machines, networks, and cloud resources. For Google Cloud, you need to configure
gcloud auth
or the service account credentials.-
User account — makes use of your personal Google account for authentication.
gcloud auth login gcloud auth application-default login
-Service account — makes use of a service account for automated deployments.
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
- Workload Identity (GKE/Cloud Build) — makes use of a workload identity for deployments from GCP services.
-
-
Application authentication (cloud storage access) to allow applications running on virtual machines to download the deployment resources from the respective cloud storage. This is configured in the
netprobe.yml
file for each environment. Refer to Google Cloud Platform authentication for detailed authentication configuration.
Configuration files Copied
Select the appropriate configuration file for your operating system:
Operating system | Configuration file |
---|---|
Ubuntu 22.04 LTS (default) | terraform.tfvars.example |
Ubuntu 24.04 LTS | terraform.tfvars.ubuntu24.example |
RHEL 8 | terraform.tfvars.rhel8.example |
RHEL 9 | terraform.tfvars.rhel9.example |
In the selected configuration file, configure the parameters outlined below.
GCP account configuration Copied
Parameter | Description | Default | Required |
---|---|---|---|
gcp_project_id |
GCP project ID for deployment | Yes | |
gcp_region |
GCP region for deployment | “us-central1” | Yes |
gcp_zone_id |
Zone suffix within the region | “a” | Yes |
GCP service account configuration Copied
The service account must be created by the user before deployment. This service account will be attached to the VM instances during creation.
Example service account creation:
# Create the service account for VM instances
gcloud iam service-accounts create dev-instance-sa \
--display-name="Development Instance Service Account" \
--project=your-project-id
Parameter | Description | Default | Required |
---|---|---|---|
gcp_service_account_email |
Email of existing service account to attach to instances | Yes | |
gcp_service_account_scopes |
List of access scopes for the service account | [“cloud-platform”] | Yes |
Deployment configuration Copied
Parameter | Description | Default | Required |
---|---|---|---|
deployment_count |
Number of identical VM deployments to create | 1 | Yes |
labels |
Resource labels to assign to all created resources | {} | No |
Network configuration Copied
Parameter | Description | Default | Required |
---|---|---|---|
network_name |
VPC network name | “default” | Yes |
subnetwork_name |
Subnet name | “default” | Yes |
Virtual machine configuration Copied
Virtual machine configurations are based on the Netprobe system requirements. The default machine type and boot OS disk type and size also follow the Netprobe requirements.
Parameter | Description | Default | Required |
---|---|---|---|
vm_name |
Base name for VM instances | “vm-template” | Yes |
vm_type |
GCP machine type | “n2-standard-2” | Yes |
vm_image_family |
VM boot image family | “ubuntu-2204-lts” | Yes |
vm_image_project |
GCP project containing the VM image | “ubuntu-os-cloud” | Yes |
vm_disk_size |
VM boot disk size in GB | 50 | Yes |
vm_disk_type |
VM boot disk type | “pd-ssd” | Yes |
vm_status |
Desired VM status | “RUNNING” | Yes |
SSH access configuration Copied
Parameter | Description | Default | Required |
---|---|---|---|
ssh_user |
SSH username for VM access | “netprobe_user” | Yes |
ssh_public_key_path |
Path to SSH public key file | “../../../../../resources/id_rsa.pub” | Yes |
Ansible deployment configuration Copied
Parameter | Description | Default | Required |
---|---|---|---|
ansible_playbook_path |
Path to Ansible playbook | “../../../../ansible/netprobe.yml” | Yes |
ansible_operation |
Deployment operation | “install” | Yes |
additional_args |
Additional Ansible playbook arguments | "" | No |
Resources created Copied
The following GCP infrastructure resources will be created:
Resource | Description |
---|---|
Compute instance | VM with selected OS and automatic image detection |
Ansible deployment | Automated Netprobe service installation |
Outputs Copied
The following outputs will be available after deployment:
Output | Description |
---|---|
external_ip |
External IP address of the compute instance |
internal_ip |
Internal IP address of the compute instance |
instance_name |
Name of the compute instance |
instance_zone |
Zone where the instance is deployed |
operating_system |
Operating system version selected |
ssh_user |
SSH username for the operating system |
deployment_summary |
Summary of all deployed resources |
Ansible integration Copied
Ansible playbooks are automatically executed after the creation of the virtual machine. These are used to:
- Configure the Netprobe service.
- Set up monitoring connections to the Gateway.
- Apply environment-specific settings.
- Install the required dependencies.
Troubleshooting Copied
You can run the given commands if you encounter the following issues:
Issue type | Command |
---|---|
Authentication issues |
|
Project and API issues |
|
Instance issues |
|
Image issues |
|
SSH connection issues |
|
Ansible deployment issues |
|
Terraform commands Copied
Run the following Terraform commands to deploy the infrastructure.
Command | Command |
---|---|
Initialize Terraform |
|
Plan the deployment |
|
Apply the deployment |
|
Show the deployment options |
|
Destroy the deployment |
|
Netprobe Configuration Copied
The netprobe.yml
file contains Ansible configuration for Netprobe deployment. For general configuration structure and available parameters, refer to Ansible configuration.
Update the following environment-specific settings in netprobe.yml
file for your GCP development environment:
SSH configuration Copied
# SSH connection configuration (required)
ansible_ssh_private_key_file: "../../../../resources/id_rsa"
ansible_ssh_common_args: "-o ControlMaster=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
Bootstrap configuration Copied
# Set to false for dev environments (minimal bootstrap)
perform_bootstrap: false
# GCP Cloud Storage library installation if perform_bootstrap is true
additional_bootstrap: "{{ python_path }} -m pip install --upgrade google-cloud-storage"
Cloud provider configuration Copied
resources:
# Google Cloud Storage configuration
source:
gcp:
auth_kind: "machineaccount"
# credential: "service-account@project-id.iam.gserviceaccount.com" # Optional override
# Cloud storage container
container: geneos
# Resource paths
path: netprobe.tar.gz
setupfile:
path: netprobe.setup_template.xml
Gateway connection Copied
env_vars:
# Gateway information (configure for your setup)
GATEWAY_HOST: "0.0.0.0"
GATEWAY_PORT: "7039"
Netprobe connection Copied
env_vars:
# Netprobe information
SERVICE_PARAM: "-port 7036 -setup {{ workspace_dir }}/{{ resources.setupfile.path | basename }}"