Skip to content

Commit 579de9e

Browse files
committed
vdi module - password reset handling
1 parent 4d2fb3e commit 579de9e

31 files changed

Lines changed: 2053 additions & 15367 deletions

community/modules/scripts/vdi-setup/README.md

Lines changed: 45 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,37 @@
22

33
Creates a containerised Guacamole instance. Works with the Rocky, Debian and Ubuntu images shown in blueprint example below.
44

5-
### Secret Manager Integration
5+
## Features
66

7-
The VDI module supports flexible Secret Manager integration:
7+
- **VDI Tool Support**: Currently supports Guacamole for web-based VDI access
8+
- **User Provisioning**: Supports local user creation with secure password management
9+
- **VNC Integration**: Configures VNC servers for desktop access
10+
- **Secret Manager Integration**: Secure password storage and retrieval for VDI users and webapp admin
11+
- **VDI Monitoring System**: Automatic monitoring and reconfiguration capabilities with password reset flags and deployment status updates
12+
- **Debug Mode**: Comprehensive logging when enabled via the `debug` variable
813

9-
- **Default Behavior**: Secrets are stored in the deployment project
10-
- **Automatic Password Generation**: If no `secret_name` is provided, random passwords are generated and stored
11-
- **Existing Secret Retrieval**: Provide `secret_name` to use existing secrets from Secret Manager
12-
- **Cross-Project Secrets**: Use `secret_project` to specify a different GCP project if providing secrets
14+
## Secret Manager Integration
1315

14-
## Basic Example (Guacamole)
16+
The module integrates with Google Cloud Secret Manager for secure password handling:
17+
18+
- **VDI Users**: Passwords are stored in Secret Manager with the pattern `vdi-user-password-{username}-{deployment_name}`
19+
- **Webapp Admin**: Password is stored in Secret Manager with the pattern `webapp-server-password-{deployment_name}` (always stored, not just when reset is enabled)
20+
- **Password Sources**: Users can specify `secret_name` to fetch existing passwords, provide `password` directly, or let the system generate random passwords
21+
- **Reset Functionality**: Both individual user passwords (`reset_password`) and webapp admin password (`reset_webapp_admin_password`) can be forced to regenerate
22+
- **Database Updates**: Password resets update existing database records without re-initializing the entire database
23+
24+
## VDI Monitoring System
25+
26+
The module includes a monitoring system that:
27+
28+
- **Deployment Status**: Updates instance metadata to reflect deployment state (`available`, `reconfiguring`)
29+
- **Password Reset Flags**: Supports `reset_password` for individual users and `reset_webapp_admin_password` for the webapp admin account
30+
- **Automatic Reconfiguration**: Detects changes and triggers reconfiguration when needed
31+
- **Status Tracking**: Maintains deployment status through instance metadata
32+
33+
## Usage
34+
35+
### Basic Configuration
1536

1637
```yaml
1738
blueprint_name: vdi-test
@@ -51,9 +72,13 @@ deployment_groups:
5172
settings:
5273
vnc_flavor: tigervnc
5374
vdi_tool: guacamole
54-
user_provision: local_users
5575
vdi_user_group: vdiusers
5676
vdi_resolution: 1920x1080
77+
# Enable debug mode for verbose logging
78+
debug: true
79+
# Force reset of webapp admin password (optional)
80+
reset_webapp_admin_password: false
81+
user_provision: local_users
5782
vdi_users:
5883
# Alice: password generated and saved to Secret Manager in deployment project
5984
- username: alice
@@ -67,6 +92,10 @@ deployment_groups:
6792
port: 5903
6893
secret_name: charlie-password
6994
secret_project: another-project-id
95+
# David: auto-generated password with reset flag (triggers password regeneration)
96+
- username: david
97+
port: 5904
98+
reset_password: true
7099

71100
- id: guac_vm
72101
source: modules/compute/vm-instance
@@ -79,6 +108,8 @@ deployment_groups:
79108
#project: debian-cloud
80109
#family: ubuntu-2204-lts
81110
#project: ubuntu-os-cloud
111+
name_prefix: debian
112+
add_deployment_name_before_prefix: true
82113
machine_type: e2-highcpu-8
83114
tags: ["guacamole"]
84115
use:
@@ -98,18 +129,18 @@ echo -n "BobPassword123" | gcloud secrets create a-password-for-bob --data-file=
98129
echo -n "CharliePassword123" | gcloud secrets create charlie-password --data-file=- --project=another-project-id
99130
```
100131

101-
### Accessing Guacamole VDI
132+
### Accessing VDI
102133

103134
After deployment, you can access the VDI in several ways:
104135

105-
1. **Guacamole Web Interface**:
136+
1. **Web Interface** (for Guacamole):
106137
- Access web interface:
107138
- http://$VM_PUBLIC_IP:8080/guacamole/#/
108-
- Note: It is not advisable to serve Guacamole directly from a public IP in production environments. You should consider placing the VDI behind a reverse proxy, load balancer, or tunnel to it directly over IAP (see below).
139+
- Note: It is not advisable to serve the web interface directly from a public IP in production environments. You should consider placing the VDI behind a reverse proxy, load balancer, or tunnel to it directly over IAP (see below).
109140

110141
- Admin credentials:
111-
- Username: `guacadmin`
112-
- Password: Retrieve the `webapp-server...` secret from Secret Manager
142+
- Username: `guacadmin` (for Guacamole)
143+
- Password: Retrieve the `webapp-server-password-{deployment_name}` secret from Secret Manager
113144

114145
2. **User VDI Access**:
115146
- Each user's credentials are stored in Secret Manager
@@ -124,65 +155,4 @@ After deployment, you can access the VDI in several ways:
124155
--zone=us-central1-a
125156
```
126157

127-
- Guacamole will then be accessible from http://localhost:8080/guacamole/
128-
129-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
130-
## Requirements
131-
132-
| Name | Version |
133-
|------|---------|
134-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
135-
| <a name="requirement_archive"></a> [archive](#requirement\_archive) | ~> 2.0 |
136-
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 3.83 |
137-
138-
## Providers
139-
140-
| Name | Version |
141-
|------|---------|
142-
| <a name="provider_archive"></a> [archive](#provider\_archive) | ~> 2.0 |
143-
| <a name="provider_google"></a> [google](#provider\_google) | >= 3.83 |
144-
| <a name="provider_terraform"></a> [terraform](#provider\_terraform) | n/a |
145-
146-
## Modules
147-
148-
| Name | Source | Version |
149-
|------|--------|---------|
150-
| <a name="module_startup_script"></a> [startup\_script](#module\_startup\_script) | ../../../../modules/scripts/startup-script | n/a |
151-
152-
## Resources
153-
154-
| Name | Type |
155-
|------|------|
156-
| [google_storage_bucket.bucket](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket) | resource |
157-
| [terraform_data.input_validation](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
158-
| [archive_file.roles_tar](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
159-
160-
## Inputs
161-
162-
| Name | Description | Type | Default | Required |
163-
|------|-------------|------|---------|:--------:|
164-
| <a name="input_deployment_name"></a> [deployment\_name](#input\_deployment\_name) | The name of the deployment. | `string` | n/a | yes |
165-
| <a name="input_labels"></a> [labels](#input\_labels) | Key-value pairs of labels to be added to created resources. | `map(string)` | n/a | yes |
166-
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Project in which the HPC deployment will be created. | `string` | n/a | yes |
167-
| <a name="input_region"></a> [region](#input\_region) | Region to place bucket containing startup script. | `string` | n/a | yes |
168-
| <a name="input_user_provision"></a> [user\_provision](#input\_user\_provision) | User type to create (local\_users supported. os-login to do. | `string` | `"local_users"` | no |
169-
| <a name="input_vdi_resolution"></a> [vdi\_resolution](#input\_vdi\_resolution) | Desktop resolution for VNC sessions (e.g. 1920x1080). | `string` | `"1920x1080"` | no |
170-
| <a name="input_vdi_tool"></a> [vdi\_tool](#input\_vdi\_tool) | VDI tool to deploy (guacamole currently supported). | `string` | `"guacamole"` | no |
171-
| <a name="input_vdi_user_group"></a> [vdi\_user\_group](#input\_vdi\_user\_group) | Unix group to create/use for VDI users. | `string` | `"vdiusers"` | no |
172-
| <a name="input_vdi_users"></a> [vdi\_users](#input\_vdi\_users) | List of VDI users to configure. Passwords are handled securely by the Ansible roles: if secret\_name is provided, the password is fetched from Secret Manager; if neither password nor secret\_name is provided, a random password is generated and stored in Secret Manager. If secret\_project is provided, it specifies the GCP project where the secret is stored (defaults to the deployment project). | <pre>list(object({<br/> username = string<br/> port = number<br/> secret_name = optional(string)<br/> secret_project = optional(string)<br/> }))</pre> | `[]` | no |
173-
| <a name="input_vdi_webapp_port"></a> [vdi\_webapp\_port](#input\_vdi\_webapp\_port) | Port to serve the Webapp interface from if applicable | `string` | `"8080"` | no |
174-
| <a name="input_vnc_flavor"></a> [vnc\_flavor](#input\_vnc\_flavor) | The VNC server flavor to use (tigervnc currently supported) | `string` | `"tigervnc"` | no |
175-
| <a name="input_vnc_port_max"></a> [vnc\_port\_max](#input\_vnc\_port\_max) | Maximum valid VNC port. | `number` | `5999` | no |
176-
| <a name="input_vnc_port_min"></a> [vnc\_port\_min](#input\_vnc\_port\_min) | Minimum valid VNC port. | `number` | `5901` | no |
177-
| <a name="input_debug"></a> [debug](#input\_debug) | Enable debug mode for verbose logging during VDI setup. | `bool` | `false` | no |
178-
179-
## Outputs
180-
181-
| Name | Description |
182-
|------|-------------|
183-
| <a name="output_guacamole_admin_password_secret"></a> [guacamole\_admin\_password\_secret](#output\_guacamole\_admin\_password\_secret) | The name of the Secret Manager secret containing the Guacamole admin password |
184-
| <a name="output_guacamole_admin_username"></a> [guacamole\_admin\_username](#output\_guacamole\_admin\_username) | The admin username for Guacamole |
185-
| <a name="output_startup_script"></a> [startup\_script](#output\_startup\_script) | Combined startup script that installs VDI (VNC, Guacamole, users). |
186-
| <a name="output_vdi_runner"></a> [vdi\_runner](#output\_vdi\_runner) | Shell runner wrapping Ansible playbook + roles (for custom-image or direct use). |
187-
| <a name="output_vdi_user_credentials"></a> [vdi\_user\_credentials](#output\_vdi\_user\_credentials) | Map of VDI user credentials stored in Secret Manager |
188-
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
158+
- The web interface will then be accessible from http://localhost:8080/guacamole/ (for Guacamole)

community/modules/scripts/vdi-setup/VDI_IDEMPOTENCY_IMPLEMENTATION_PLAN.md

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)