From 806e70a4cb92fcaf29865e5518601cfb667c8c6d Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 11:55:07 -0500 Subject: [PATCH 01/22] Add the SCVMM Lab on AWS blueprint Builds an SCVMM 2025 test lab on AWS in an existing domain: two or more nested-virtualization Hyper-V hosts in a failover cluster, iSCSI shared storage from a gp3 volume on the SCVMM server, and SCVMM managing the cluster. Five build plug-ins and a CNO teardown share the scvmm_lab module, which runs guest steps as marker-reporting PowerShell or polled scheduled tasks (the domain account's steps sign in as that account) and makes the EC2 calls through the AWS handler, adding NestedVirtualization to the signed request because the appliance's botocore predates it. SCVMM media comes from File Archives (SCVMM_2025.zip, unchanged); SQL Server 2022 Developer and the Windows ADK download from Microsoft. Not yet run on an appliance; the README lists what is untested. Co-Authored-By: Claude Opus 5.5 --- CATALOG.md | 18 +- .../BP-9zp8udce/BP-9zp8udce_metadata.json | 224 ++++++ blueprints/BP-9zp8udce/README.md | 83 +++ blueprints/README.md | 1 + catalog.json | 126 ++++ .../OHK-77f19kly/OHK-77f19kly_metadata.json | 16 + plugins/OHK-77f19kly/OHK-77f19kly_script.py | 157 ++++ .../OHK-8f9o1496/OHK-8f9o1496_metadata.json | 17 + plugins/OHK-8f9o1496/OHK-8f9o1496_script.py | 230 ++++++ .../OHK-8ioy2cbi/OHK-8ioy2cbi_metadata.json | 16 + plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py | 193 +++++ .../OHK-ive3ka22/OHK-ive3ka22_metadata.json | 16 + plugins/OHK-ive3ka22/OHK-ive3ka22_script.py | 79 ++ .../OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json | 16 + plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py | 60 ++ .../OHK-q6fb9833/OHK-q6fb9833_metadata.json | 16 + plugins/OHK-q6fb9833/OHK-q6fb9833_script.py | 151 ++++ plugins/README.md | 6 + shared_modules/README.md | 5 +- .../SHM-dpj24dfj/SHM-dpj24dfj_metadata.json | 12 + .../SHM-dpj24dfj/SHM-dpj24dfj_script.py | 679 ++++++++++++++++++ 21 files changed, 2114 insertions(+), 7 deletions(-) create mode 100644 blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json create mode 100644 blueprints/BP-9zp8udce/README.md create mode 100644 plugins/OHK-77f19kly/OHK-77f19kly_metadata.json create mode 100644 plugins/OHK-77f19kly/OHK-77f19kly_script.py create mode 100644 plugins/OHK-8f9o1496/OHK-8f9o1496_metadata.json create mode 100644 plugins/OHK-8f9o1496/OHK-8f9o1496_script.py create mode 100644 plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_metadata.json create mode 100644 plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py create mode 100644 plugins/OHK-ive3ka22/OHK-ive3ka22_metadata.json create mode 100644 plugins/OHK-ive3ka22/OHK-ive3ka22_script.py create mode 100644 plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json create mode 100644 plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py create mode 100644 plugins/OHK-q6fb9833/OHK-q6fb9833_metadata.json create mode 100644 plugins/OHK-q6fb9833/OHK-q6fb9833_script.py create mode 100644 shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_metadata.json create mode 100644 shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py diff --git a/CATALOG.md b/CATALOG.md index b2aed558..cb21ee32 100644 --- a/CATALOG.md +++ b/CATALOG.md @@ -6,15 +6,15 @@ Every piece of content in this repo, grouped by type. Names and descriptions com | Type | Count | |---|---| | [Packages](#packages) | 11 | -| [Blueprints](#blueprints) | 34 | +| [Blueprints](#blueprints) | 35 | | [Resource actions](#resource-actions) | 65 | | [Server actions](#server-actions) | 3 | | [Orchestration actions](#orchestration-actions) | 22 | | [Recurring jobs](#recurring-jobs) | 5 | | [Webhooks](#webhooks) | 5 | | [MCP tool actions](#mcp-tool-actions) | 9 | -| [Plugins](#plugins) | 198 | -| [Shared modules](#shared-modules) | 25 | +| [Plugins](#plugins) | 204 | +| [Shared modules](#shared-modules) | 26 | | [UI extensions](#ui-extensions) | 15 | | [Parameters](#parameters) | 3 | | [Runbook workflows](#runbook-workflows) | 2 | @@ -75,6 +75,7 @@ Orderable resources. Each folder has a README with contents, prerequisites, and | Run an Azure PowerShell Script | [BP-jvvjm3te](blueprints/BP-jvvjm3te/README.md) | Runs one of a catalog of Azure PowerShell Remote Scripts against the Azure subscription of a chosen Environment on a Windows host you manage (the script's Run on Server), with the sign-in handled by CloudBolt from the environment's resource handler. | | Run an Azure PowerShell Script (Deployment Script) | [BP-qo1stxre](blueprints/BP-qo1stxre/README.md) | Runs one of a catalog of Azure PowerShell Remote Scripts against the Azure subscription of a chosen Environment in a Microsoft-managed container started per run through an ARM deployment script, with no server to maintain and the sign-in handled by CloudBolt from the environment's resource handler. | | Run Aria Orchestrator Workflow | [BP-f5y1fhe9](blueprints/BP-f5y1fhe9/README.md) | Runs an Aria Orchestrator workflow as a CloudBolt resource build, stores the workflow outputs on the resource, and runs it again with teardown parameters on delete. | +| SCVMM Lab on AWS | [BP-9zp8udce](blueprints/BP-9zp8udce/README.md) | Builds an SCVMM 2025 test lab on AWS: two or more nested-virtualization Hyper-V hosts in a failover cluster with iSCSI shared storage, and an SCVMM server that manages the cluster, all joined to an existing domain. | | Server with Data Disks | [BP-g9zwqjoa](blueprints/BP-g9zwqjoa/README.md) | Deploys a Windows Server or Oracle Linux VM whose order form turns the environment's disk_map parameter into a table of data disks, which the disk map orchestration actions attach and prepare inside the guest. | | Windows File Server | [BP-psw7rclb](blueprints/BP-psw7rclb/README.md) | Deploys a Windows server and installs the File Server role. | | Windows Server with Data Disks | [BP-9ph7xcok](blueprints/BP-9ph7xcok/README.md) | Deploys a Windows Server 2025 VM with an order-time list of data disks, attaching each one and then matching it inside the guest by serial number or SCSI address to initialize, letter, label, and format it. | @@ -242,6 +243,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Add AKS Node Pool | [OHK-b7poza8x](plugins/OHK-b7poza8x/) | Adds a User or System node pool on the control plane's Kubernetes version to the AKS cluster, optionally autoscaled and spread across availability zones, and records it as an AKS Node Pool sub-resource. | CloudBolt Plug-in | [Add AKS Node Pool](resource_actions/RSA-wxd1o7s8/) | | Add AWS EKS Nodegroup | [OHK-bfhdr8vx](plugins/OHK-bfhdr8vx/) | Creates a managed node group on the EKS cluster with the chosen AMI type, instance type, disk size, and scaling bounds, and records it as a sub-resource. | CloudBolt Plug-in | [Add AWS EKS Nodegroup](resource_actions/RSA-f9ivvn5q/) | | Add GKE Node Pool | [OHK-aaltlvmb](plugins/OHK-aaltlvmb/) | Adds a node pool on the control plane's version to the GKE cluster, optionally autoscaled or on Spot VMs, and records it as a GKE Node Pool sub-resource. | CloudBolt Plug-in | [Add GKE Node Pool](resource_actions/RSA-hg13ra5x/) | +| Add Hyper-V Cluster to SCVMM | [OHK-ive3ka22](plugins/OHK-ive3ka22/) | Adds the SCVMM lab's failover cluster to SCVMM under All Hosts with a Run As account for the domain service account. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Add Parent Blueprints to Group | [OHK-tswevdir](plugins/OHK-tswevdir/) | Grants a newly created group explicit deploy permission on every blueprint that one of its ancestor groups is explicitly permitted to deploy. | CloudBolt Plug-in | [Add Parent Blueprints to Group](orchestration_actions/HPA-1lp8xqo3/README.md) | | Add Resource Group to Environment | [OHK-r1imfgdx](plugins/OHK-r1imfgdx/) | Adds the created resource group as a resource_group_arm option on the provisioning environment. | CloudBolt Plug-in | [Azure Resource Group - Bicep](blueprints/BP-p7zmh96m/README.md) | | AKS Cluster Build | [OHK-x13tmam0](plugins/OHK-x13tmam0/) | Creates an AKS cluster with Microsoft Entra ID and Azure RBAC, Azure CNI Overlay with Cilium, and automatic upgrades, registers it as a CloudBolt Kubernetes container orchestrator, and records its node pools. | CloudBolt Plug-in | [Azure Kubernetes Service](blueprints/BP-20q58q9z/README.md) | @@ -287,6 +289,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Configure Data Disks (Windows) | [OHK-ea8opsps](plugins/OHK-ea8opsps/) | Matches each attached data disk to its Windows disk by serial number, LUN, SCSI target, or attach order, then initializes it GPT and formats it NTFS with the requested drive letter and label. | Remote Script | [Windows Server with Data Disks](blueprints/BP-9ph7xcok/README.md) | | Configure Data Disks from Disk Map (Oracle Linux) | [OHK-9h9vphf5](plugins/OHK-9h9vphf5/) | Prepares the disks from a Linux server's disk_map in the guest: matches each one by serial number, SCSI address, or attach order, then creates an LVM volume with an XFS file system and mounts it. | CloudBolt Plug-in | [Configure Data Disks from Disk Map (Oracle Linux)](orchestration_actions/HPA-4ptcwgg4/README.md) | | Configure Data Disks from Disk Map (Windows) | [OHK-pdwb3xso](plugins/OHK-pdwb3xso/) | Formats the disks from a Windows server's disk_map in the guest: matches each one by serial number, SCSI address, or attach order, then initializes it GPT and formats it NTFS with its drive letter and label. | CloudBolt Plug-in | [Configure Data Disks from Disk Map (Windows)](orchestration_actions/HPA-42uy9dyo/README.md) | +| Configure Hyper-V Hosts | [OHK-8ioy2cbi](plugins/OHK-8ioy2cbi/) | Installs Hyper-V and Failover Clustering on the SCVMM lab hosts, creates their NAT switch, and connects them to the iSCSI disks it creates on the SCVMM server. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Configure Linux App Host | [OHK-o30l8kjn](plugins/OHK-o30l8kjn/) | Writes a systemd-tmpfiles log retention rule and a host profile for an application account on a Linux VM, from a config file in File Archives and the outputs of the earlier steps. | Remote Script | [Prepare Linux app host](runbook_workflows/SWF-69r5mmdb/README.md) | | Configure Windows App Host | [OHK-lkmy7ij9](plugins/OHK-lkmy7ij9/) | Records application settings in the registry, schedules a daily log clean-up and writes an Application event on a Windows VM, from a config file in File Archives and the outputs of the earlier steps. | Remote Script | [Prepare Windows app host](runbook_workflows/SWF-7s01lyyk/README.md) | | Create AKS Namespace | [OHK-kb4pv2yq](plugins/OHK-kb4pv2yq/) | Creates a namespace landing zone on this AKS cluster for a chosen CloudBolt group, filed as an AKS Namespace resource with the same quota, policies, and pinned environment as an ordered one. | CloudBolt Plug-in | [Create AKS Namespace](resource_actions/RSA-jttbwkm5/) | @@ -294,6 +297,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Create Blob Container | [OHK-l25x6wd8](plugins/OHK-l25x6wd8/) | Creates a blob container in the resource's Azure storage account. | CloudBolt Plug-in | [Create Blob Container](resource_actions/RSA-xzs5f3a2/) | | Create Environment | [OHK-yd1af0eu](plugins/OHK-yd1af0eu/) | Creates a CloudBolt environment on an AWS handler with the region and VPC stored as custom field values. | CloudBolt Plug-in | [Create VPC](blueprints/BP-n454hj40/README.md) | | Create GKE Namespace | [OHK-cco2r73h](plugins/OHK-cco2r73h/) | Creates a namespace landing zone on this GKE cluster for a chosen CloudBolt group, filed as a GKE Namespace resource with the same quota, policies, and pinned environment as an ordered one. | CloudBolt Plug-in | [Create GKE Namespace](resource_actions/RSA-yrnl5j6j/) | +| Create Hyper-V Cluster | [OHK-77f19kly](plugins/OHK-77f19kly/) | Creates the SCVMM lab's failover cluster as the domain service account with one IP address resource per host, a cluster shared volume and a disk witness. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Create Linux App Account | [OHK-4etpeg05](plugins/OHK-4etpeg05/) | Creates the system group, no-login system user and home directory named in a config file from File Archives on a Linux VM, when they do not exist, and outputs the account and home directory. | Remote Script | [Prepare Linux app host](runbook_workflows/SWF-69r5mmdb/README.md) | | Create Windows App Folders | [OHK-7fxxufkt](plugins/OHK-7fxxufkt/) | Creates the local operators group and application folders named in a config file from File Archives on a Windows VM, when they do not exist, gives the group Modify on them, and outputs the root and group. | Remote Script | [Prepare Windows app host](runbook_workflows/SWF-7s01lyyk/README.md) | | Delete AKS Node Pool | [OHK-czexzrl1](plugins/OHK-czexzrl1/) | Deletes a chosen node pool from the AKS cluster, refusing the cluster's only System pool, and removes its AKS Node Pool sub-resource. | CloudBolt Plug-in | [Delete AKS Node Pool](resource_actions/RSA-j4f98ti1/) | @@ -344,6 +348,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Install IIS Windows | [OHK-0ql0870k](plugins/OHK-0ql0870k/) | Installs IIS on a Windows server. | Remote Script | [IIS Web Application](blueprints/BP-122nbdt5/README.md) | | Install NGINX OEL8 | [OHK-2vdm93hu](plugins/OHK-2vdm93hu/) | Installs NGINX on an Oracle Linux 8 server. | Remote Script | [NGINX Web Application](blueprints/BP-anonytrx/README.md) | | Install Postgres | [OHK-29uent0x](plugins/OHK-29uent0x/) | Installs PostgreSQL on an Oracle Linux 8 server. | Remote Script | [Postgres Database](blueprints/BP-b91c5f90/README.md) | +| Install SCVMM | [OHK-8f9o1496](plugins/OHK-8f9o1496/) | Installs SQL Server 2022 Developer, the Windows ADK with the WinPE add-on and SCVMM 2025 from File Archives on the SCVMM lab's management server. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Install Windows File Server | [OHK-up7829pv](plugins/OHK-up7829pv/) | Installs the File Server role on a Windows server. | Remote Script | [Windows File Server](blueprints/BP-psw7rclb/README.md) | | Join Linux Server to AD Domain | [OHK-exqmrl0e](plugins/OHK-exqmrl0e/) | Joins a Linux server to Active Directory with realmd, SSSD, and adcli using its LDAP utility's credentials. | CloudBolt Plug-in | [Join Linux Server to AD Domain](orchestration_actions/HPA-o6ctckmt/README.md) | | Join Windows Server to AD Domain | [OHK-9oqn6pur](plugins/OHK-9oqn6pur/) | Joins a Windows server with Add-Computer to the Active Directory OU its domain_ou names under its CloudBolt hostname, renaming the guest when needed, switches its CloudBolt credentials to the domain_service_account connection info when set, then waits for the restart and verifies the name and secure channel. | CloudBolt Plug-in | [Join Windows Server to AD Domain](orchestration_actions/HPA-jjp1vlfi/README.md) | @@ -375,6 +380,8 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Node Size - Generate Options by Region, OS Image, Security, Networking and Storage (Azure SKU capabilities) | [OHK-kujhsds0](plugins/OHK-kujhsds0/README.md) | Generates node_size options filtered by live Azure SKU capabilities for the selected region, image, security, networking, and storage settings. | CloudBolt Plug-in | standalone | | OpenShift Project Landing Zone | [OHK-prew0osh](plugins/OHK-prew0osh/) | Creates an OpenShift project with quota, limits, network policies, and an optional role binding, then pins a CloudBolt environment to it. | CloudBolt Plug-in | [OpenShift Project Landing Zone](blueprints/BP-tikkhf2y/README.md) | | Order Counts by Blueprint | [OHK-yjblxbwg](plugins/OHK-yjblxbwg/) | | CloudBolt Plug-in | [Order Counts by Blueprint](mcp_tool_actions/MTA-lp8lgi7e/) | +| Prepare SCVMM Lab on AWS | [OHK-q6fb9833](plugins/OHK-q6fb9833/) | Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | +| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](plugins/OHK-kzb6pzzu/) | Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Remove Resource Group from Environments | [OHK-vm5p34w3](plugins/OHK-vm5p34w3/) | Removes the deleted resource group's resource_group_arm option from environments on the same subscription. | CloudBolt Plug-in | [Azure Resource Group - Bicep](blueprints/BP-p7zmh96m/README.md) | | Remove Servers from Ansible Automation Platform | [OHK-8v830go3](plugins/OHK-8v830go3/) | Removes the host records a deployment's servers hold in Ansible Automation Platform inventories through CloudBolt's own connector method, before the infrastructure is destroyed; a missing host or unreachable AAP is a warning, never a blocker. | CloudBolt Plug-in | standalone | | Request AKS Namespace Quota Change | [OHK-jeighfcq](plugins/OHK-jeighfcq/) | Moves an AKS namespace landing zone to a different size tier after approval and mirrors the new quota into its environment. | CloudBolt Plug-in | [Request AKS Namespace Quota Change](resource_actions/RSA-7wdigcpr/) | @@ -442,7 +449,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | Module | ID | Description | Used by | |---|---|---|---| -| `ad_domain` | [SHM-gcba1u31](shared_modules/SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects. | [Delete Windows Computer Object from AD](plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](plugins/OHK-9oqn6pur/), [Suggest Domain OUs](plugins/OHK-z9qrccyu/) | +| `ad_domain` | [SHM-gcba1u31](shared_modules/SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects. | [Delete Windows Computer Object from AD](plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](plugins/OHK-9oqn6pur/), [Remove Hyper-V Cluster Object](plugins/OHK-kzb6pzzu/), [Suggest Domain OUs](plugins/OHK-z9qrccyu/) | | `aks_namespace` | [SHM-cozv547n](shared_modules/SHM-cozv547n/) | Managed-namespace landing zones, Azure RBAC namespace access, connection details, and GitHub pipeline identities for the AKS Namespace blueprint. | [AKS Namespace](plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](plugins/OHK-vi009xb8/), [Create AKS Namespace](plugins/OHK-kb4pv2yq/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover AKS Namespaces](plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](plugins/OHK-t1r0y1yd/), [Manage AKS Namespace Access](plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](plugins/OHK-jeighfcq/), [Teardown AKS Namespace](plugins/OHK-wmdr2ef5/) | | `aria_connection` | [SHM-u2s2d40p](shared_modules/SHM-u2s2d40p/) | Aria Automation 8 and Aria Orchestrator REST clients built on a CloudBolt ConnectionInfo labeled vra8 or aria, with generate-options helpers for connection and project dropdowns. | [Aria Migration Form Options](plugins/OHK-xhpq1rn3/), [Migrate Aria Automation Deployments](plugins/OHK-7sq2hqrb/), [Migrate Aria Automation Projects](plugins/OHK-gyl8wlrq/), [Run Aria Orchestrator Workflow](plugins/OHK-3bgpjmlr/) | | `azure_aks` | [SHM-ptvp0km4](shared_modules/SHM-ptvp0km4/) | ARM client, cluster and node pool operations, orchestrator registration, and role-assignment helpers for Azure Kubernetes Service content. | [Add AKS Node Pool](plugins/OHK-b7poza8x/), [AKS Cluster Build](plugins/OHK-x13tmam0/), [AKS Cluster Discovery](plugins/OHK-uof2rcaa/), [AKS Cluster Teardown](plugins/OHK-27oemiwb/), [AKS Namespace](plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](plugins/OHK-vi009xb8/), [Create AKS Namespace](plugins/OHK-kb4pv2yq/), [Delete AKS Node Pool](plugins/OHK-czexzrl1/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover AKS Namespaces](plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](plugins/OHK-t1r0y1yd/), [List AKS Node Pools](plugins/OHK-0fp008gh/), [Manage AKS Cluster Groups](plugins/OHK-yzmq0kzu/), [Manage AKS Namespace Access](plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](plugins/OHK-jeighfcq/), [Scale AKS Node Pool](plugins/OHK-80c4ibdb/), [Teardown AKS Namespace](plugins/OHK-wmdr2ef5/), [Upgrade AKS Node Pool](plugins/OHK-t0j1w09c/), [Upgrade AKS Version](plugins/OHK-ojf2vvq1/) | @@ -455,7 +462,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | `disk_map` | [SHM-8qcvbri7](shared_modules/SHM-8qcvbri7/) | Parses and validates a server's disk_map parameter for its operating system and runs the in-guest data disk scripts of the disk map orchestration actions. | [Attach Data Disks from Disk Map](plugins/OHK-jzkblrv7/), [Configure Data Disks from Disk Map (Oracle Linux)](plugins/OHK-9h9vphf5/), [Configure Data Disks from Disk Map (Windows)](plugins/OHK-pdwb3xso/) | | `eks_namespace` | [SHM-sa5yqm9j](shared_modules/SHM-sa5yqm9j/) | Kubernetes API client on the EKS cluster's orchestrator, size-tier catalog, and cluster lookups for the AWS EKS Namespace blueprint. | [AWS EKS Namespace](plugins/OHK-u9jm7p8h/), [AWS EKS Namespace Connection Details](plugins/OHK-7n4o0hox/), [Create AWS EKS Namespace](plugins/OHK-oguk4oad/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover AWS EKS Namespaces](plugins/OHK-ow9x0amc/), [Extend AWS EKS Namespace Expiration](plugins/OHK-paad1c56/), [Manage AWS EKS Namespace Access](plugins/OHK-3902mdky/), [Manage AWS EKS Namespace Pipeline Identity](plugins/OHK-h9moajbi/), [Request AWS EKS Namespace Quota Change](plugins/OHK-arour20h/), [Teardown AWS EKS Namespace](plugins/OHK-bnano0nc/) | | `env_options` | [SHM-r0oq14r7](shared_modules/SHM-r0oq14r7/) | RBAC-gated option sources (resource groups, subnets, images, sizes, any custom field) derived from a CloudBolt Environment for order-form dropdowns and build plugins. | [Azure PS Script Panel](plugins/OHK-bvn2l7q1/), [Compare Azure List Prices](plugins/OHK-r9cm4oar/), [Discover HCP Terraform No-Code Workspaces](plugins/OHK-b1n02ula/), [Form Options](plugins/OHK-fx500o2r/), [Generate options for HCP Terraform coordinates](plugins/OHK-529jjzli/), [HCP Terraform No-Code Module](plugins/OHK-axtt0yqq/), [HCP Terraform VM](plugins/OHK-pvo05e24/), [Run Azure PowerShell Script](plugins/OHK-pmyb1car/), [Run Azure PowerShell Script (Deployment Script)](plugins/OHK-oblhxhw2/) | -| `file_archives` | [SHM-v8llc736](shared_modules/SHM-v8llc736/) | Stores versioned files on the CloudBolt appliance, signs short-lived download links for them, and adds the download step to scripts that declare files with cb-archive header lines. | [Run Task](plugins/OHK-o4tgygjs/) | +| `file_archives` | [SHM-v8llc736](shared_modules/SHM-v8llc736/) | Stores versioned files on the CloudBolt appliance, signs short-lived download links for them, and adds the download step to scripts that declare files with cb-archive header lines. | [Install SCVMM](plugins/OHK-8f9o1496/), [Run Task](plugins/OHK-o4tgygjs/) | | `gcp_gke` | [SHM-4yw92b8x](shared_modules/SHM-4yw92b8x/) | GKE API client, cluster and node pool operations, Kubernetes API access verified against the cluster CA, orchestrator registration, and group entitlement helpers for Google Kubernetes Engine content. | [Add GKE Node Pool](plugins/OHK-aaltlvmb/), [Create GKE Namespace](plugins/OHK-cco2r73h/), [Delete GKE Node Pool](plugins/OHK-qxdrryt6/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover GKE Namespaces](plugins/OHK-ml7ee42y/), [Extend GKE Namespace Expiration](plugins/OHK-vtuzh4nh/), [GKE Cluster Build](plugins/OHK-shr5y3i6/), [GKE Cluster Discovery](plugins/OHK-6l86xugc/), [GKE Cluster Teardown](plugins/OHK-y9wx9bga/), [GKE Namespace](plugins/OHK-32pzj98f/), [GKE Namespace Connection Details](plugins/OHK-egyf9q28/), [List GKE Node Pools](plugins/OHK-niw4hc9m/), [Manage GKE Cluster Groups](plugins/OHK-m8iwylq8/), [Manage GKE Namespace Access](plugins/OHK-vdhjpyg2/), [Manage GKE Namespace Pipeline Identity](plugins/OHK-l3j30r89/), [Request GKE Namespace Quota Change](plugins/OHK-xg47m1x2/), [Scale GKE Node Pool](plugins/OHK-m0s3j1ax/), [Teardown GKE Namespace](plugins/OHK-jm8j1513/), [Upgrade GKE Node Pool](plugins/OHK-2rpjqm7u/), [Upgrade GKE Version](plugins/OHK-91bx99mg/) | | `github` | [SHM-eybr4hgz](shared_modules/SHM-eybr4hgz/) | GitHub API client that authenticates with the GitHub ConnectionInfo when one is usable and otherwise fetches public repositories anonymously, with directory listing, raw file download, and archive fetch. | [Bicep Engine Connectivity Check](plugins/OHK-b21biimg/), [Deploy Bicep Template](plugins/OHK-gqvi9kv4/), [Drift Check](plugins/OHK-9n4wfasa/), [Update Bicep Deployment](plugins/OHK-9f45ede7/) | | `gke_namespace` | [SHM-kephq8iq](shared_modules/SHM-kephq8iq/) | Namespace landing zones on GKE clusters: quota, limits, network policies, the pinned CloudBolt environment, Kubernetes RBAC access for Google identities, GitHub Actions pipeline identities, and connection details. | [Create GKE Namespace](plugins/OHK-cco2r73h/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover GKE Namespaces](plugins/OHK-ml7ee42y/), [Extend GKE Namespace Expiration](plugins/OHK-vtuzh4nh/), [GKE Namespace](plugins/OHK-32pzj98f/), [GKE Namespace Connection Details](plugins/OHK-egyf9q28/), [Manage GKE Namespace Access](plugins/OHK-vdhjpyg2/), [Manage GKE Namespace Pipeline Identity](plugins/OHK-l3j30r89/), [Request GKE Namespace Quota Change](plugins/OHK-xg47m1x2/), [Teardown GKE Namespace](plugins/OHK-jm8j1513/) | @@ -463,6 +470,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | `openshift_landing_zone` | [SHM-qmiweowv](shared_modules/SHM-qmiweowv/) | OpenShift REST client, size-tier catalog, and environment helpers for the landing-zone blueprint. | [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover OpenShift Project Landing Zones](plugins/OHK-e7albpni/), [Extend Expiration](plugins/OHK-3w9nejn3/), [Manage Team Access](plugins/OHK-9zzqqz7t/), [OpenShift Project Landing Zone](plugins/OHK-prew0osh/), [Request Quota Change](plugins/OHK-ug53cdbx/), [Teardown OpenShift Project Landing Zone](plugins/OHK-mpe8fl3d/) | | `runbook_tasks` | [SHM-571l7249](shared_modules/SHM-571l7249/) | Finds the Remote Scripts that can run on a VM, checks credentials and task inputs, and runs a chosen script for the Run Task action and its form webhook. | [Run Task](plugins/OHK-o4tgygjs/), [Runbook Tasks](plugins/OHK-bf3iyg9j/), [runbook_workflows](shared_modules/SHM-nznzhpp0/) | | `runbook_workflows` | [SHM-nznzhpp0](shared_modules/SHM-nznzhpp0/) | Stores workflows, works out which workflows and step actions fit a VM or a workflow's filters, builds the run form's prompts, and runs a workflow's steps in order with outputs passed between them, and exports and imports workflows for content packages. | [Run Workflow](plugins/OHK-69gk5ne9/), [Runbook Workflows](plugins/OHK-9ewh41dg/) | +| `scvmm_lab` | [SHM-dpj24dfj](shared_modules/SHM-dpj24dfj/) | Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler. | [Add Hyper-V Cluster to SCVMM](plugins/OHK-ive3ka22/), [Configure Hyper-V Hosts](plugins/OHK-8ioy2cbi/), [Create Hyper-V Cluster](plugins/OHK-77f19kly/), [Install SCVMM](plugins/OHK-8f9o1496/), [Prepare SCVMM Lab on AWS](plugins/OHK-q6fb9833/) | | `servicenow_requests` | [SHM-ww6b1uwj](shared_modules/SHM-ww6b1uwj/) | ServiceNow REQ/RITM client plus the order-summary, catalog-variable, and identifier-storage helpers shared by the ServiceNow request actions. | [ServiceNow Request Approval Sync](plugins/OHK-bsqictlo/), [ServiceNow Request: Close](plugins/OHK-htrxkps2/), [ServiceNow Request: Close on Denial](plugins/OHK-w8exctx7/), [ServiceNow Request: Open](plugins/OHK-o4qmnffy/) | | `tfc_api` | [SHM-jlguerjr](shared_modules/SHM-jlguerjr/) | HCP Terraform REST client and run engine for workspace-per-deployment provisioning. | [Deploy Latest Version](plugins/OHK-4y8f1vff/), [Discover HCP Terraform No-Code Workspaces](plugins/OHK-b1n02ula/), [Form Options](plugins/OHK-fx500o2r/), [Generate options for HCP Terraform coordinates](plugins/OHK-529jjzli/), [HCP Terraform No-Code Module](plugins/OHK-axtt0yqq/), [HCP Terraform VM](plugins/OHK-pvo05e24/), [Resize](plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](plugins/OHK-2b9qu490/), [Terraform Update](plugins/OHK-lvy5tj0y/) | | `vm_adoption` | [SHM-9h13o859](shared_modules/SHM-9h13o859/) | Adopts the VMs a Terraform deployment created (from its cloudbolt_vm_ids output) as CloudBolt Server records under the resource, hydrated through the Azure, AWS, or VMware handler, and retires them on teardown. | [Deploy Latest Version](plugins/OHK-4y8f1vff/), [HCP Terraform No-Code Module](plugins/OHK-axtt0yqq/), [HCP Terraform VM](plugins/OHK-pvo05e24/), [Resize](plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](plugins/OHK-2b9qu490/), [Terraform Update](plugins/OHK-lvy5tj0y/) | diff --git a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json new file mode 100644 index 00000000..b0a2015a --- /dev/null +++ b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json @@ -0,0 +1,224 @@ +{ + "any_group_can_deploy": false, + "auto_historical_resources": false, + "deployment_items": [ + { + "all_environments_enabled": false, + "allowed_os_families": [ + "Windows" + ], + "applications": null, + "deploy_seq": 1, + "description": "Windows Server 2025 Hyper-V hosts; order two or more. Use an instance type AWS lists as supporting nested virtualization (for example m8i, c8i, r8i or m7i sizes) or a .metal size.", + "environment_selection_orchestration": null, + "execute_in_parallel": true, + "hostname_template": "hvlab-00X", + "id": "BDI-wctopceu", + "name": "Hyper-V Hosts", + "os_build": { + "href": "/api/v3/cmp/osBuilds/OSB-35y5mshd/", + "title": "Windows 2025" + }, + "rate": null, + "restrict_applications": false, + "show_on_order_form": true, + "tier_type": "server" + }, + { + "all_environments_enabled": false, + "allowed_os_families": [ + "Windows" + ], + "applications": null, + "deploy_seq": 2, + "description": "Windows Server 2025 SCVMM management server; order one.", + "environment_selection_orchestration": null, + "execute_in_parallel": false, + "hostname_template": "vmmlab-00X", + "id": "BDI-olzewnbv", + "name": "SCVMM Server", + "os_build": { + "href": "/api/v3/cmp/osBuilds/OSB-35y5mshd/", + "title": "Windows 2025" + }, + "rate": null, + "restrict_applications": false, + "show_on_order_form": true, + "tier_type": "server" + }, + { + "action_name": "Prepare SCVMM Lab on AWS", + "continue_on_failure": false, + "dependencies": { + "hook": "plugins/OHK-q6fb9833" + }, + "deploy_seq": 3, + "description": "Turns on nested virtualization and adds a cluster IP address on each host, and attaches the storage volume to the SCVMM server and shares it to the hosts over iSCSI.", + "enabled": true, + "execute_in_parallel": false, + "id": "BDI-pbj83dx6", + "name": "Prepare SCVMM Lab on AWS", + "rate": null, + "run_on_scale_up": false, + "show_on_order_form": false, + "tier_type": "plugin" + }, + { + "action_name": "Install SCVMM", + "continue_on_failure": false, + "dependencies": { + "hook": "plugins/OHK-8f9o1496" + }, + "deploy_seq": 4, + "description": "Installs SQL Server Developer, the Windows ADK and SCVMM on the SCVMM server, while the hosts are configured.", + "enabled": true, + "execute_in_parallel": true, + "id": "BDI-1ezqmxtt", + "name": "Install SCVMM", + "rate": null, + "run_on_scale_up": false, + "show_on_order_form": false, + "tier_type": "plugin" + }, + { + "action_name": "Configure Hyper-V Hosts", + "continue_on_failure": false, + "dependencies": { + "hook": "plugins/OHK-8ioy2cbi" + }, + "deploy_seq": 5, + "description": "Installs Hyper-V and Failover Clustering on the hosts, connects them to the iSCSI disks and creates the NAT switch.", + "enabled": true, + "execute_in_parallel": false, + "id": "BDI-g70u7vc5", + "name": "Configure Hyper-V Hosts", + "rate": null, + "run_on_scale_up": false, + "show_on_order_form": false, + "tier_type": "plugin" + }, + { + "action_name": "Create Hyper-V Cluster", + "continue_on_failure": false, + "dependencies": { + "hook": "plugins/OHK-77f19kly" + }, + "deploy_seq": 6, + "description": "Creates the failover cluster with one IP address per host, a cluster shared volume and a disk witness.", + "enabled": true, + "execute_in_parallel": false, + "id": "BDI-x24qf0f1", + "name": "Create Hyper-V Cluster", + "rate": null, + "run_on_scale_up": false, + "show_on_order_form": false, + "tier_type": "plugin" + }, + { + "action_name": "Add Hyper-V Cluster to SCVMM", + "continue_on_failure": false, + "dependencies": { + "hook": "plugins/OHK-ive3ka22" + }, + "deploy_seq": 7, + "description": "Adds the cluster to SCVMM under All Hosts with a Run As account for the domain service account.", + "enabled": true, + "execute_in_parallel": false, + "id": "BDI-eotua3t6", + "name": "Add Hyper-V Cluster to SCVMM", + "rate": null, + "run_on_scale_up": false, + "show_on_order_form": false, + "tier_type": "plugin" + } + ], + "deployment_permissions": [], + "description": "Builds an SCVMM 2025 test lab on AWS: two or more nested-virtualization Hyper-V hosts in a failover cluster with iSCSI shared storage, and an SCVMM server that manages the cluster, all joined to an existing domain.", + "favorited": false, + "id": "BP-9zp8udce", + "is_orderable": true, + "labels": [], + "last_updated": "2026-11-02", + "management_actions": [], + "metadata_version": "2026.1.0", + "name": "SCVMM Lab on AWS", + "parameters": [ + { + "allow_multiple": false, + "available_all_servers": false, + "constraints": "Unconstrained", + "description": "File Archives reference (archive/file[@version]) of the zipped SCVMM 2025 setup folder, pinned as this parameter's only option.", + "destination": "Resource", + "field_dependency_controlling_set": [], + "field_dependency_dependent_set": [], + "global_options": [], + "id": "CF-0374eazp", + "label": "SCVMM Setup Media", + "name": "scvmm_media", + "options": [ + "scvmm/SCVMM_2025.zip" + ], + "placeholder": null, + "relevant_osfamilies": [], + "required": true, + "show_as_attribute": true, + "show_on_servers": false, + "type": "STR", + "value_pattern_string": null + }, + { + "allow_multiple": false, + "available_all_servers": false, + "constraints": "Unconstrained", + "description": "Size of the gp3 volume on the SCVMM server that holds the cluster's iSCSI disks, setup downloads and the VMM library, pinned as this parameter's only option.", + "destination": "Resource", + "field_dependency_controlling_set": [], + "field_dependency_dependent_set": [], + "global_options": [], + "id": "CF-m80lzl6h", + "label": "Lab Storage (GB)", + "name": "scvmm_lab_storage_gb", + "options": [ + 250 + ], + "placeholder": null, + "relevant_osfamilies": [], + "required": true, + "show_as_attribute": true, + "show_on_servers": false, + "type": "INT", + "value_pattern_string": null + } + ], + "resource_name_template": "scvmm-lab-00X", + "resource_type": { + "icon": "fas fa-server", + "internal_only": false, + "label": "SCVMM Lab", + "lifecycle": "ACTIVE", + "list_view_columns": [], + "name": "scvmm_lab", + "plural_label": "SCVMM Labs" + }, + "sequence": 0, + "show_recipient_field_on_order_form": false, + "teardown_items": [ + { + "action_name": "Remove Hyper-V Cluster Object", + "continue_on_failure": true, + "dependencies": { + "hook": "plugins/OHK-kzb6pzzu" + }, + "deploy_seq": -1, + "description": "Deletes the cluster's computer object from Active Directory; the servers and the storage volume are deleted with the resource.", + "enabled": true, + "execute_in_parallel": false, + "id": "BDI-w9x43skq", + "name": "Remove Hyper-V Cluster Object", + "rate": null, + "run_on_scale_up": false, + "show_on_order_form": false, + "tier_type": "teardown_plugin" + } + ] +} \ No newline at end of file diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md new file mode 100644 index 00000000..58f5707e --- /dev/null +++ b/blueprints/BP-9zp8udce/README.md @@ -0,0 +1,83 @@ +# SCVMM Lab on AWS + +Builds an SCVMM 2025 test lab on AWS: +- Two or more Windows Server 2025 Hyper-V hosts on nested-virtualization EC2 instances, in a failover cluster. +- Shared storage over iSCSI from a gp3 volume. +- One SCVMM server that manages the cluster. + +Every server joins an existing Active Directory domain. The build runs unattended and takes about an hour, mostly SQL Server and SCVMM setup. + +## Contents +| Role | ID | Name | +|---|---|---| +| Server tier (seq 1, parallel) | — | Hyper-V Hosts (OS build "Windows 2025"; hostname `hvlab-00X`; order 2 or more) | +| Server tier (seq 2) | — | SCVMM Server (OS build "Windows 2025"; hostname `vmmlab-00X`; order 1) | +| Build (Plug-in, seq 3) | OHK-q6fb9833 | Prepare SCVMM Lab on AWS | +| Build (Plug-in, seq 4, parallel) | OHK-8f9o1496 | Install SCVMM | +| Build (Plug-in, seq 5) | OHK-8ioy2cbi | Configure Hyper-V Hosts | +| Build (Plug-in, seq 6) | OHK-77f19kly | Create Hyper-V Cluster | +| Build (Plug-in, seq 7) | OHK-ive3ka22 | Add Hyper-V Cluster to SCVMM | +| Teardown | OHK-kzb6pzzu | Remove Hyper-V Cluster Object | +| Shared module | SHM-dpj24dfj | `scvmm_lab`: guest scripts, scheduled-task steps, EC2 calls | + +Blueprint parameters, each pinned as its only option, so the order form hides them: +- `scvmm_media`: the File Archives file holding the SCVMM media (default `scvmm/SCVMM_2025.zip`). +- `scvmm_lab_storage_gb`: size of the lab volume (default 250). + +## What gets built +| Piece | How | +|---|---| +| Nested virtualization | Each host is stopped, gets `NestedVirtualization=enabled`, and is started again. Not needed on `.metal` sizes. The appliance's botocore predates the field, so the shared module adds it to the signed request itself. | +| Cluster addresses | Each host gets one secondary private IP. The cluster has one IP address resource per host, each owned only by its host, joined by an OR dependency. The cluster name is `hvc-`. | +| Shared storage | The SCVMM server gets a gp3 volume (labeled `CBLab`, deleted with the server) and runs the iSCSI Target Server role. The volume holds a 1 GB disk witness and a cluster shared volume of the volume size minus 40 GB, both dynamically expanding. | +| SCVMM server | Root volume grown to 80 GB. SQL Server 2022 Developer (default instance), Windows ADK Deployment Tools + WinPE, and SCVMM 2025 evaluation. The VMM service runs as Local System; the library share is on the lab volume. | +| Hosts | Hyper-V and Failover Clustering are installed. An internal switch `CBLab-NAT` with NAT `192.168.250.0/24` (gateway `.1`) is created on every host. | +| SCVMM | Run As account `CloudBolt SCVMM Lab Hosts` for the domain service account; the cluster is added under All Hosts. | + +Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster_ips`, `scvmm_lab_vmm_server`. + +## Prerequisites +- **Domain join content.** Install [PKG-nf407lm5](../../packages/PKG-nf407lm5/) (Join Windows Server to AD Domain), with `domain_ou` and `domain_service_account` set on the AWS environment. Every lab server must get the same `domain_service_account`. That account: + - is a member of the local Administrators group on the lab servers, for example through a Group Policy linked to their OU; + - has **Create Computer objects** on that OU, for the cluster's computer object. +- **Teardown rights.** The LDAP Utility's account must be able to delete computer objects in that OU. +- **Runbooks package.** [PKG-v20qv308](../../packages/PKG-v20qv308/) provides the File Archives tab and the `file_archives` shared module. +- **AWS environment.** Windows Server 2025 instances CloudBolt can run scripts on, through SSM (with an instance profile allowing `AmazonSSMManagedInstanceCore`) or through WinRM. + - **Security group:** allow all traffic between its own members (a rule whose source is the group itself). + - **Internet access** from the SCVMM server, to download SQL Server and the ADK from Microsoft. +- **IAM.** The AWS handler's credentials also need: + - `ec2:ModifyInstanceCpuOptions`, `ec2:StopInstances`, `ec2:StartInstances`, `ec2:DescribeInstanceTypes` + - `ec2:AssignPrivateIpAddresses` + - `ec2:CreateVolume`, `ec2:AttachVolume`, `ec2:CreateTags`, `ec2:ModifyInstanceAttribute` + - `ec2:ModifyVolume`, `ec2:DescribeVolumesModifications` + +## Setup +1. Download SCVMM 2025 from the [Evaluation Center](https://www.microsoft.com/en-us/evalcenter/download-system-center-2025). The file is `SCVMM_2025.zip`, about 1 GB. +2. In CloudBolt, go to **Admin > Custom Extensions > Runbooks > File Archives**: + - **Settings:** set **Largest upload** to 1100 MB or more, and set a download base URL the lab's VPC can reach. + - Create archive `scvmm` and upload `SCVMM_2025.zip` unchanged. +3. Sync the blueprint, then open it in **Catalog**: + - **Hyper-V Hosts** tier: enable the AWS environment, and limit **Instance Type** to sizes AWS lists as supporting nested virtualization, for example `m7i.xlarge`, `m8i.xlarge` or `r7i.xlarge`. Bare metal sizes also work. + - **SCVMM Server** tier: enable the same environment. SCVMM's documented minimum is 8 cores and 16 GB of RAM; `m7i.2xlarge` meets it, and `m7i.xlarge` saves cost in a lab. + - Re-point both tiers' OS build if yours is not "Windows 2025" (`OSB-35y5mshd` is instance-specific). + - If you uploaded under another name, change the `scvmm_media` option. +4. Grant the groups that may order it. +5. Order it with **Hyper-V Hosts** quantity 2 or more and **SCVMM Server** quantity 1. + +## Notes +- **Re-running a build item.** Every step is skipped when it is already done. +- **Slow steps** run as scheduled tasks under `\CloudBolt\` and are polled every 30 seconds. Steps that reach AD or other servers sign in as the domain service account, so there is no double hop. Their logs are in the job's progress. +- **The service account's password** goes to the guest inside the script body, base64 encoded for quoting only. On AWS that body stays in Systems Manager's command history. +- **Scale-up is not supported.** Order a new lab for more hosts. +- **Nested VMs** reach the network only through their host's NAT (`192.168.250.0/24`), because EC2 drops frames from unknown MAC addresses. They are not reachable from the VPC. +- **SCVMM has no templates, logical networks or IP pools yet.** Add them in the console. +- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item deletes the cluster's computer object. The servers' own computer objects are deleted only by HPA-q181uofy, when it is installed. + +### Untested +None of this has run on a live appliance yet: +- **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not move with the core group, keep only the first host's address and pin the group to that host. +- **Nested virtualization request without CPU counts.** The plug-in sends `NestedVirtualization` without `CoreCount`/`ThreadsPerCore` (all optional in the API) and retries with them on `MissingParameter`. A dry run from the appliance succeeded with the counts. +- **SQL Server media download.** It uses the installer's own `/Action=Download /MediaType=CAB /Quiet` switches, which Microsoft does not document. +- **SQL Server edition.** SCVMM 2025 lists Standard, Enterprise and Datacenter. Developer is the Enterprise engine, for test use only. +- **SCVMM settings.** `SqlInstanceName=MSSQLSERVER` for the default instance, and no DKM settings with a Local System service. +- **SCSI-3 persistent reservations** on the iSCSI target are not validated: `Test-Cluster` is not run. Run cluster validation in Failover Cluster Manager for a supported configuration. diff --git a/blueprints/README.md b/blueprints/README.md index 71bc5471..6b35d75e 100644 --- a/blueprints/README.md +++ b/blueprints/README.md @@ -35,6 +35,7 @@ Orderable resources. Each folder has a README with contents, prerequisites, and | Run an Azure PowerShell Script | [BP-jvvjm3te](BP-jvvjm3te/README.md) | Runs one of a catalog of Azure PowerShell Remote Scripts against the Azure subscription of a chosen Environment on a Windows host you manage (the script's Run on Server), with the sign-in handled by CloudBolt from the environment's resource handler. | | Run an Azure PowerShell Script (Deployment Script) | [BP-qo1stxre](BP-qo1stxre/README.md) | Runs one of a catalog of Azure PowerShell Remote Scripts against the Azure subscription of a chosen Environment in a Microsoft-managed container started per run through an ARM deployment script, with no server to maintain and the sign-in handled by CloudBolt from the environment's resource handler. | | Run Aria Orchestrator Workflow | [BP-f5y1fhe9](BP-f5y1fhe9/README.md) | Runs an Aria Orchestrator workflow as a CloudBolt resource build, stores the workflow outputs on the resource, and runs it again with teardown parameters on delete. | +| SCVMM Lab on AWS | [BP-9zp8udce](BP-9zp8udce/README.md) | Builds an SCVMM 2025 test lab on AWS: two or more nested-virtualization Hyper-V hosts in a failover cluster with iSCSI shared storage, and an SCVMM server that manages the cluster, all joined to an existing domain. | | Server with Data Disks | [BP-g9zwqjoa](BP-g9zwqjoa/README.md) | Deploys a Windows Server or Oracle Linux VM whose order form turns the environment's disk_map parameter into a table of data disks, which the disk map orchestration actions attach and prepare inside the guest. | | Windows File Server | [BP-psw7rclb](BP-psw7rclb/README.md) | Deploys a Windows server and installs the File Server role. | | Windows Server with Data Disks | [BP-9ph7xcok](BP-9ph7xcok/README.md) | Deploys a Windows Server 2025 VM with an order-time list of data disks, attaching each one and then matching it inside the guest by serial number or SCSI address to initialize, letter, label, and format it. | diff --git a/catalog.json b/catalog.json index 7b45b741..dc559d3f 100644 --- a/catalog.json +++ b/catalog.json @@ -128,6 +128,23 @@ "packages/PKG-t1k7drin" ] }, + { + "id": "BP-9zp8udce", + "type": "blueprints", + "name": "SCVMM Lab on AWS", + "description": "Builds an SCVMM 2025 test lab on AWS: two or more nested-virtualization Hyper-V hosts in a failover cluster with iSCSI shared storage, and an SCVMM server that manages the cluster, all joined to an existing domain.", + "path": "blueprints/BP-9zp8udce", + "readme": "blueprints/BP-9zp8udce/README.md", + "uses": [ + "plugins/OHK-77f19kly", + "plugins/OHK-8f9o1496", + "plugins/OHK-8ioy2cbi", + "plugins/OHK-ive3ka22", + "plugins/OHK-kzb6pzzu", + "plugins/OHK-q6fb9833" + ], + "used_by": [] + }, { "id": "BP-anonytrx", "type": "blueprints", @@ -2360,6 +2377,21 @@ ], "plugin_type": "CloudBolt Plug-in" }, + { + "id": "OHK-77f19kly", + "type": "plugins", + "name": "Create Hyper-V Cluster", + "description": "Creates the SCVMM lab's failover cluster as the domain service account with one IP address resource per host, a cluster shared volume and a disk witness.", + "path": "plugins/OHK-77f19kly", + "readme": null, + "uses": [ + "shared_modules/SHM-dpj24dfj" + ], + "used_by": [ + "blueprints/BP-9zp8udce" + ], + "plugin_type": "CloudBolt Plug-in" + }, { "id": "OHK-7987st2p", "type": "plugins", @@ -2470,6 +2502,37 @@ ], "plugin_type": "CloudBolt Plug-in" }, + { + "id": "OHK-8f9o1496", + "type": "plugins", + "name": "Install SCVMM", + "description": "Installs SQL Server 2022 Developer, the Windows ADK with the WinPE add-on and SCVMM 2025 from File Archives on the SCVMM lab's management server.", + "path": "plugins/OHK-8f9o1496", + "readme": null, + "uses": [ + "shared_modules/SHM-dpj24dfj", + "shared_modules/SHM-v8llc736" + ], + "used_by": [ + "blueprints/BP-9zp8udce" + ], + "plugin_type": "CloudBolt Plug-in" + }, + { + "id": "OHK-8ioy2cbi", + "type": "plugins", + "name": "Configure Hyper-V Hosts", + "description": "Installs Hyper-V and Failover Clustering on the SCVMM lab hosts, creates their NAT switch, and connects them to the iSCSI disks it creates on the SCVMM server.", + "path": "plugins/OHK-8ioy2cbi", + "readme": null, + "uses": [ + "shared_modules/SHM-dpj24dfj" + ], + "used_by": [ + "blueprints/BP-9zp8udce" + ], + "plugin_type": "CloudBolt Plug-in" + }, { "id": "OHK-8px9e3ws", "type": "plugins", @@ -3339,6 +3402,21 @@ "packages/PKG-v20qv308" ] }, + { + "id": "OHK-ive3ka22", + "type": "plugins", + "name": "Add Hyper-V Cluster to SCVMM", + "description": "Adds the SCVMM lab's failover cluster to SCVMM under All Hosts with a Run As account for the domain service account.", + "path": "plugins/OHK-ive3ka22", + "readme": null, + "uses": [ + "shared_modules/SHM-dpj24dfj" + ], + "used_by": [ + "blueprints/BP-9zp8udce" + ], + "plugin_type": "CloudBolt Plug-in" + }, { "id": "OHK-iy92hhvh", "type": "plugins", @@ -3466,6 +3544,21 @@ ], "plugin_type": "Remote Script" }, + { + "id": "OHK-kzb6pzzu", + "type": "plugins", + "name": "Remove Hyper-V Cluster Object", + "description": "Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted.", + "path": "plugins/OHK-kzb6pzzu", + "readme": null, + "uses": [ + "shared_modules/SHM-gcba1u31" + ], + "used_by": [ + "blueprints/BP-9zp8udce" + ], + "plugin_type": "CloudBolt Plug-in" + }, { "id": "OHK-l25x6wd8", "type": "plugins", @@ -3953,6 +4046,21 @@ ], "plugin_type": "CloudBolt Plug-in" }, + { + "id": "OHK-q6fb9833", + "type": "plugins", + "name": "Prepare SCVMM Lab on AWS", + "description": "Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role.", + "path": "plugins/OHK-q6fb9833", + "readme": null, + "uses": [ + "shared_modules/SHM-dpj24dfj" + ], + "used_by": [ + "blueprints/BP-9zp8udce" + ], + "plugin_type": "CloudBolt Plug-in" + }, { "id": "OHK-qduf79xu", "type": "plugins", @@ -5962,6 +6070,22 @@ "plugins/OHK-dnstrd01" ] }, + { + "id": "SHM-dpj24dfj", + "type": "shared_modules", + "name": "scvmm_lab", + "description": "Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler.", + "path": "shared_modules/SHM-dpj24dfj", + "readme": null, + "uses": [], + "used_by": [ + "plugins/OHK-ive3ka22", + "plugins/OHK-8ioy2cbi", + "plugins/OHK-77f19kly", + "plugins/OHK-8f9o1496", + "plugins/OHK-q6fb9833" + ] + }, { "id": "SHM-eybr4hgz", "type": "shared_modules", @@ -5988,6 +6112,7 @@ "used_by": [ "plugins/OHK-bkoau0j8", "plugins/OHK-9oqn6pur", + "plugins/OHK-kzb6pzzu", "plugins/OHK-z9qrccyu" ] }, @@ -6203,6 +6328,7 @@ "readme": null, "uses": [], "used_by": [ + "plugins/OHK-8f9o1496", "plugins/OHK-o4tgygjs" ] }, diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_metadata.json b/plugins/OHK-77f19kly/OHK-77f19kly_metadata.json new file mode 100644 index 00000000..8c295499 --- /dev/null +++ b/plugins/OHK-77f19kly/OHK-77f19kly_metadata.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "sharedModules": [ + "shared_modules/SHM-dpj24dfj" + ] + }, + "description": "Creates the SCVMM lab's failover cluster as the domain service account with one IP address resource per host, a cluster shared volume and a disk witness.", + "id": "OHK-77f19kly", + "max_retries": 0, + "name": "Create Hyper-V Cluster", + "resource_technologies": [], + "script_filename": "OHK-77f19kly_script.py", + "shared": false, + "target_os_families": [], + "type": "CloudBolt Plug-in" +} \ No newline at end of file diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_script.py b/plugins/OHK-77f19kly/OHK-77f19kly_script.py new file mode 100644 index 00000000..99bc722a --- /dev/null +++ b/plugins/OHK-77f19kly/OHK-77f19kly_script.py @@ -0,0 +1,157 @@ +""" +Create Hyper-V Cluster + +Build item 6 of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce). It +runs on the first host as a scheduled task signed in as the domain service +account. That account creates the cluster's computer object (CNO) in the +hosts' OU, so it needs Create Computer objects there, and it must be in each +host's local Administrators group. Each step is skipped when it is already +done, so the item can be re-run. + + 1. Create the cluster hvc- on every host with no storage and + the first host's secondary private IP as its address, ignoring the NAT + network. Add any host the cluster is missing. + 2. Give the core network name one IP address resource per host, each + host's secondary private IP, possible owner that host only, joined by + an OR dependency. EC2 delivers an address only to the interface it is + assigned to, so the cluster name comes online with whichever address + belongs to the node that owns the core group. This is the IP layout and + possible-owner setting of AWS's guidance for clusters on EC2, which + describes nodes in separate subnets; the hosts here share one subnet. + 3. Keep the NAT network (every host has the same gateway address on it) + out of cluster traffic, and raise SameSubnetThreshold to 10 as AWS + recommends. + 4. Format the two iSCSI disks on this host, add them to the cluster, make + the large one a cluster shared volume and the 1 GB one the disk witness. + +Cluster validation (Test-Cluster) is not run; for a supported cluster run it +from Failover Cluster Manager. + +CloudBolt renders this file as a template before running it, so it must never +contain template tags; values reach the scripts through the __CB_*__ tokens. + +References: + New-Cluster: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/new-cluster + Add-ClusterNode: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clusternode + Add-ClusterResource: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clusterresource + Set-ClusterParameter: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterparameter?view=windowsserver2019-ps + IP Address private properties: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mscs/ip-address-private-properties + Set-ClusterOwnerNode: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterownernode + Set-ClusterResourceDependency: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterresourcedependency + Add-ClusterDisk: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clusterdisk + Add-ClusterSharedVolume: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clustersharedvolume + Set-ClusterQuorum: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterquorum + Prestage cluster objects in AD: https://learn.microsoft.com/en-us/windows-server/failover-clustering/prestage-cluster-adds + SQL Server clustering on EC2: https://docs.aws.amazon.com/sql-server-ec2/latest/userguide/aws-sql-ec2-clustering.html +""" +from common.methods import set_progress + +from shared_modules import scvmm_lab +from shared_modules.scvmm_lab import LabError + +NAT_PREFIX = "192.168.250.0/24" + +CREATE_CLUSTER = r""" + Import-Module FailoverClusters + $name = Decode '__CB_NAME__' + $nodes = @((Decode '__CB_NODES__') -split ',') + $ips = @((Decode '__CB_IPS__') -split ',') + $natPrefix = Decode '__CB_NAT_PREFIX__' + $natAddress = ($natPrefix -split '/')[0] + + $cluster = Lookup { Get-Cluster -ErrorAction Stop } + if ($cluster -and $cluster.Name -ne $name) { throw "$env:COMPUTERNAME is already in cluster $($cluster.Name)." } + if (-not $cluster) { + Log "Creating cluster $name on $($nodes -join ', ') with address $($ips[0])" + New-Cluster -Name $name -Node $nodes -StaticAddress $ips[0] -IgnoreNetwork $natPrefix -NoStorage | Out-Null + } + $members = @(Get-ClusterNode -Cluster $name | ForEach-Object { $_.Name.ToLower() }) + foreach ($node in $nodes) { + if ($members -notcontains $node.ToLower()) { + Log "Adding node $node" + Add-ClusterNode -Cluster $name -Name $node -NoStorage | Out-Null + } + } + + $nat = Get-ClusterNetwork -Cluster $name | Where-Object { $_.Address -eq $natAddress } + foreach ($n in $nat) { if ($n.Role -ne 0) { $n.Role = 0; Log "Cluster network $($n.Name) ($natPrefix) set to no cluster traffic" } } + $network = Get-ClusterNetwork -Cluster $name | Where-Object { $_.Address -ne $natAddress -and $_.Role -ne 0 } | Select-Object -First 1 + if (-not $network) { throw 'The cluster has no network for its IP addresses.' } + + $core = Get-ClusterResource -Cluster $name | Where-Object { $_.OwnerGroup -eq 'Cluster Group' } + $nameResource = $core | Where-Object { $_.ResourceType -eq 'Network Name' } | Select-Object -First 1 + $ipResources = @() + for ($i = 0; $i -lt $nodes.Count; $i++) { + $resource = $core | Where-Object { $_.ResourceType -eq 'IP Address' } | + Where-Object { (Get-ClusterParameter -InputObject $_ -Name Address).Value -eq $ips[$i] } | Select-Object -First 1 + if (-not $resource) { + $resource = Add-ClusterResource -Cluster $name -Name "Cluster IP Address $($ips[$i])" -ResourceType 'IP Address' -Group 'Cluster Group' + $resource | Set-ClusterParameter -Multiple @{ Address = $ips[$i]; SubnetMask = $network.AddressMask; Network = $network.Name; EnableDhcp = 0 } + Log "Added IP address resource $($ips[$i]) for $($nodes[$i])" + } + Set-ClusterOwnerNode -Cluster $name -Resource $resource.Name -Owners $nodes[$i] | Out-Null + $ipResources += $resource.Name + } + $expression = ($ipResources | ForEach-Object { "[$_]" }) -join ' or ' + Set-ClusterResourceDependency -Cluster $name -Resource $nameResource.Name -Dependency $expression | Out-Null + Start-ClusterGroup -Cluster $name -Name 'Cluster Group' | Out-Null + $settings = Get-Cluster -Name $name + if ($settings.SameSubnetThreshold -lt 10) { $settings.SameSubnetThreshold = 10 } + + $witnessName = 'CBLab Witness' + $csvName = 'CBLab CSV' + $diskResources = @(Get-ClusterResource -Cluster $name | Where-Object { $_.ResourceType -eq 'Physical Disk' } | ForEach-Object { $_.Name }) + # The smaller iSCSI disk (1 GB) is the witness, the larger the cluster shared volume. + $iscsi = @(Get-Disk | Where-Object { $_.BusType -eq 'iSCSI' } | Sort-Object Size) + $plan = @( + @{ Resource = $witnessName; Label = 'CBLabWitness'; Disk = $iscsi[0] }, + @{ Resource = $csvName; Label = 'CBLabCSV'; Disk = $iscsi[-1] } + ) + foreach ($item in $plan) { + if ($diskResources -contains $item.Resource) { continue } + if ($iscsi.Count -lt 2) { throw "Only $($iscsi.Count) of the 2 iSCSI disks are visible on $env:COMPUTERNAME." } + $disk = $item.Disk + if ($disk.PartitionStyle -eq 'RAW') { + if ($disk.IsOffline) { Set-Disk -Number $disk.Number -IsOffline $false } + if ($disk.IsReadOnly) { Set-Disk -Number $disk.Number -IsReadOnly $false } + Initialize-Disk -Number $disk.Number -PartitionStyle GPT + New-Partition -DiskNumber $disk.Number -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel $item.Label -Confirm:$false | Out-Null + Log "Formatted iSCSI disk $($disk.Number) ($([math]::Round($disk.Size / 1GB)) GB) as $($item.Label)" + } + $available = Get-ClusterAvailableDisk -Cluster $name -Disk (Get-Disk -Number $disk.Number) + if (-not $available) { throw "iSCSI disk $($disk.Number) cannot be added to the cluster; check every host sees it." } + $added = $available | Add-ClusterDisk + $added.Name = $item.Resource + Log "Added cluster disk $($item.Resource)" + } + if ((Get-ClusterQuorum -Cluster $name).QuorumResource.Name -ne $witnessName) { + Set-ClusterQuorum -Cluster $name -DiskWitness $witnessName | Out-Null + } + $csv = Lookup { Get-ClusterSharedVolume -Cluster $name -Name $csvName -ErrorAction Stop } + if (-not $csv) { $csv = Add-ClusterSharedVolume -Cluster $name -Name $csvName } + Mark 'CSV_PATH' $csv.SharedVolumeInfo.FriendlyVolumeName + Mark 'OWNER' (Get-ClusterGroup -Cluster $name -Name 'Cluster Group').OwnerNode.Name +""" + + +def run(job, resource=None, **kwargs): + resource = resource or job.resource_set.first() + try: + lab = scvmm_lab.Lab(resource) + nodes, ips = [], [] + for host in lab.hosts: + ip = scvmm_lab.cluster_ip(scvmm_lab.ec2_client(host), host) + if not ip: + raise LabError(f"{host.hostname} has no secondary private IP; run Prepare SCVMM Lab on AWS again.") + nodes.append(scvmm_lab.computer_name(host)) + ips.append(ip) + log = scvmm_lab.run_task(lab.hosts[0], CREATE_CLUSTER, f"create cluster {lab.cluster_name}", tokens={ + "NAME": lab.cluster_name, "NODES": ",".join(nodes), "IPS": ",".join(ips), "NAT_PREFIX": NAT_PREFIX, + }, account=lab.account, timeout=2700) + found = scvmm_lab.markers(log) + set_progress(f"Cluster {lab.cluster_fqdn}: cluster shared volume {found.get('CSV_PATH')}, " + f"core group on {found.get('OWNER')}") + except LabError as err: + return "FAILURE", "", str(err) + return "SUCCESS", (f"Cluster {lab.cluster_fqdn} has {len(nodes)} nodes, IP addresses {', '.join(ips)}, " + f"cluster shared volume {found.get('CSV_PATH')} and a disk witness."), "" diff --git a/plugins/OHK-8f9o1496/OHK-8f9o1496_metadata.json b/plugins/OHK-8f9o1496/OHK-8f9o1496_metadata.json new file mode 100644 index 00000000..e29741ac --- /dev/null +++ b/plugins/OHK-8f9o1496/OHK-8f9o1496_metadata.json @@ -0,0 +1,17 @@ +{ + "dependencies": { + "sharedModules": [ + "shared_modules/SHM-dpj24dfj", + "shared_modules/SHM-v8llc736" + ] + }, + "description": "Installs SQL Server 2022 Developer, the Windows ADK with the WinPE add-on and SCVMM 2025 from File Archives on the SCVMM lab's management server.", + "id": "OHK-8f9o1496", + "max_retries": 0, + "name": "Install SCVMM", + "resource_technologies": [], + "script_filename": "OHK-8f9o1496_script.py", + "shared": false, + "target_os_families": [], + "type": "CloudBolt Plug-in" +} \ No newline at end of file diff --git a/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py b/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py new file mode 100644 index 00000000..9a279ebe --- /dev/null +++ b/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py @@ -0,0 +1,230 @@ +""" +Install SCVMM + +Build item 4 of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce). It +runs in parallel with Configure Hyper-V Hosts (item 5) and only touches the +SCVMM server. Every step is skipped when it is already done, so the item can +be re-run. + + 1. Find the lab volume (labeled CBLab by Prepare SCVMM Lab on AWS), check C: + has room, and restart the server first if Windows has a restart pending + (SQL Server setup refuses to run then). + 2. SQL Server 2022 Developer, default instance, Database Engine only, as a + SYSTEM scheduled task. The installer bootstrapper (SSEI) downloads the + media from Microsoft. Its /Action=Download, /MediaPath, /MediaType and + /Quiet switches are not documented; they are the ones the bootstrapper + itself lists. The domain service account and BUILTIN\\Administrators + become sysadmins, because SCVMM setup runs as that account and needs + sysadmin. The services keep setup's default virtual accounts. SCVMM + 2025 lists Standard, Enterprise and Datacenter editions; Developer is the + Enterprise engine, licensed for test labs only. + 3. Windows ADK Deployment Tools and the WinPE add-on, which SCVMM setup + requires, from Microsoft's download links. + 4. The SCVMM 2025 media from File Archives: scvmm_media names the zip + (SCVMM_2025.zip from the Evaluation Center, uploaded unchanged). The + file_archives shared module downloads and checks it on the server; this + moves the extracted folder to the lab volume. + 5. SCVMM setup from the command prompt, as a scheduled task signed in as the + domain service account: new database VirtualManagerDB on the local + instance, the VMM service as Local System (no distributed key + management), the library share on the lab volume, the default ports, + no product key (180-day evaluation). + +The server downloads SQL Server and the ADK from the internet; with no +internet access, steps 2 and 3 fail with the download error. + +CloudBolt renders this file as a template before running it, so it must never +contain template tags; values reach the scripts through the __CB_*__ tokens. + +References: + SQL Server from the command prompt: https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-ver16 + SQL Server service accounts: https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-windows-service-accounts-and-permissions?view=sql-server-ver16 + SQL Server 2022 downloads: https://www.microsoft.com/en-us/sql-server/sql-server-downloads + Windows ADK downloads: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install + ADK silent install: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-offline-install + ADK command-line options: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/dn621910(v=win.10) + Install VMM (command prompt, ini): https://learn.microsoft.com/en-us/system-center/vmm/install?view=sc-vmm-2025 + Plan the VMM installation: https://learn.microsoft.com/en-us/system-center/vmm/plan-install?view=sc-vmm-2025 + VMM 2025 system requirements: https://learn.microsoft.com/en-us/system-center/vmm/system-requirements?view=sc-vmm-2025 + System Center 2025 evaluation: https://www.microsoft.com/en-us/evalcenter/download-system-center-2025 +""" +from common.methods import set_progress + +from shared_modules import scvmm_lab +from shared_modules.scvmm_lab import LabError + +SQL_SSEI_URL = "https://go.microsoft.com/fwlink/p/?linkid=2215158" +ADK_URL = "https://go.microsoft.com/fwlink/?linkid=2289980" +WINPE_URL = "https://go.microsoft.com/fwlink/?linkid=2289981" +MIN_FREE_C_GB = 25 + +STATE = r""" + $volume = Get-Volume -FileSystemLabel (Decode '__CB_LABEL__') -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $volume) { throw 'The lab volume is missing; run Prepare SCVMM Lab on AWS again.' } + Mark 'ROOT' ('{0}:\CBLab' -f $volume.DriveLetter) + Mark 'C_FREE_GB' ([math]::Floor((Get-Volume -DriveLetter C).SizeRemaining / 1GB)) + $pending = (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') -or + (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') -or + [bool](Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue) + Mark 'RESTART_PENDING' ([int]$pending) + Mark 'SQL' ([int][bool](Get-Service -Name MSSQLSERVER -ErrorAction SilentlyContinue)) + $kit = Join-Path ${env:ProgramFiles(x86)} 'Windows Kits\10\Assessment and Deployment Kit' + Mark 'ADK' ([int](Test-Path (Join-Path $kit 'Deployment Tools'))) + Mark 'WINPE' ([int](Test-Path (Join-Path $kit 'Windows Preinstallation Environment'))) + Mark 'VMM' ([int][bool](Get-Service -Name SCVMMService -ErrorAction SilentlyContinue)) + Mark 'MEDIA' ([int](Test-Path ('{0}:\CBLab\Media\VMM\setup.exe' -f $volume.DriveLetter))) +""" + +INSTALL_SQL = r""" + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072 + $root = Decode '__CB_ROOT__' + # SQL Server setup takes DOMAIN\user; resolve a UPN through its SID. + $account = (New-Object Security.Principal.NTAccount (Decode '__CB_SYSADMIN__')).Translate([Security.Principal.SecurityIdentifier]).Translate([Security.Principal.NTAccount]).Value + $media = Join-Path $root 'Media\SQL' + New-Item -ItemType Directory -Force -Path $media | Out-Null + $ssei = Join-Path $media 'SQL2022-SSEI-Dev.exe' + if (-not (Test-Path -LiteralPath $ssei)) { + Log 'Downloading the SQL Server 2022 Developer installer' + Invoke-WebRequest -Uri (Decode '__CB_SSEI_URL__') -OutFile $ssei -UseBasicParsing + } + $box = Get-ChildItem -LiteralPath $media -Filter 'SQLServer2022-DEV-x64-*.exe' | Select-Object -First 1 + if (-not $box) { + Log 'Downloading the SQL Server 2022 Developer media (CAB)' + $p = Start-Process -FilePath $ssei -ArgumentList '/Action=Download', "/MediaPath=`"$media`"", '/MediaType=CAB', '/Quiet' -Wait -PassThru + $box = Get-ChildItem -LiteralPath $media -Filter 'SQLServer2022-DEV-x64-*.exe' | Select-Object -First 1 + if (-not $box) { throw "The SQL Server installer did not download the media (exit code $($p.ExitCode)); the server needs internet access to download.microsoft.com." } + } + $setupDir = Join-Path $media 'setup' + if (-not (Test-Path -LiteralPath (Join-Path $setupDir 'setup.exe'))) { + Log 'Extracting the SQL Server media' + $p = Start-Process -FilePath $box.FullName -ArgumentList '/q', "/x:`"$setupDir`"" -Wait -PassThru + if (-not (Test-Path -LiteralPath (Join-Path $setupDir 'setup.exe'))) { throw "Extracting $($box.Name) failed (exit code $($p.ExitCode))." } + } + Log "Installing SQL Server 2022 Developer (MSSQLSERVER) with sysadmins $account and BUILTIN\Administrators" + $arguments = @('/Q', '/ACTION=Install', '/FEATURES=SQLENGINE', '/INSTANCENAME=MSSQLSERVER', + "/SQLSYSADMINACCOUNTS=`"$account`" `"BUILTIN\Administrators`"", + '/IACCEPTSQLSERVERLICENSETERMS', '/SUPPRESSPRIVACYSTATEMENTNOTICE', '/UpdateEnabled=0') + $p = Start-Process -FilePath (Join-Path $setupDir 'setup.exe') -ArgumentList $arguments -Wait -PassThru + if ($p.ExitCode -notin 0, 3010) { + throw "SQL Server setup exited with code $($p.ExitCode); see Summary.txt under C:\Program Files\Microsoft SQL Server\160\Setup Bootstrap\Log." + } + if ((Get-Service -Name MSSQLSERVER).Status -ne 'Running') { Start-Service -Name MSSQLSERVER } + Log 'SQL Server is running' +""" + +INSTALL_ADK = r""" + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072 + $media = Join-Path (Decode '__CB_ROOT__') 'Media\ADK' + New-Item -ItemType Directory -Force -Path $media | Out-Null + $kit = Join-Path ${env:ProgramFiles(x86)} 'Windows Kits\10\Assessment and Deployment Kit' + $parts = @( + @{ Url = (Decode '__CB_ADK_URL__'); File = 'adksetup.exe'; Feature = 'OptionId.DeploymentTools'; Folder = 'Deployment Tools' }, + @{ Url = (Decode '__CB_WINPE_URL__'); File = 'adkwinpesetup.exe'; Feature = 'OptionId.WindowsPreinstallationEnvironment'; Folder = 'Windows Preinstallation Environment' } + ) + foreach ($part in $parts) { + if (Test-Path -LiteralPath (Join-Path $kit $part.Folder)) { Log "$($part.Folder) is already installed"; continue } + $exe = Join-Path $media $part.File + if (-not (Test-Path -LiteralPath $exe)) { Invoke-WebRequest -Uri $part.Url -OutFile $exe -UseBasicParsing } + Log "Installing $($part.Folder) (it downloads from Microsoft)" + $p = Start-Process -FilePath $exe -ArgumentList '/quiet', '/norestart', '/ceip', 'off', '/features', $part.Feature -Wait -PassThru + if ($p.ExitCode -notin 0, 3010 -or -not (Test-Path -LiteralPath (Join-Path $kit $part.Folder))) { + throw "$($part.File) exited with code $($p.ExitCode); see the logs under $env:TEMP\adk." + } + } +""" + +STAGE_MEDIA = r""" + $target = Join-Path (Decode '__CB_ROOT__') 'Media\VMM' + $setup = Get-ChildItem -LiteralPath $env:CB_ARCHIVE_DIR -Filter setup.exe -Recurse -Depth 2 | + Sort-Object { $_.FullName.Length } | Select-Object -First 1 + if (-not $setup) { throw 'The archive has no setup.exe. Upload SCVMM_2025.zip from the Evaluation Center unchanged.' } + Get-ChildItem -LiteralPath $env:CB_ARCHIVE_DIR -Filter *.zip | Remove-Item -Force + Set-Location -LiteralPath $env:SystemDrive\ + if (Test-Path -LiteralPath $target) { Remove-Item -LiteralPath $target -Recurse -Force } + Move-Item -LiteralPath $setup.Directory.FullName -Destination $target + Log "SCVMM media is in $target" +""" + +INSTALL_VMM = r""" + $root = Decode '__CB_ROOT__' + $setup = Join-Path $root 'Media\VMM\setup.exe' + $library = Join-Path $root 'Library' + $ini = Join-Path $root 'VMServer.ini' + New-Item -ItemType Directory -Force -Path $library | Out-Null + $settings = @( + '[OPTIONS]', + 'CreateNewSqlDatabase=1', + 'SqlInstanceName=MSSQLSERVER', + 'SqlDatabaseName=VirtualManagerDB', + 'RemoteDatabaseImpersonation=0', + "SqlMachineName=$env:COMPUTERNAME", + 'IndigoTcpPort=8100', + 'IndigoHTTPSPort=8101', + 'IndigoNETTCPPort=8102', + 'IndigoHTTPPort=8103', + 'WSManTcpPort=5985', + 'BitsTcpPort=443', + 'CreateNewLibraryShare=1', + 'LibraryShareName=MSSCVMMLibrary', + "LibrarySharePath=$library", + 'LibraryShareDescription=Virtual Machine Manager Library Files', + 'SQMOptIn=0', + 'MUOptIn=0', + 'VmmServiceLocalAccount=1', + 'HighlyAvailable=0' + ) + # The sample VMServer.ini that ships with the media is UTF-16LE. + Set-Content -LiteralPath $ini -Value $settings -Encoding Unicode + Log "Running SCVMM setup as $(whoami)" + $p = Start-Process -FilePath $setup -ArgumentList '/server', '/i', '/f', "`"$ini`"", '/IACCEPTSCEULA' -Wait -PassThru + # In case the bootstrapper hands off to the setup engine and exits first. + $deadline = (Get-Date).AddMinutes(60) + while ((Get-Process -Name SetupVM -ErrorAction SilentlyContinue) -and (Get-Date) -lt $deadline) { Start-Sleep -Seconds 15 } + $service = Get-Service -Name SCVMMService -ErrorAction SilentlyContinue + if ($p.ExitCode -ne 0 -or -not $service) { + throw "SCVMM setup exited with code $($p.ExitCode); see the logs in $env:SystemDrive\ProgramData\VMMLogs." + } + if ($service.Status -ne 'Running') { Start-Service -Name SCVMMService } + Log 'The SCVMM service is running' +""" + + +def run(job, resource=None, **kwargs): + resource = resource or job.resource_set.first() + try: + lab = scvmm_lab.Lab(resource) + vmm = lab.vmm + media_ref = str(resource.get_value_for_custom_field("scvmm_media") or "").strip() + if not media_ref: + raise LabError("scvmm_media is empty. Pin the File Archives reference of SCVMM_2025.zip " + "(for example scvmm/SCVMM_2025.zip) as the blueprint parameter's only option.") + state, _ = scvmm_lab.run_ps(vmm, STATE, tokens={"LABEL": scvmm_lab.STORAGE_LABEL}) + if state["RESTART_PENDING"] == "1" and state["VMM"] == "0": + scvmm_lab.restart([vmm], "clear a pending restart before SQL Server setup") + if state["VMM"] == "1": + return "SUCCESS", f"SCVMM is already installed on {vmm.hostname}.", "" + if state["SQL"] == "0" and int(state["C_FREE_GB"]) < MIN_FREE_C_GB: + raise LabError(f"{vmm.hostname}: C: has {state['C_FREE_GB']} GB free; SQL Server, the ADK and SCVMM " + f"need {MIN_FREE_C_GB} GB. Grow the root volume and extend C:.") + root = state["ROOT"] + temp = f"{root}\\Temp" + tokens = {"ROOT": root} + + if state["SQL"] == "1": + set_progress(f"{vmm.hostname}: SQL Server is already installed") + else: + scvmm_lab.run_task(vmm, INSTALL_SQL, "install SQL Server 2022 Developer", tokens=dict( + tokens, SYSADMIN=lab.username, SSEI_URL=SQL_SSEI_URL), timeout=3600, temp_dir=temp) + if state["ADK"] == "1" and state["WINPE"] == "1": + set_progress(f"{vmm.hostname}: the Windows ADK and WinPE add-on are already installed") + else: + scvmm_lab.run_task(vmm, INSTALL_ADK, "install the Windows ADK and WinPE add-on", tokens=dict( + tokens, ADK_URL=ADK_URL, WINPE_URL=WINPE_URL), timeout=3600, temp_dir=temp) + if state["MEDIA"] == "0": + scvmm_lab.run_task(vmm, STAGE_MEDIA, f"download {media_ref} from File Archives", tokens=tokens, + timeout=3600, temp_dir=temp, archive_refs=[f"{media_ref} extract"], job=job) + scvmm_lab.run_task(vmm, INSTALL_VMM, "install SCVMM", tokens=tokens, account=lab.account, + timeout=3600, temp_dir=temp) + except LabError as err: + return "FAILURE", "", str(err) + return "SUCCESS", f"SCVMM 2025 (evaluation) is running on {lab.fqdn(vmm)} with SQL Server 2022 Developer.", "" diff --git a/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_metadata.json b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_metadata.json new file mode 100644 index 00000000..fba891c0 --- /dev/null +++ b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_metadata.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "sharedModules": [ + "shared_modules/SHM-dpj24dfj" + ] + }, + "description": "Installs Hyper-V and Failover Clustering on the SCVMM lab hosts, creates their NAT switch, and connects them to the iSCSI disks it creates on the SCVMM server.", + "id": "OHK-8ioy2cbi", + "max_retries": 0, + "name": "Configure Hyper-V Hosts", + "resource_technologies": [], + "script_filename": "OHK-8ioy2cbi_script.py", + "shared": false, + "target_os_families": [], + "type": "CloudBolt Plug-in" +} \ No newline at end of file diff --git a/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py new file mode 100644 index 00000000..ca44dbe0 --- /dev/null +++ b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py @@ -0,0 +1,193 @@ +""" +Configure Hyper-V Hosts + +Build item 5 of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce). It +runs while Install SCVMM (item 4, in parallel) sets up the SCVMM server. +Every step is skipped when it is already done, so the item can be re-run. + + 1. Per host, as a SYSTEM scheduled task: install the Hyper-V and Failover + Clustering features with their management tools, and start the + Microsoft iSCSI Initiator service. + 2. Restart the hosts together when a feature asked for it, and wait for + them. + 3. Per host: check the Hyper-V management service runs, open the firewall + rule groups SCVMM uses to install its agent (File and Printer Sharing, + WMI, Remote Service Management), take the cluster IP address off the + network adapter if anything bound it there (the cluster brings it + online itself; AWS's clustering guidance keeps the NIC on DHCP), create + an internal switch with a NAT network for nested VMs (the same prefix + on every host, so a VM keeps its address when it moves), and read the + host's iSCSI initiator name. + 4. SCVMM server: create the iSCSI target for exactly those initiator + names, with two dynamically expanding virtual disks on the lab volume: + a 1 GB disk witness and the cluster shared volume, which takes the rest + of the volume minus RESERVE_GB for setup downloads and the VMM library. + 5. Per host: add the SCVMM server as a target portal, connect the target + persistently and check both disks are visible. They stay offline until + Create Hyper-V Cluster formats them on the first host. + +Nested VMs reach the network only through their host's NAT: EC2 network +interfaces drop frames from MAC addresses they do not know. + +CloudBolt renders this file as a template before running it, so it must never +contain template tags; values reach the scripts through the __CB_*__ tokens. + +References: + Install-WindowsFeature: https://learn.microsoft.com/en-us/powershell/module/servermanager/install-windowsfeature + Hyper-V on Windows Server: https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/install-hyper-v + New-VMSwitch: https://learn.microsoft.com/en-us/powershell/module/hyper-v/new-vmswitch + New-NetNat: https://learn.microsoft.com/en-us/powershell/module/netnat/new-netnat + New-IscsiServerTarget: https://learn.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsiservertarget + New-IscsiVirtualDisk: https://learn.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsivirtualdisk + Add-IscsiVirtualDiskTargetMapping: https://learn.microsoft.com/en-us/powershell/module/iscsitarget/add-iscsivirtualdisktargetmapping + New-IscsiTargetPortal: https://learn.microsoft.com/en-us/powershell/module/iscsi/new-iscsitargetportal + Connect-IscsiTarget: https://learn.microsoft.com/en-us/powershell/module/iscsi/connect-iscsitarget + SQL Server clustering on EC2 (IPs): https://docs.aws.amazon.com/sql-server-ec2/latest/userguide/aws-sql-ec2-clustering.html +""" +from common.methods import set_progress + +from shared_modules import scvmm_lab +from shared_modules.scvmm_lab import LabError + +SWITCH = "CBLab-NAT" +NAT_PREFIX = "192.168.250.0/24" +NAT_GATEWAY = "192.168.250.1" +TARGET = "cblab-cluster" +RESERVE_GB = 40 + +FEATURES = r""" + $result = Install-WindowsFeature -Name Hyper-V, Failover-Clustering -IncludeManagementTools + if (-not $result.Success) { throw "Install-WindowsFeature Hyper-V, Failover-Clustering failed (exit code $($result.ExitCode))." } + $running = (Get-Service -Name vmms -ErrorAction SilentlyContinue).Status -eq 'Running' + Log "Features: $(@($result.FeatureResult | ForEach-Object { $_.Name }) -join ', '); restart needed: $($result.RestartNeeded)" + Mark 'RESTART' $(if ($running) { 0 } else { 1 }) + Set-Service -Name MSiSCSI -StartupType Automatic + Start-Service -Name MSiSCSI +""" + +HOST_SETUP = r""" + if ((Get-Service -Name vmms -ErrorAction SilentlyContinue).Status -ne 'Running') { + throw 'The Hyper-V Virtual Machine Management service (vmms) is not running after the restart.' + } + foreach ($group in 'File and Printer Sharing', 'Windows Management Instrumentation (WMI)', 'Remote Service Management') { + Enable-NetFirewallRule -DisplayGroup $group + } + $clusterIp = Decode '__CB_CLUSTER_IP__' + if ((Get-Service -Name ClusSvc -ErrorAction SilentlyContinue).Status -ne 'Running') { + Get-NetIPAddress -IPAddress $clusterIp -ErrorAction SilentlyContinue | Remove-NetIPAddress -Confirm:$false + } + $switch = Decode '__CB_SWITCH__' + $gateway = Decode '__CB_GATEWAY__' + $prefix = Decode '__CB_PREFIX__' + if (-not (Get-VMSwitch -Name $switch -ErrorAction SilentlyContinue)) { + New-VMSwitch -Name $switch -SwitchType Internal | Out-Null + Log "Created internal switch $switch" + } + $alias = "vEthernet ($switch)" + if (-not (Get-NetIPAddress -InterfaceAlias $alias -IPAddress $gateway -ErrorAction SilentlyContinue)) { + New-NetIPAddress -InterfaceAlias $alias -IPAddress $gateway -PrefixLength ([int]($prefix -split '/')[1]) | Out-Null + } + if (-not (Get-NetNat -Name $switch -ErrorAction SilentlyContinue)) { + New-NetNat -Name $switch -InternalIPInterfaceAddressPrefix $prefix | Out-Null + Log "Created NAT $switch for $prefix" + } + Set-Service -Name MSiSCSI -StartupType Automatic + Start-Service -Name MSiSCSI + $iqn = (Get-InitiatorPort | Where-Object { $_.ConnectionType -eq 'iSCSI' } | Select-Object -First 1).NodeAddress + if (-not $iqn) { throw 'The Microsoft iSCSI Initiator has no initiator name.' } + Mark 'IQN' $iqn +""" + +TARGET_SETUP = r""" + $target = Decode '__CB_TARGET__' + $initiators = @((Decode '__CB_IQNS__') -split ',' | ForEach-Object { "IQN:$_" }) + $reserve = [int64](Decode '__CB_RESERVE_GB__') * 1GB + $volume = Get-Volume -FileSystemLabel (Decode '__CB_LABEL__') -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $volume) { throw 'The lab volume is missing; run Prepare SCVMM Lab on AWS again.' } + $dir = '{0}:\CBLab\iSCSI' -f $volume.DriveLetter + if (Lookup { Get-IscsiServerTarget -TargetName $target -ErrorAction Stop }) { + Set-IscsiServerTarget -TargetName $target -InitiatorIds $initiators + } else { + New-IscsiServerTarget -TargetName $target -InitiatorIds $initiators | Out-Null + Log "Created iSCSI target $target" + } + $csvBytes = [math]::Floor(($volume.Size - $reserve) / 1GB) * 1GB + if ($csvBytes -lt 20GB) { throw "The lab volume is too small for a cluster shared volume; make scvmm_lab_storage_gb at least $([math]::Ceiling(($reserve + 20GB) / 1GB))." } + $disks = [ordered]@{ 'witness.vhdx' = 1GB; 'csv01.vhdx' = $csvBytes } + foreach ($file in $disks.Keys) { + $path = Join-Path $dir $file + if (-not (Lookup { Get-IscsiVirtualDisk -Path $path -ErrorAction Stop })) { + New-IscsiVirtualDisk -Path $path -SizeBytes $disks[$file] | Out-Null + Log "Created iSCSI virtual disk $path ($([math]::Round($disks[$file] / 1GB)) GB, dynamically expanding)" + } + $mapped = @((Get-IscsiServerTarget -TargetName $target).LunMappings | ForEach-Object { $_.Path }) + if ($mapped -notcontains $path) { Add-IscsiVirtualDiskTargetMapping -TargetName $target -Path $path } + } + Mark 'TARGET_IQN' (Get-IscsiServerTarget -TargetName $target).TargetIqn +""" + +HOST_CONNECT = r""" + $portal = Decode '__CB_PORTAL__' + $targetIqn = Decode '__CB_TARGET_IQN__' + $targetName = Decode '__CB_TARGET__' + if (-not (Lookup { Get-IscsiTargetPortal -TargetPortalAddress $portal -ErrorAction Stop })) { + New-IscsiTargetPortal -TargetPortalAddress $portal | Out-Null + } else { + Update-IscsiTargetPortal -TargetPortalAddress $portal | Out-Null + } + # Microsoft target names end in --target; match on that if the server did not report the IQN. + $target = Get-IscsiTarget | Where-Object { + $_.NodeAddress -eq $targetIqn -or (-not $targetIqn -and $_.NodeAddress -like "*-$targetName-target") + } | Select-Object -First 1 + if (-not $target) { throw "$portal does not offer target $targetName to this host; check TCP 3260 between the servers and the target's initiator list." } + if (-not $target.IsConnected) { + Connect-IscsiTarget -NodeAddress $target.NodeAddress -TargetPortalAddress $portal -IsPersistent $true | Out-Null + Log "Connected $($target.NodeAddress)" + } + $count = 0 + for ($i = 0; $i -lt 12 -and $count -lt 2; $i++) { + Update-HostStorageCache + $count = @(Get-Disk | Where-Object { $_.BusType -eq 'iSCSI' }).Count + if ($count -lt 2) { Start-Sleep -Seconds 5 } + } + if ($count -lt 2) { throw "Only $count of the 2 iSCSI disks are visible." } + Mark 'DISKS' $count +""" + + +def run(job, resource=None, **kwargs): + resource = resource or job.resource_set.first() + try: + lab = scvmm_lab.Lab(resource) + restart = [] + for host in lab.hosts: + log = scvmm_lab.run_task(host, FEATURES, "install Hyper-V and Failover Clustering", timeout=2700) + if scvmm_lab.markers(log).get("RESTART") == "1": + restart.append(host) + if restart: + scvmm_lab.restart(restart, "finish installing Hyper-V") + + iqns, portal = [], "" + for host in lab.hosts: + client = scvmm_lab.ec2_client(host) + found, _ = scvmm_lab.run_ps(host, HOST_SETUP, tokens={ + "CLUSTER_IP": scvmm_lab.cluster_ip(client, host), "SWITCH": SWITCH, + "GATEWAY": NAT_GATEWAY, "PREFIX": NAT_PREFIX, + }) + iqns.append(found["IQN"]) + set_progress(f"{host.hostname}: Hyper-V ready, NAT switch {SWITCH}, initiator {found['IQN']}") + + found, _ = scvmm_lab.run_ps(lab.vmm, TARGET_SETUP, tokens={ + "TARGET": TARGET, "IQNS": ",".join(iqns), "RESERVE_GB": RESERVE_GB, "LABEL": scvmm_lab.STORAGE_LABEL, + }, timeout=600) + target_iqn = found.get("TARGET_IQN", "") + portal = scvmm_lab.describe_instance(scvmm_lab.ec2_client(lab.vmm), lab.vmm)["PrivateIpAddress"] + set_progress(f"{lab.vmm.hostname}: iSCSI target {target_iqn or TARGET} on {portal}") + + for host in lab.hosts: + scvmm_lab.run_ps(host, HOST_CONNECT, tokens={"PORTAL": portal, "TARGET_IQN": target_iqn, "TARGET": TARGET}) + set_progress(f"{host.hostname}: connected to {target_iqn or TARGET}") + except LabError as err: + return "FAILURE", "", str(err) + return "SUCCESS", (f"{len(lab.hosts)} Hyper-V hosts ready with NAT switch {SWITCH} ({NAT_PREFIX}) and " + f"the lab's iSCSI disks from {lab.vmm.hostname}."), "" diff --git a/plugins/OHK-ive3ka22/OHK-ive3ka22_metadata.json b/plugins/OHK-ive3ka22/OHK-ive3ka22_metadata.json new file mode 100644 index 00000000..35845765 --- /dev/null +++ b/plugins/OHK-ive3ka22/OHK-ive3ka22_metadata.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "sharedModules": [ + "shared_modules/SHM-dpj24dfj" + ] + }, + "description": "Adds the SCVMM lab's failover cluster to SCVMM under All Hosts with a Run As account for the domain service account.", + "id": "OHK-ive3ka22", + "max_retries": 0, + "name": "Add Hyper-V Cluster to SCVMM", + "resource_technologies": [], + "script_filename": "OHK-ive3ka22_script.py", + "shared": false, + "target_os_families": [], + "type": "CloudBolt Plug-in" +} \ No newline at end of file diff --git a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py new file mode 100644 index 00000000..b2cbbe58 --- /dev/null +++ b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py @@ -0,0 +1,79 @@ +""" +Add Hyper-V Cluster to SCVMM + +Build item 7 of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce), after +Install SCVMM and Create Hyper-V Cluster. It runs on the SCVMM server as a +scheduled task signed in as the domain service account (an SCVMM +administrator, because it installed SCVMM): + + 1. Create the Run As account RUN_AS for the domain service account, unless + it exists. SCVMM uses it to install its agent on every node; it must be + a domain account in each node's local Administrators group. + 2. Add the cluster to the All Hosts group with Add-SCVMHostCluster, unless + SCVMM already manages it, and report each node's state. + +Re-running it after a success changes nothing. + +CloudBolt renders this file as a template before running it, so it must never +contain template tags; values reach the scripts through the __CB_*__ tokens. + +References: + Add existing Hyper-V hosts and clusters: https://learn.microsoft.com/en-us/system-center/vmm/hyper-v-existing?view=sc-vmm-2025 + Ports and protocols: https://learn.microsoft.com/en-us/system-center/vmm/plan-ports-protocols?view=sc-vmm-2025 + Get-SCVMMServer: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmmserver?view=systemcenter-ps-2025 + New-SCRunAsAccount: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/new-scrunasaccount?view=systemcenter-ps-2025 + Get-SCVMHostGroup: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmhostgroup?view=systemcenter-ps-2025 + Add-SCVMHostCluster: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/add-scvmhostcluster?view=systemcenter-ps-2025 + Get-SCVMHostCluster: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmhostcluster?view=systemcenter-ps-2025 +""" +from common.methods import set_progress + +from shared_modules import scvmm_lab +from shared_modules.scvmm_lab import LabError + +RUN_AS = "CloudBolt SCVMM Lab Hosts" + +ADD_CLUSTER = r""" + Import-Module VirtualMachineManager + $vmm = Get-SCVMMServer -ComputerName $env:COMPUTERNAME + $clusterName = Decode '__CB_CLUSTER__' + $runAsName = Decode '__CB_RUN_AS__' + $runAs = Get-SCRunAsAccount -VMMServer $vmm -Name $runAsName + if (-not $runAs) { + $secret = ConvertTo-SecureString -String (Decode '__CB_PASSWORD__') -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential -ArgumentList (Decode '__CB_USER__'), $secret + $runAs = New-SCRunAsAccount -VMMServer $vmm -Name $runAsName -Credential $credential -Description 'Domain service account of the CloudBolt SCVMM lab; local administrator on every Hyper-V host.' + Log "Created Run As account $runAsName" + } + $cluster = Get-SCVMHostCluster -VMMServer $vmm -Name $clusterName + if (-not $cluster) { + $allHosts = Get-SCVMHostGroup -VMMServer $vmm | Where-Object { $_.Path -eq 'All Hosts' } + Log "Adding cluster $clusterName to All Hosts" + Add-SCVMHostCluster -VMMServer $vmm -Name $clusterName -VMHostGroup $allHosts -Credential $runAs | Out-Null + $cluster = Get-SCVMHostCluster -VMMServer $vmm -Name $clusterName + } + if (-not $cluster) { throw "SCVMM does not list cluster $clusterName after Add-SCVMHostCluster." } + $nodes = @($cluster.Nodes) + foreach ($node in $nodes) { Log "$($node.Name): $($node.OverallState), $($node.CommunicationState)" } + Mark 'NODES' $nodes.Count + Mark 'SHARED_VOLUMES' ((@($cluster.SharedVolumes) | ForEach-Object { $_.Name }) -join ' ') +""" + + +def run(job, resource=None, **kwargs): + resource = resource or job.resource_set.first() + try: + lab = scvmm_lab.Lab(resource) + log = scvmm_lab.run_task(lab.vmm, ADD_CLUSTER, f"add cluster {lab.cluster_fqdn} to SCVMM", tokens={ + "CLUSTER": lab.cluster_fqdn, "RUN_AS": RUN_AS, "USER": lab.username, "PASSWORD": lab.password, + }, account=lab.account, hidden=[lab.password], timeout=2700) + found = scvmm_lab.markers(log) + nodes = int(found.get("NODES") or 0) + if nodes < len(lab.hosts): + raise LabError(f"SCVMM lists {nodes} of the {len(lab.hosts)} nodes of {lab.cluster_fqdn}.") + set_progress(f"SCVMM on {lab.fqdn(lab.vmm)} manages {lab.cluster_fqdn} ({nodes} nodes); " + f"shared volumes: {found.get('SHARED_VOLUMES') or 'none reported'}") + except LabError as err: + return "FAILURE", "", str(err) + return "SUCCESS", (f"SCVMM on {lab.fqdn(lab.vmm)} manages cluster {lab.cluster_fqdn} with {nodes} Hyper-V " + f"hosts, using Run As account '{RUN_AS}'."), "" diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json new file mode 100644 index 00000000..d98dba64 --- /dev/null +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "sharedModules": [ + "shared_modules/SHM-gcba1u31" + ] + }, + "description": "Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted.", + "id": "OHK-kzb6pzzu", + "max_retries": 0, + "name": "Remove Hyper-V Cluster Object", + "resource_technologies": [], + "script_filename": "OHK-kzb6pzzu_script.py", + "shared": false, + "target_os_families": [], + "type": "CloudBolt Plug-in" +} \ No newline at end of file diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py new file mode 100644 index 00000000..a750ca2c --- /dev/null +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py @@ -0,0 +1,60 @@ +""" +Remove Hyper-V Cluster Object + +Teardown item of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce). +Create Hyper-V Cluster made a computer object for the cluster name (the CNO) +in the hosts' OU. This deletes it over LDAP with the LDAP Utility that serves +the lab's domain, the same utility Join Windows Server to AD Domain joins with, +through the ad_domain shared module (shared_modules/SHM-gcba1u31). The +servers' own computer objects are left to Delete Windows Computer Object from +AD (HPA-q181uofy), and the servers and the storage volume are deleted with +the resource. + +Idempotent: a lab that never got a cluster, or a CNO that is already gone, +ends with SUCCESS; a CNO that cannot be deleted ends with WARNING so the +rest of the delete goes on. + +CloudBolt renders this file as a template before running it, so it must never +contain template tags. +""" +from common.methods import set_progress +from utilities.logger import ThreadLogger + +from shared_modules import ad_domain + +logger = ThreadLogger(__name__) + + +def run(job, resource=None, **kwargs): + resource = resource or job.resource_set.first() + cluster = str(resource.get_value_for_custom_field("scvmm_lab_cluster") or "").strip().lower() + domain = str(resource.get_value_for_custom_field("scvmm_lab_domain") or "").strip().lower() + if not cluster or not domain: + return "SUCCESS", "The lab has no cluster recorded; no computer object to delete.", "" + name = cluster.split(".")[0] + + matches = [u for u in ad_domain.utilities() if ad_domain.utility_domain(u) == domain] + if len(matches) != 1: + return "WARNING", "", (f"{len(matches)} LDAP Utilities serve {domain}, so the computer object of cluster " + f"{name} was not deleted. Delete it in Active Directory.") + try: + conn = ad_domain.connect(matches[0]) + try: + found = ad_domain.find_computers(conn, ad_domain.search_base(matches[0], conn), name=name) + if not found: + return "SUCCESS", f"Cluster {name} has no computer object in {domain}; nothing to delete.", "" + if len(found) > 1: + return "WARNING", "", f"Found several computer objects named {name} in {domain}; none was deleted." + dns_name = (found[0]["dns_host_name"] or "").lower() + if dns_name and dns_name != cluster: + return "WARNING", "", (f"Computer object {found[0]['dn']} has DNS name {dns_name}, not {cluster}; " + "it was not deleted.") + set_progress(f"Deleting {found[0]['dn']}") + ad_domain.delete_entry(conn, found[0]["dn"]) + finally: + conn.unbind_s() + except Exception as err: + logger.exception("Deleting the computer object of cluster %s failed", name) + return "WARNING", "", (f"Could not delete the computer object of cluster {name}: {err}. The LDAP Utility's " + "account needs the right to delete computer objects in the hosts' OU.") + return "SUCCESS", f"Deleted the computer object of cluster {name} from {domain}.", "" diff --git a/plugins/OHK-q6fb9833/OHK-q6fb9833_metadata.json b/plugins/OHK-q6fb9833/OHK-q6fb9833_metadata.json new file mode 100644 index 00000000..9aac61ae --- /dev/null +++ b/plugins/OHK-q6fb9833/OHK-q6fb9833_metadata.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "sharedModules": [ + "shared_modules/SHM-dpj24dfj" + ] + }, + "description": "Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role.", + "id": "OHK-q6fb9833", + "max_retries": 0, + "name": "Prepare SCVMM Lab on AWS", + "resource_technologies": [], + "script_filename": "OHK-q6fb9833_script.py", + "shared": false, + "target_os_families": [], + "type": "CloudBolt Plug-in" +} \ No newline at end of file diff --git a/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py b/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py new file mode 100644 index 00000000..186dd523 --- /dev/null +++ b/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py @@ -0,0 +1,151 @@ +""" +Prepare SCVMM Lab on AWS + +Build item 3 of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce), +after both server tiers. Each step is skipped when it is already done, so the +item can be re-run. + + 1. Check that every lab server is in the domain under its CloudBolt + hostname (Join Windows Server to AD Domain, HPA-jjp1vlfi, joins them at + Post-Provision) and record the domain on the resource. + 2. Per Hyper-V host: check the instance type, stop the instance, turn on + nested virtualization and start it again (nothing on .metal sizes), and + assign one secondary private IP to its primary interface for the + cluster's IP address resource on that host. + 3. SCVMM server: grow its root volume to ROOT_GB GB and extend C: (SQL + Server, the Windows ADK and SCVMM install there), create a gp3 volume + of scvmm_lab_storage_gb GB, attach it with delete-on-termination, + format it as NTFS labeled CBLab, install + the iSCSI Target Server role and allow TCP 3260 from the hosts. The + iSCSI disks are created in Configure Hyper-V Hosts, once the hosts' + initiator names are known. The role is installed here so it never runs + at the same time as the SQL Server setup in Install SCVMM. + +The EC2 calls use the AWS handler's own boto3 client (scvmm_lab.ec2_client). +The appliance's botocore predates nested virtualization, so the shared +module adds that field to the signed request itself. + +CloudBolt renders this file as a template before running it, so it must never +contain template tags; values reach the scripts through the __CB_*__ tokens. + +References: + Install-WindowsFeature: https://learn.microsoft.com/en-us/powershell/module/servermanager/install-windowsfeature + Resize-Partition: https://learn.microsoft.com/en-us/powershell/module/storage/resize-partition + Extend a Windows volume: https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-windows.html + Initialize-Disk: https://learn.microsoft.com/en-us/powershell/module/storage/initialize-disk + New-Partition: https://learn.microsoft.com/en-us/powershell/module/storage/new-partition + Format-Volume: https://learn.microsoft.com/en-us/powershell/module/storage/format-volume + New-NetFirewallRule: https://learn.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule + iSCSI Target Server: https://learn.microsoft.com/en-us/windows-server/storage/iscsi/iscsi-target-server + EC2 calls: see shared_modules/SHM-dpj24dfj +""" +from common.methods import set_progress + +from shared_modules import scvmm_lab +from shared_modules.scvmm_lab import LabError + +ROOT_GB = 80 + +DOMAIN_CHECK = r""" + $cs = Get-CimInstance -ClassName Win32_ComputerSystem + $name = Decode '__CB_NAME__' + if (-not $cs.PartOfDomain) { + throw "$($cs.Name) is not in a domain. Set domain_ou and domain_service_account where the lab is ordered, so Join Windows Server to AD Domain joins it at Post-Provision." + } + if ($cs.Name -ne $name) { throw "The computer is named $($cs.Name), not $name." } + Mark 'DOMAIN' $cs.Domain.ToLower() +""" + +STORAGE = r""" + $label = Decode '__CB_LABEL__' + $size = [int64](Decode '__CB_SIZE_GB__') * 1GB + $hosts = @((Decode '__CB_HOST_IPS__') -split ',') + Update-HostStorageCache + $max = (Get-PartitionSupportedSize -DriveLetter C).SizeMax + if ($max -gt (Get-Partition -DriveLetter C).Size + 1GB) { + Resize-Partition -DriveLetter C -Size $max + Log "Extended C: to $([math]::Round($max / 1GB)) GB" + } + $volume = Get-Volume -FileSystemLabel $label -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $volume) { + # The lab volume is the only raw disk of its size; it can take a moment to appear after the attach. + $disk = $null + for ($i = 0; $i -lt 24 -and -not $disk; $i++) { + $disk = Get-Disk | Where-Object { $_.PartitionStyle -eq 'RAW' -and $_.Size -eq $size } | Select-Object -First 1 + if (-not $disk) { Start-Sleep -Seconds 5; Update-HostStorageCache } + } + if (-not $disk) { throw "No raw $($size / 1GB) GB disk appeared after the volume was attached." } + if ($disk.IsOffline) { Set-Disk -Number $disk.Number -IsOffline $false } + if ($disk.IsReadOnly) { Set-Disk -Number $disk.Number -IsReadOnly $false } + Initialize-Disk -Number $disk.Number -PartitionStyle GPT + $partition = New-Partition -DiskNumber $disk.Number -UseMaximumSize -AssignDriveLetter + $volume = Format-Volume -Partition $partition -FileSystem NTFS -NewFileSystemLabel $label -Confirm:$false + Log "Formatted the lab volume as $($volume.DriveLetter):" + } + $root = '{0}:\CBLab' -f $volume.DriveLetter + foreach ($dir in 'iSCSI', 'Media', 'Temp', 'Library') { + New-Item -ItemType Directory -Force -Path (Join-Path $root $dir) | Out-Null + } + $feature = Get-WindowsFeature -Name FS-iSCSITarget-Server + if (-not $feature.Installed) { + $result = Install-WindowsFeature -Name FS-iSCSITarget-Server -IncludeManagementTools + if (-not $result.Success) { throw "Install-WindowsFeature FS-iSCSITarget-Server failed: $($result.ExitCode)" } + Log "Installed the iSCSI Target Server role (restart needed: $($result.RestartNeeded))" + } + $rule = 'CBLab-iSCSI-Target' + Remove-NetFirewallRule -Name $rule -ErrorAction SilentlyContinue + New-NetFirewallRule -Name $rule -DisplayName 'CloudBolt SCVMM lab: iSCSI target' -Direction Inbound -Protocol TCP -LocalPort 3260 -RemoteAddress $hosts -Action Allow | Out-Null + Mark 'DRIVE' $volume.DriveLetter +""" + + +def _check_domains(lab): + domains = {} + for server in lab.servers: + found, _ = scvmm_lab.run_ps(server, DOMAIN_CHECK, tokens={"NAME": scvmm_lab.computer_name(server)}) + domains[server.hostname] = found["DOMAIN"] + if len(set(domains.values())) != 1: + raise LabError("The lab servers are in different domains: " + + ", ".join(f"{name} in {domain}" for name, domain in domains.items()) + ".") + return next(iter(domains.values())) + + +def run(job, resource=None, **kwargs): + resource = resource or job.resource_set.first() + try: + scvmm_lab.ensure_fields() + lab = scvmm_lab.Lab(resource) + domain = _check_domains(lab) + resource.set_value_for_custom_field("scvmm_lab_domain", domain) + set_progress(f"All {len(lab.servers)} lab servers are in {domain}") + + host_ips, cluster_ips = [], [] + for host in lab.hosts: + client = scvmm_lab.ec2_client(host) + done = scvmm_lab.enable_nested_virtualization(client, host) + set_progress(f"{host.hostname}: {done}") + ip = scvmm_lab.cluster_ip(client, host, assign=True) + cluster_ips.append(ip) + host_ips.append(scvmm_lab.describe_instance(client, host)["PrivateIpAddress"]) + set_progress(f"{host.hostname}: cluster IP address {ip}") + # A stopped and started host needs its guest agent back before the next step. + for host in lab.hosts: + scvmm_lab.run_ps(host, " Mark 'READY' 1") + + client = scvmm_lab.ec2_client(lab.vmm) + set_progress(f"{lab.vmm.hostname}: {scvmm_lab.ensure_root_size(client, lab.vmm, ROOT_GB)}") + size_gb = int(resource.get_value_for_custom_field("scvmm_lab_storage_gb") or 250) + volume_id, done = scvmm_lab.ensure_storage_volume(client, lab.vmm, size_gb, resource.id) + set_progress(f"{lab.vmm.hostname}: storage volume {volume_id}: {done}") + log = scvmm_lab.run_task(lab.vmm, STORAGE, "prepare the lab volume and the iSCSI Target Server role", tokens={ + "LABEL": scvmm_lab.STORAGE_LABEL, "SIZE_GB": size_gb, "HOST_IPS": ",".join(host_ips), + }, timeout=1800) + drive = scvmm_lab.markers(log).get("DRIVE", "?") + + resource.set_value_for_custom_field("scvmm_lab_cluster", lab.cluster_fqdn) + resource.set_value_for_custom_field("scvmm_lab_cluster_ips", ", ".join(cluster_ips)) + resource.set_value_for_custom_field("scvmm_lab_vmm_server", lab.fqdn(lab.vmm)) + except LabError as err: + return "FAILURE", "", str(err) + return "SUCCESS", (f"Nested virtualization and cluster IP addresses ready on {len(lab.hosts)} hosts; " + f"lab storage on {lab.vmm.hostname} {drive}: with the iSCSI Target Server role."), "" diff --git a/plugins/README.md b/plugins/README.md index 504b157d..b0bffb9f 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -10,6 +10,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Add AKS Node Pool | [OHK-b7poza8x](OHK-b7poza8x/) | Adds a User or System node pool on the control plane's Kubernetes version to the AKS cluster, optionally autoscaled and spread across availability zones, and records it as an AKS Node Pool sub-resource. | CloudBolt Plug-in | [Add AKS Node Pool](../resource_actions/RSA-wxd1o7s8/) | | Add AWS EKS Nodegroup | [OHK-bfhdr8vx](OHK-bfhdr8vx/) | Creates a managed node group on the EKS cluster with the chosen AMI type, instance type, disk size, and scaling bounds, and records it as a sub-resource. | CloudBolt Plug-in | [Add AWS EKS Nodegroup](../resource_actions/RSA-f9ivvn5q/) | | Add GKE Node Pool | [OHK-aaltlvmb](OHK-aaltlvmb/) | Adds a node pool on the control plane's version to the GKE cluster, optionally autoscaled or on Spot VMs, and records it as a GKE Node Pool sub-resource. | CloudBolt Plug-in | [Add GKE Node Pool](../resource_actions/RSA-hg13ra5x/) | +| Add Hyper-V Cluster to SCVMM | [OHK-ive3ka22](OHK-ive3ka22/) | Adds the SCVMM lab's failover cluster to SCVMM under All Hosts with a Run As account for the domain service account. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Add Parent Blueprints to Group | [OHK-tswevdir](OHK-tswevdir/) | Grants a newly created group explicit deploy permission on every blueprint that one of its ancestor groups is explicitly permitted to deploy. | CloudBolt Plug-in | [Add Parent Blueprints to Group](../orchestration_actions/HPA-1lp8xqo3/README.md) | | Add Resource Group to Environment | [OHK-r1imfgdx](OHK-r1imfgdx/) | Adds the created resource group as a resource_group_arm option on the provisioning environment. | CloudBolt Plug-in | [Azure Resource Group - Bicep](../blueprints/BP-p7zmh96m/README.md) | | AKS Cluster Build | [OHK-x13tmam0](OHK-x13tmam0/) | Creates an AKS cluster with Microsoft Entra ID and Azure RBAC, Azure CNI Overlay with Cilium, and automatic upgrades, registers it as a CloudBolt Kubernetes container orchestrator, and records its node pools. | CloudBolt Plug-in | [Azure Kubernetes Service](../blueprints/BP-20q58q9z/README.md) | @@ -55,6 +56,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Configure Data Disks (Windows) | [OHK-ea8opsps](OHK-ea8opsps/) | Matches each attached data disk to its Windows disk by serial number, LUN, SCSI target, or attach order, then initializes it GPT and formats it NTFS with the requested drive letter and label. | Remote Script | [Windows Server with Data Disks](../blueprints/BP-9ph7xcok/README.md) | | Configure Data Disks from Disk Map (Oracle Linux) | [OHK-9h9vphf5](OHK-9h9vphf5/) | Prepares the disks from a Linux server's disk_map in the guest: matches each one by serial number, SCSI address, or attach order, then creates an LVM volume with an XFS file system and mounts it. | CloudBolt Plug-in | [Configure Data Disks from Disk Map (Oracle Linux)](../orchestration_actions/HPA-4ptcwgg4/README.md) | | Configure Data Disks from Disk Map (Windows) | [OHK-pdwb3xso](OHK-pdwb3xso/) | Formats the disks from a Windows server's disk_map in the guest: matches each one by serial number, SCSI address, or attach order, then initializes it GPT and formats it NTFS with its drive letter and label. | CloudBolt Plug-in | [Configure Data Disks from Disk Map (Windows)](../orchestration_actions/HPA-42uy9dyo/README.md) | +| Configure Hyper-V Hosts | [OHK-8ioy2cbi](OHK-8ioy2cbi/) | Installs Hyper-V and Failover Clustering on the SCVMM lab hosts, creates their NAT switch, and connects them to the iSCSI disks it creates on the SCVMM server. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Configure Linux App Host | [OHK-o30l8kjn](OHK-o30l8kjn/) | Writes a systemd-tmpfiles log retention rule and a host profile for an application account on a Linux VM, from a config file in File Archives and the outputs of the earlier steps. | Remote Script | [Prepare Linux app host](../runbook_workflows/SWF-69r5mmdb/README.md) | | Configure Windows App Host | [OHK-lkmy7ij9](OHK-lkmy7ij9/) | Records application settings in the registry, schedules a daily log clean-up and writes an Application event on a Windows VM, from a config file in File Archives and the outputs of the earlier steps. | Remote Script | [Prepare Windows app host](../runbook_workflows/SWF-7s01lyyk/README.md) | | Create AKS Namespace | [OHK-kb4pv2yq](OHK-kb4pv2yq/) | Creates a namespace landing zone on this AKS cluster for a chosen CloudBolt group, filed as an AKS Namespace resource with the same quota, policies, and pinned environment as an ordered one. | CloudBolt Plug-in | [Create AKS Namespace](../resource_actions/RSA-jttbwkm5/) | @@ -62,6 +64,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Create Blob Container | [OHK-l25x6wd8](OHK-l25x6wd8/) | Creates a blob container in the resource's Azure storage account. | CloudBolt Plug-in | [Create Blob Container](../resource_actions/RSA-xzs5f3a2/) | | Create Environment | [OHK-yd1af0eu](OHK-yd1af0eu/) | Creates a CloudBolt environment on an AWS handler with the region and VPC stored as custom field values. | CloudBolt Plug-in | [Create VPC](../blueprints/BP-n454hj40/README.md) | | Create GKE Namespace | [OHK-cco2r73h](OHK-cco2r73h/) | Creates a namespace landing zone on this GKE cluster for a chosen CloudBolt group, filed as a GKE Namespace resource with the same quota, policies, and pinned environment as an ordered one. | CloudBolt Plug-in | [Create GKE Namespace](../resource_actions/RSA-yrnl5j6j/) | +| Create Hyper-V Cluster | [OHK-77f19kly](OHK-77f19kly/) | Creates the SCVMM lab's failover cluster as the domain service account with one IP address resource per host, a cluster shared volume and a disk witness. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Create Linux App Account | [OHK-4etpeg05](OHK-4etpeg05/) | Creates the system group, no-login system user and home directory named in a config file from File Archives on a Linux VM, when they do not exist, and outputs the account and home directory. | Remote Script | [Prepare Linux app host](../runbook_workflows/SWF-69r5mmdb/README.md) | | Create Windows App Folders | [OHK-7fxxufkt](OHK-7fxxufkt/) | Creates the local operators group and application folders named in a config file from File Archives on a Windows VM, when they do not exist, gives the group Modify on them, and outputs the root and group. | Remote Script | [Prepare Windows app host](../runbook_workflows/SWF-7s01lyyk/README.md) | | Delete AKS Node Pool | [OHK-czexzrl1](OHK-czexzrl1/) | Deletes a chosen node pool from the AKS cluster, refusing the cluster's only System pool, and removes its AKS Node Pool sub-resource. | CloudBolt Plug-in | [Delete AKS Node Pool](../resource_actions/RSA-j4f98ti1/) | @@ -112,6 +115,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Install IIS Windows | [OHK-0ql0870k](OHK-0ql0870k/) | Installs IIS on a Windows server. | Remote Script | [IIS Web Application](../blueprints/BP-122nbdt5/README.md) | | Install NGINX OEL8 | [OHK-2vdm93hu](OHK-2vdm93hu/) | Installs NGINX on an Oracle Linux 8 server. | Remote Script | [NGINX Web Application](../blueprints/BP-anonytrx/README.md) | | Install Postgres | [OHK-29uent0x](OHK-29uent0x/) | Installs PostgreSQL on an Oracle Linux 8 server. | Remote Script | [Postgres Database](../blueprints/BP-b91c5f90/README.md) | +| Install SCVMM | [OHK-8f9o1496](OHK-8f9o1496/) | Installs SQL Server 2022 Developer, the Windows ADK with the WinPE add-on and SCVMM 2025 from File Archives on the SCVMM lab's management server. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Install Windows File Server | [OHK-up7829pv](OHK-up7829pv/) | Installs the File Server role on a Windows server. | Remote Script | [Windows File Server](../blueprints/BP-psw7rclb/README.md) | | Join Linux Server to AD Domain | [OHK-exqmrl0e](OHK-exqmrl0e/) | Joins a Linux server to Active Directory with realmd, SSSD, and adcli using its LDAP utility's credentials. | CloudBolt Plug-in | [Join Linux Server to AD Domain](../orchestration_actions/HPA-o6ctckmt/README.md) | | Join Windows Server to AD Domain | [OHK-9oqn6pur](OHK-9oqn6pur/) | Joins a Windows server with Add-Computer to the Active Directory OU its domain_ou names under its CloudBolt hostname, renaming the guest when needed, switches its CloudBolt credentials to the domain_service_account connection info when set, then waits for the restart and verifies the name and secure channel. | CloudBolt Plug-in | [Join Windows Server to AD Domain](../orchestration_actions/HPA-jjp1vlfi/README.md) | @@ -143,6 +147,8 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Node Size - Generate Options by Region, OS Image, Security, Networking and Storage (Azure SKU capabilities) | [OHK-kujhsds0](OHK-kujhsds0/README.md) | Generates node_size options filtered by live Azure SKU capabilities for the selected region, image, security, networking, and storage settings. | CloudBolt Plug-in | standalone | | OpenShift Project Landing Zone | [OHK-prew0osh](OHK-prew0osh/) | Creates an OpenShift project with quota, limits, network policies, and an optional role binding, then pins a CloudBolt environment to it. | CloudBolt Plug-in | [OpenShift Project Landing Zone](../blueprints/BP-tikkhf2y/README.md) | | Order Counts by Blueprint | [OHK-yjblxbwg](OHK-yjblxbwg/) | | CloudBolt Plug-in | [Order Counts by Blueprint](../mcp_tool_actions/MTA-lp8lgi7e/) | +| Prepare SCVMM Lab on AWS | [OHK-q6fb9833](OHK-q6fb9833/) | Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | +| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](OHK-kzb6pzzu/) | Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Remove Resource Group from Environments | [OHK-vm5p34w3](OHK-vm5p34w3/) | Removes the deleted resource group's resource_group_arm option from environments on the same subscription. | CloudBolt Plug-in | [Azure Resource Group - Bicep](../blueprints/BP-p7zmh96m/README.md) | | Remove Servers from Ansible Automation Platform | [OHK-8v830go3](OHK-8v830go3/) | Removes the host records a deployment's servers hold in Ansible Automation Platform inventories through CloudBolt's own connector method, before the infrastructure is destroyed; a missing host or unreachable AAP is a warning, never a blocker. | CloudBolt Plug-in | standalone | | Request AKS Namespace Quota Change | [OHK-jeighfcq](OHK-jeighfcq/) | Moves an AKS namespace landing zone to a different size tier after approval and mirrors the new quota into its environment. | CloudBolt Plug-in | [Request AKS Namespace Quota Change](../resource_actions/RSA-7wdigcpr/) | diff --git a/shared_modules/README.md b/shared_modules/README.md index d0b85cc2..4f0ca69c 100644 --- a/shared_modules/README.md +++ b/shared_modules/README.md @@ -5,7 +5,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | Module | ID | Description | Used by | |---|---|---|---| -| `ad_domain` | [SHM-gcba1u31](SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects. | [Delete Windows Computer Object from AD](../plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](../plugins/OHK-9oqn6pur/), [Suggest Domain OUs](../plugins/OHK-z9qrccyu/) | +| `ad_domain` | [SHM-gcba1u31](SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects. | [Delete Windows Computer Object from AD](../plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](../plugins/OHK-9oqn6pur/), [Remove Hyper-V Cluster Object](../plugins/OHK-kzb6pzzu/), [Suggest Domain OUs](../plugins/OHK-z9qrccyu/) | | `aks_namespace` | [SHM-cozv547n](SHM-cozv547n/) | Managed-namespace landing zones, Azure RBAC namespace access, connection details, and GitHub pipeline identities for the AKS Namespace blueprint. | [AKS Namespace](../plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](../plugins/OHK-vi009xb8/), [Create AKS Namespace](../plugins/OHK-kb4pv2yq/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover AKS Namespaces](../plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](../plugins/OHK-t1r0y1yd/), [Manage AKS Namespace Access](../plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](../plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](../plugins/OHK-jeighfcq/), [Teardown AKS Namespace](../plugins/OHK-wmdr2ef5/) | | `aria_connection` | [SHM-u2s2d40p](SHM-u2s2d40p/) | Aria Automation 8 and Aria Orchestrator REST clients built on a CloudBolt ConnectionInfo labeled vra8 or aria, with generate-options helpers for connection and project dropdowns. | [Aria Migration Form Options](../plugins/OHK-xhpq1rn3/), [Migrate Aria Automation Deployments](../plugins/OHK-7sq2hqrb/), [Migrate Aria Automation Projects](../plugins/OHK-gyl8wlrq/), [Run Aria Orchestrator Workflow](../plugins/OHK-3bgpjmlr/) | | `azure_aks` | [SHM-ptvp0km4](SHM-ptvp0km4/) | ARM client, cluster and node pool operations, orchestrator registration, and role-assignment helpers for Azure Kubernetes Service content. | [Add AKS Node Pool](../plugins/OHK-b7poza8x/), [AKS Cluster Build](../plugins/OHK-x13tmam0/), [AKS Cluster Discovery](../plugins/OHK-uof2rcaa/), [AKS Cluster Teardown](../plugins/OHK-27oemiwb/), [AKS Namespace](../plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](../plugins/OHK-vi009xb8/), [Create AKS Namespace](../plugins/OHK-kb4pv2yq/), [Delete AKS Node Pool](../plugins/OHK-czexzrl1/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover AKS Namespaces](../plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](../plugins/OHK-t1r0y1yd/), [List AKS Node Pools](../plugins/OHK-0fp008gh/), [Manage AKS Cluster Groups](../plugins/OHK-yzmq0kzu/), [Manage AKS Namespace Access](../plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](../plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](../plugins/OHK-jeighfcq/), [Scale AKS Node Pool](../plugins/OHK-80c4ibdb/), [Teardown AKS Namespace](../plugins/OHK-wmdr2ef5/), [Upgrade AKS Node Pool](../plugins/OHK-t0j1w09c/), [Upgrade AKS Version](../plugins/OHK-ojf2vvq1/) | @@ -18,7 +18,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | `disk_map` | [SHM-8qcvbri7](SHM-8qcvbri7/) | Parses and validates a server's disk_map parameter for its operating system and runs the in-guest data disk scripts of the disk map orchestration actions. | [Attach Data Disks from Disk Map](../plugins/OHK-jzkblrv7/), [Configure Data Disks from Disk Map (Oracle Linux)](../plugins/OHK-9h9vphf5/), [Configure Data Disks from Disk Map (Windows)](../plugins/OHK-pdwb3xso/) | | `eks_namespace` | [SHM-sa5yqm9j](SHM-sa5yqm9j/) | Kubernetes API client on the EKS cluster's orchestrator, size-tier catalog, and cluster lookups for the AWS EKS Namespace blueprint. | [AWS EKS Namespace](../plugins/OHK-u9jm7p8h/), [AWS EKS Namespace Connection Details](../plugins/OHK-7n4o0hox/), [Create AWS EKS Namespace](../plugins/OHK-oguk4oad/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover AWS EKS Namespaces](../plugins/OHK-ow9x0amc/), [Extend AWS EKS Namespace Expiration](../plugins/OHK-paad1c56/), [Manage AWS EKS Namespace Access](../plugins/OHK-3902mdky/), [Manage AWS EKS Namespace Pipeline Identity](../plugins/OHK-h9moajbi/), [Request AWS EKS Namespace Quota Change](../plugins/OHK-arour20h/), [Teardown AWS EKS Namespace](../plugins/OHK-bnano0nc/) | | `env_options` | [SHM-r0oq14r7](SHM-r0oq14r7/) | RBAC-gated option sources (resource groups, subnets, images, sizes, any custom field) derived from a CloudBolt Environment for order-form dropdowns and build plugins. | [Azure PS Script Panel](../plugins/OHK-bvn2l7q1/), [Compare Azure List Prices](../plugins/OHK-r9cm4oar/), [Discover HCP Terraform No-Code Workspaces](../plugins/OHK-b1n02ula/), [Form Options](../plugins/OHK-fx500o2r/), [Generate options for HCP Terraform coordinates](../plugins/OHK-529jjzli/), [HCP Terraform No-Code Module](../plugins/OHK-axtt0yqq/), [HCP Terraform VM](../plugins/OHK-pvo05e24/), [Run Azure PowerShell Script](../plugins/OHK-pmyb1car/), [Run Azure PowerShell Script (Deployment Script)](../plugins/OHK-oblhxhw2/) | -| `file_archives` | [SHM-v8llc736](SHM-v8llc736/) | Stores versioned files on the CloudBolt appliance, signs short-lived download links for them, and adds the download step to scripts that declare files with cb-archive header lines. | [Run Task](../plugins/OHK-o4tgygjs/) | +| `file_archives` | [SHM-v8llc736](SHM-v8llc736/) | Stores versioned files on the CloudBolt appliance, signs short-lived download links for them, and adds the download step to scripts that declare files with cb-archive header lines. | [Install SCVMM](../plugins/OHK-8f9o1496/), [Run Task](../plugins/OHK-o4tgygjs/) | | `gcp_gke` | [SHM-4yw92b8x](SHM-4yw92b8x/) | GKE API client, cluster and node pool operations, Kubernetes API access verified against the cluster CA, orchestrator registration, and group entitlement helpers for Google Kubernetes Engine content. | [Add GKE Node Pool](../plugins/OHK-aaltlvmb/), [Create GKE Namespace](../plugins/OHK-cco2r73h/), [Delete GKE Node Pool](../plugins/OHK-qxdrryt6/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover GKE Namespaces](../plugins/OHK-ml7ee42y/), [Extend GKE Namespace Expiration](../plugins/OHK-vtuzh4nh/), [GKE Cluster Build](../plugins/OHK-shr5y3i6/), [GKE Cluster Discovery](../plugins/OHK-6l86xugc/), [GKE Cluster Teardown](../plugins/OHK-y9wx9bga/), [GKE Namespace](../plugins/OHK-32pzj98f/), [GKE Namespace Connection Details](../plugins/OHK-egyf9q28/), [List GKE Node Pools](../plugins/OHK-niw4hc9m/), [Manage GKE Cluster Groups](../plugins/OHK-m8iwylq8/), [Manage GKE Namespace Access](../plugins/OHK-vdhjpyg2/), [Manage GKE Namespace Pipeline Identity](../plugins/OHK-l3j30r89/), [Request GKE Namespace Quota Change](../plugins/OHK-xg47m1x2/), [Scale GKE Node Pool](../plugins/OHK-m0s3j1ax/), [Teardown GKE Namespace](../plugins/OHK-jm8j1513/), [Upgrade GKE Node Pool](../plugins/OHK-2rpjqm7u/), [Upgrade GKE Version](../plugins/OHK-91bx99mg/) | | `github` | [SHM-eybr4hgz](SHM-eybr4hgz/) | GitHub API client that authenticates with the GitHub ConnectionInfo when one is usable and otherwise fetches public repositories anonymously, with directory listing, raw file download, and archive fetch. | [Bicep Engine Connectivity Check](../plugins/OHK-b21biimg/), [Deploy Bicep Template](../plugins/OHK-gqvi9kv4/), [Drift Check](../plugins/OHK-9n4wfasa/), [Update Bicep Deployment](../plugins/OHK-9f45ede7/) | | `gke_namespace` | [SHM-kephq8iq](SHM-kephq8iq/) | Namespace landing zones on GKE clusters: quota, limits, network policies, the pinned CloudBolt environment, Kubernetes RBAC access for Google identities, GitHub Actions pipeline identities, and connection details. | [Create GKE Namespace](../plugins/OHK-cco2r73h/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover GKE Namespaces](../plugins/OHK-ml7ee42y/), [Extend GKE Namespace Expiration](../plugins/OHK-vtuzh4nh/), [GKE Namespace](../plugins/OHK-32pzj98f/), [GKE Namespace Connection Details](../plugins/OHK-egyf9q28/), [Manage GKE Namespace Access](../plugins/OHK-vdhjpyg2/), [Manage GKE Namespace Pipeline Identity](../plugins/OHK-l3j30r89/), [Request GKE Namespace Quota Change](../plugins/OHK-xg47m1x2/), [Teardown GKE Namespace](../plugins/OHK-jm8j1513/) | @@ -26,6 +26,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | `openshift_landing_zone` | [SHM-qmiweowv](SHM-qmiweowv/) | OpenShift REST client, size-tier catalog, and environment helpers for the landing-zone blueprint. | [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover OpenShift Project Landing Zones](../plugins/OHK-e7albpni/), [Extend Expiration](../plugins/OHK-3w9nejn3/), [Manage Team Access](../plugins/OHK-9zzqqz7t/), [OpenShift Project Landing Zone](../plugins/OHK-prew0osh/), [Request Quota Change](../plugins/OHK-ug53cdbx/), [Teardown OpenShift Project Landing Zone](../plugins/OHK-mpe8fl3d/) | | `runbook_tasks` | [SHM-571l7249](SHM-571l7249/) | Finds the Remote Scripts that can run on a VM, checks credentials and task inputs, and runs a chosen script for the Run Task action and its form webhook. | [Run Task](../plugins/OHK-o4tgygjs/), [Runbook Tasks](../plugins/OHK-bf3iyg9j/), [runbook_workflows](SHM-nznzhpp0/) | | `runbook_workflows` | [SHM-nznzhpp0](SHM-nznzhpp0/) | Stores workflows, works out which workflows and step actions fit a VM or a workflow's filters, builds the run form's prompts, and runs a workflow's steps in order with outputs passed between them, and exports and imports workflows for content packages. | [Run Workflow](../plugins/OHK-69gk5ne9/), [Runbook Workflows](../plugins/OHK-9ewh41dg/) | +| `scvmm_lab` | [SHM-dpj24dfj](SHM-dpj24dfj/) | Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler. | [Add Hyper-V Cluster to SCVMM](../plugins/OHK-ive3ka22/), [Configure Hyper-V Hosts](../plugins/OHK-8ioy2cbi/), [Create Hyper-V Cluster](../plugins/OHK-77f19kly/), [Install SCVMM](../plugins/OHK-8f9o1496/), [Prepare SCVMM Lab on AWS](../plugins/OHK-q6fb9833/) | | `servicenow_requests` | [SHM-ww6b1uwj](SHM-ww6b1uwj/) | ServiceNow REQ/RITM client plus the order-summary, catalog-variable, and identifier-storage helpers shared by the ServiceNow request actions. | [ServiceNow Request Approval Sync](../plugins/OHK-bsqictlo/), [ServiceNow Request: Close](../plugins/OHK-htrxkps2/), [ServiceNow Request: Close on Denial](../plugins/OHK-w8exctx7/), [ServiceNow Request: Open](../plugins/OHK-o4qmnffy/) | | `tfc_api` | [SHM-jlguerjr](SHM-jlguerjr/) | HCP Terraform REST client and run engine for workspace-per-deployment provisioning. | [Deploy Latest Version](../plugins/OHK-4y8f1vff/), [Discover HCP Terraform No-Code Workspaces](../plugins/OHK-b1n02ula/), [Form Options](../plugins/OHK-fx500o2r/), [Generate options for HCP Terraform coordinates](../plugins/OHK-529jjzli/), [HCP Terraform No-Code Module](../plugins/OHK-axtt0yqq/), [HCP Terraform VM](../plugins/OHK-pvo05e24/), [Resize](../plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](../plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](../plugins/OHK-2b9qu490/), [Terraform Update](../plugins/OHK-lvy5tj0y/) | | `vm_adoption` | [SHM-9h13o859](SHM-9h13o859/) | Adopts the VMs a Terraform deployment created (from its cloudbolt_vm_ids output) as CloudBolt Server records under the resource, hydrated through the Azure, AWS, or VMware handler, and retires them on teardown. | [Deploy Latest Version](../plugins/OHK-4y8f1vff/), [HCP Terraform No-Code Module](../plugins/OHK-axtt0yqq/), [HCP Terraform VM](../plugins/OHK-pvo05e24/), [Resize](../plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](../plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](../plugins/OHK-2b9qu490/), [Terraform Update](../plugins/OHK-lvy5tj0y/) | diff --git a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_metadata.json b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_metadata.json new file mode 100644 index 00000000..07999097 --- /dev/null +++ b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_metadata.json @@ -0,0 +1,12 @@ +{ + "description": "Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler.", + "id": "SHM-dpj24dfj", + "label": "SCVMM Lab", + "max_retries": 0, + "module_name": "scvmm_lab", + "name": "scvmm_lab", + "resource_technologies": [], + "script_filename": "SHM-dpj24dfj_script.py", + "shared": true, + "type": "Shared Module" +} \ No newline at end of file diff --git a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py new file mode 100644 index 00000000..3ca94f00 --- /dev/null +++ b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py @@ -0,0 +1,679 @@ +""" +SCVMM lab: the shared steps of the SCVMM Lab on AWS blueprint +(blueprints/BP-9zp8udce). + +The blueprint builds two or more Hyper-V hosts (server tier HOST_TIER) and +one SCVMM server (server tier VMM_TIER) as EC2 instances that the Join +Windows Server to AD Domain action (orchestration_actions/HPA-jjp1vlfi) +joins to an existing domain. Its build plug-ins then call this module for: + + - the lab's servers, domain and service account (Lab); + - PowerShell in the guest through Server.execute_script (run_ps). Results + come back in CB_LAB_* marker lines and every script exits 0, because + CloudBolt's AWS SSM transport reports only the exit code of a failed + script, not its output; + - long steps, and steps that must run as the domain account, as a one-off + scheduled task (run_task) polled every POLL_INTERVAL seconds. No + transport holds a session open for an hour, and a step that talks to AD + or to other servers signs in with the account's own password, so there + is no second hop to lose its credentials on; + - restarts (restart, wait_for_restart); + - EC2 calls through the handler's boto3 client: nested virtualization, + the hosts' cluster IP addresses and the storage volume. + +Every step is safe to run again, so a failed build item can be re-run. + +The domain account comes from the domain_service_account parameter the join +action uses: the ID of a connection info labeled domain_service_account. Its +password reaches the guest inside a script body, base64 encoded for quoting +only; it is scrubbed from everything this module logs or returns, and the +task's script file is deleted when the task ends. On AWS the script body stays +in Systems Manager command history (see the blueprint README). + +References: + Server.execute_script, AWS SSM: typings/infrastructure/models.pyi, resourcehandlers/aws run_script_on_guest + Register-ScheduledTask: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask + New-ScheduledTaskPrincipal: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal + Nested virtualization: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-ec2-nested-virtualization.html + ModifyInstanceCpuOptions: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyInstanceCpuOptions.html + AssignPrivateIpAddresses: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssignPrivateIpAddresses.html + CreateVolume / AttachVolume: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVolume.html + https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AttachVolume.html + ModifyInstanceAttribute: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyInstanceAttribute.html + ModifyVolume: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyVolume.html + DescribeVolumesModifications: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVolumesModifications.html + DescribeInstanceTypes: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstanceTypes.html + Windows device names (Nitro): https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html + boto3 EC2 client and waiters: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html +""" +import base64 +import re +import secrets +import time +from contextlib import contextmanager + +from botocore.exceptions import ClientError + +from common.methods import set_progress +from infrastructure.models import CustomField +from utilities.logger import ThreadLogger +from utilities.models import ConnectionInfo + +logger = ThreadLogger(__name__) + +HOST_TIER = "Hyper-V Hosts" +VMM_TIER = "SCVMM Server" +# The parameter and the connection info label share this name (HPA-jjp1vlfi). +SERVICE_ACCOUNT = "domain_service_account" +# Tag on the storage volume, valued with the resource ID. +VOLUME_TAG = "cloudbolt-scvmm-lab" +# File system label of the storage volume on the SCVMM server. +STORAGE_LABEL = "CBLab" +TASK_PATH = "\\CloudBolt\\" + +GUEST_READY_WAIT = 900 +POLL_INTERVAL = 30 +RESTART_WAIT = 1200 + +FIELDS = { + "scvmm_lab_domain": ("AD Domain", "Active Directory domain of the SCVMM lab servers."), + "scvmm_lab_cluster": ("Hyper-V Cluster", "Fully qualified name of the lab's Hyper-V failover cluster."), + "scvmm_lab_cluster_ips": ("Cluster IP Addresses", + "Secondary private IP address of each host, one per cluster IP address resource."), + "scvmm_lab_vmm_server": ("SCVMM Server", "Fully qualified name of the lab's SCVMM management server."), +} + +MARKER = re.compile(r"^CB_LAB_([A-Z0-9_]+)=(.*?)\s*$", re.MULTILINE) +RESPONSE_CODE = re.compile(r"Response Code: (-?\d+)") +COMPUTER_NAME = re.compile(r"^(?![0-9]+$)[A-Za-z0-9-]{1,15}$") + +PRELUDE = r""" +$ErrorActionPreference = 'Stop' +$ProgressPreference = 'SilentlyContinue' +$WarningPreference = 'SilentlyContinue' +function Decode([string]$Value) { [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Value)) } +function Mark([string]$Name, $Value) { Write-Output ('CB_LAB_{0}={1}' -f $Name, ("$Value" -replace '[\r\n]+', ' ')) } +function Log([string]$Text) { Write-Output ('[{0}] {1}' -f (Get-Date -Format 's'), $Text) } +# A lookup that may throw a terminating "not found" error, which -ErrorAction does not stop: $null instead. +function Lookup([scriptblock]$Query) { try { & $Query } catch { $null } } +""" + +# Wraps every step: errors become ERROR: lines and the script still exits 0. +WRAPPER = PRELUDE + r""" +try { +__CB_BODY__ + Mark 'STEP' 'OK' +} catch { + Write-Output "ERROR: $($_.Exception.Message)" +} +exit 0 +""" + +START_TASK = r""" +$Tag = Decode '__CB_TAG__' +$Root = Join-Path $env:ProgramData 'CloudBolt\ScvmmLab' +if (-not (Test-Path -LiteralPath $Root)) { + New-Item -ItemType Directory -Path $Root -Force | Out-Null + # Step scripts can hold the domain account's password: SYSTEM and Administrators only. + & icacls.exe $Root /inheritance:r /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' | Out-Null +} +$Step = Join-Path $Root "$Tag.ps1" +$Runner = Join-Path $Root "$Tag-run.ps1" +$Log = Join-Path $Root "$Tag.log" +$Exit = Join-Path $Root "$Tag.exit" +$TempDir = Decode '__CB_TEMP__' +$utf8 = New-Object Text.UTF8Encoding $true +[IO.File]::WriteAllText($Step, (Decode '__CB_SCRIPT__'), $utf8) +$runnerLines = @( + '$code = 1', + 'try {', + " if ('$TempDir') { New-Item -ItemType Directory -Force -Path '$TempDir' | Out-Null; `$env:TMP = '$TempDir'; `$env:TEMP = '$TempDir' }", + " & '$Step' *> '$Log'", + ' $code = 0 + $LASTEXITCODE', + '} catch {', + " Add-Content -LiteralPath '$Log' -Value ('ERROR: ' + `$_.Exception.Message)", + '} finally {', + " Remove-Item -LiteralPath '$Step' -Force -ErrorAction SilentlyContinue", + " Set-Content -LiteralPath '$Exit' -Value `$code", + '}' +) +[IO.File]::WriteAllText($Runner, ($runnerLines -join "`r`n"), $utf8) +$action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument ('-NoProfile -NonInteractive -ExecutionPolicy Bypass -File "{0}"' -f $Runner) +$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 4) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -MultipleInstances IgnoreNew +$User = Decode '__CB_USER__' +if ($User) { + # Task Scheduler stores DOMAIN\user; resolve a UPN through its SID. + $sid = (New-Object Security.Principal.NTAccount $User).Translate([Security.Principal.SecurityIdentifier]) + $User = $sid.Translate([Security.Principal.NTAccount]).Value + Register-ScheduledTask -TaskName $Tag -TaskPath '__TASK_PATH__' -Action $action -Settings $settings -User $User -Password (Decode '__CB_PASSWORD__') -RunLevel Highest -Force | Out-Null +} else { + $principal = New-ScheduledTaskPrincipal -UserId 'NT AUTHORITY\SYSTEM' -LogonType ServiceAccount -RunLevel Highest + Register-ScheduledTask -TaskName $Tag -TaskPath '__TASK_PATH__' -Action $action -Settings $settings -Principal $principal -Force | Out-Null +} +Start-ScheduledTask -TaskName $Tag -TaskPath '__TASK_PATH__' +Mark 'TASK_USER' $(if ($User) { $User } else { 'SYSTEM' }) +""".replace("__TASK_PATH__", TASK_PATH) + +POLL_TASK = r""" +$Tag = Decode '__CB_TAG__' +$Root = Join-Path $env:ProgramData 'CloudBolt\ScvmmLab' +$Log = Join-Path $Root "$Tag.log" +$Exit = Join-Path $Root "$Tag.exit" +if (Test-Path -LiteralPath $Exit) { + Mark 'TASK_STATE' 'DONE' + Mark 'TASK_EXIT' ((Get-Content -LiteralPath $Exit -Raw).Trim()) + if (Test-Path -LiteralPath $Log) { + # Prefixed so the step's own ERROR: lines do not read as this script's. + Get-Content -LiteralPath $Log -Tail 120 | ForEach-Object { 'LOG| ' + ("$_" -replace '^(.{300}).+$', '$1...') } + } + Unregister-ScheduledTask -TaskName $Tag -TaskPath '__TASK_PATH__' -Confirm:$false -ErrorAction SilentlyContinue + Remove-Item -LiteralPath $Log, $Exit, (Join-Path $Root "$Tag-run.ps1"), (Join-Path $Root "$Tag.ps1") -Force -ErrorAction SilentlyContinue +} else { + $task = Get-ScheduledTask -TaskName $Tag -TaskPath '__TASK_PATH__' -ErrorAction SilentlyContinue + if (-not $task) { + Mark 'TASK_STATE' 'MISSING' + } else { + $info = Get-ScheduledTaskInfo -InputObject $task + Mark 'TASK_STATE' $(if ($task.State -eq 'Running') { 'RUNNING' } else { 'NOT_RUNNING' }) + Mark 'TASK_RESULT' ('0x{0:X8}' -f $info.LastTaskResult) + if (Test-Path -LiteralPath $Log) { + $last = Get-Content -LiteralPath $Log -Tail 1 + if ($last) { Mark 'TASK_TAIL' ("$last" -replace '^(.{200}).+$', '$1...') } + } + } +} +""".replace("__TASK_PATH__", TASK_PATH) + +# Task Scheduler results seen when the task cannot start as the account. +TASK_RESULT_HINTS = { + "0x8007052E": "the domain account's user name or password is wrong", + "0x80070569": "the domain account lacks the 'Log on as a batch job' right on this server " + "(members of the local Administrators group have it by default)", + "0x80070532": "the domain account's password has expired", + "0x80070533": "the domain account is disabled", +} + +RESTART = r""" +Mark 'BOOT' ((Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().Ticks) +& shutdown.exe /r /t 15 /d p:4:2 /c 'CloudBolt SCVMM lab: restart to finish installing Windows features.' | Out-Null +if ($LASTEXITCODE) { throw "shutdown.exe could not schedule the restart (exit $LASTEXITCODE)." } +""" + +BOOT = r""" +Mark 'BOOT' ((Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().Ticks) +""" + + +class LabError(Exception): + """A problem to show the user as the build item's error.""" + + +# ---------------------------------------------------------------- lab layout + +def _tier(server): + item = getattr(server, "service_item", None) + return (getattr(item, "name", "") or "").strip() + + +def computer_name(server): + """The Windows computer name: the CloudBolt hostname's first label, as the join action sets it.""" + name = server.hostname.split(".")[0] + if not COMPUTER_NAME.match(name): + raise LabError(f"{server.hostname}: '{name}' is not a valid Windows computer name (at most 15 " + "letters, digits and hyphens, not only digits).") + return name + + +def service_account(server): + """The connection info the server's domain_service_account names. Raises LabError when unusable.""" + value = str(server.get_value_for_custom_field(SERVICE_ACCOUNT) or "").strip() + if not value: + raise LabError(f"{server.hostname} has no {SERVICE_ACCOUNT}. Set it next to domain_ou on the " + "environment, group or blueprint: the lab runs its cluster and SCVMM steps as that " + "domain account.") + account = None + if value.isdigit(): + account = ConnectionInfo.objects.filter(labels__name=SERVICE_ACCOUNT, id=int(value)).first() + if account is None: + raise LabError(f"{SERVICE_ACCOUNT} {value} on {server.hostname} is not the ID of a connection " + f"info labeled {SERVICE_ACCOUNT}.") + username = (account.username or "").strip() + if "@" not in username and "\\" not in username: + raise LabError(f"The username of connection info '{account.name}' must include its domain, as " + "user@corp.example.com.") + if not account.password: + raise LabError(f"Connection info '{account.name}' has no password.") + return account + + +class Lab: + """The resource's hosts, SCVMM server and the domain account they share.""" + + def __init__(self, resource): + self.resource = resource + tiers = {} + for server in resource.server_set.exclude(status="HISTORICAL"): + tiers.setdefault(_tier(server), []).append(server) + self.hosts = sorted(tiers.get(HOST_TIER, []), key=lambda s: s.hostname.lower()) + vmm = tiers.get(VMM_TIER, []) + found = ", ".join(f"'{name}' ({len(servers)})" for name, servers in tiers.items()) or "none" + if len(self.hosts) < 2: + raise LabError(f"The lab needs at least two servers in the '{HOST_TIER}' tier for a failover " + f"cluster. Server tiers on this resource: {found}.") + if len(vmm) != 1: + raise LabError(f"The lab needs exactly one server in the '{VMM_TIER}' tier. " + f"Server tiers on this resource: {found}.") + self.vmm = vmm[0] + accounts = {server.hostname: service_account(server) for server in self.servers} + ids = {account.id for account in accounts.values()} + if len(ids) > 1: + raise LabError("Every lab server must use the same domain_service_account; found " + + ", ".join(f"{h}: '{a.name}'" for h, a in accounts.items()) + ".") + self.account = accounts[self.vmm.hostname] + self.username = self.account.username.strip() + self.password = self.account.password + + @property + def servers(self): + return self.hosts + [self.vmm] + + @property + def domain(self): + return str(self.resource.get_value_for_custom_field("scvmm_lab_domain") or "") + + def fqdn(self, server): + return f"{computer_name(server)}.{self.domain}".lower() + + @property + def cluster_name(self): + """The cluster's NetBIOS name, at most 15 characters and unique per resource.""" + return f"hvc-{self.resource.id}" + + @property + def cluster_fqdn(self): + return f"{self.cluster_name}.{self.domain}".lower() + + +def ensure_fields(): + for name, (label, description) in FIELDS.items(): + CustomField.objects.get_or_create( + name=name, defaults=dict(label=label, description=description, type="STR", show_as_attribute=True), + ) + + +# ------------------------------------------------------------ guest scripts + +def b64(text): + return base64.b64encode(str(text).encode("utf-8")).decode("ascii") + + +def scrub(text, hidden=()): + text = str(text or "") + for value in hidden: + if value: + text = text.replace(value, "***").replace(b64(value), "***") + return text + + +def render(body, tokens=None): + """The body wrapped in WRAPPER, with every __CB___ token replaced by its value, base64 encoded.""" + script = WRAPPER.replace("__CB_BODY__", body) + for name, value in (tokens or {}).items(): + script = script.replace(f"__CB_{name}__", b64(value)) + missing = sorted(set(re.findall(r"__CB_[A-Z0-9_]+__", script))) + if missing: + raise LabError(f"Internal error: no value for {', '.join(missing)}.") + return script + + +def _execute(server, script, timeout): + """(exit code, output) of a PowerShell script; -1 when CloudBolt could not run it at all.""" + try: + output = server.execute_script( + script_contents=script, file_extension="ps1", timeout=timeout, show_streaming_output=False, + ) + return 0, str(output or "") + except Exception as err: + rv = getattr(err, "rv", None) + if rv is None: + # The AWS SSM transport raises "... Response Code: N." for a non-zero exit. + match = RESPONSE_CODE.search(str(err)) + rv = match.group(1) if match else -1 + try: + rv = int(rv) + except (TypeError, ValueError): + rv = -1 + return rv, str(getattr(err, "output", "") or err) + + +def errors(output): + return [line.strip()[len("ERROR:"):].strip() for line in (output or "").splitlines() + if line.strip().startswith("ERROR:")] + + +def markers(output): + return {name: value for name, value in MARKER.findall(output or "")} + + +def run_ps(server, body, tokens=None, timeout=300, ready_wait=GUEST_READY_WAIT, hidden=()): + """ + Run body on server and return (markers, output). Retries for up to + ready_wait seconds while CloudBolt cannot run a script in the guest (the + SSM agent or WinRM is not up yet). Raises LabError when the script + reports an error or does not finish. + """ + script = render(body, tokens) + deadline = time.time() + ready_wait + while True: + rv, output = _execute(server, script, timeout) + if rv != -1 or time.time() + POLL_INTERVAL > deadline: + break + time.sleep(POLL_INTERVAL) + output = scrub(output, hidden) + problems = errors(output) + if problems: + raise LabError(f"{server.hostname}: {' '.join(problems)}") + found = markers(output) + if rv != 0 or found.get("STEP") != "OK": + what = "CloudBolt could not run a script in the guest" if rv == -1 else f"the script ended with exit {rv}" + raise LabError(f"{server.hostname}: {what}: {output.strip()[-500:]}") + return found, output + + +def run_task(server, body, label, tokens=None, account=None, timeout=3600, hidden=(), temp_dir="", + archive_refs=None, job=None): + """ + Run body on server as a scheduled task, as account (a ConnectionInfo) or + as SYSTEM when account is None, and return its log. Waits up to timeout + seconds. archive_refs are File Archives references ("archive/file + [extract]") the task downloads before body runs; see the file_archives + shared module (shared_modules/SHM-v8llc736). temp_dir becomes the task's + TMP and TEMP, so large downloads land there. + """ + hidden = list(hidden) + user, password = "", "" + if account is not None: + user, password = account.username.strip(), account.password + hidden.append(password) + step = render(body, tokens) + if archive_refs: + try: + from shared_modules import file_archives + except ImportError: + raise LabError("The file_archives shared module (SHM-v8llc736) is not on this CloudBolt. " + "Sync the Runbooks package (packages/PKG-v20qv308).") + try: + step, _ = file_archives.prepare(step, server, job, extra_refs=archive_refs, minutes=30) + except file_archives.ArchiveError as err: + raise LabError(f"File Archives: {err}") + tag = f"cblab-{secrets.token_hex(4)}" + run_ps(server, START_TASK, tokens={ + "TAG": tag, "SCRIPT": step, "USER": user, "PASSWORD": password, "TEMP": temp_dir, + }, hidden=hidden) + set_progress(f"{server.hostname}: {label} (scheduled task {TASK_PATH}{tag} as {user or 'SYSTEM'})") + deadline = time.time() + timeout + last_tail, not_running = "", 0 + while True: + time.sleep(POLL_INTERVAL) + found, output = run_ps(server, POLL_TASK, tokens={"TAG": tag}, hidden=hidden) + state = found.get("TASK_STATE") + if state == "DONE": + log = "\n".join(line[len("LOG| "):] for line in output.splitlines() if line.startswith("LOG| ")) + log = scrub(log, hidden) + problems = errors(log) + if problems or markers(log).get("STEP") != "OK": + detail = " ".join(problems) or log.strip()[-800:] or f"exit {found.get('TASK_EXIT')}" + raise LabError(f"{server.hostname}: {label} failed: {detail}") + return log + if state == "MISSING": + raise LabError(f"{server.hostname}: the scheduled task for '{label}' disappeared before it finished.") + if state == "NOT_RUNNING": + # Right after Start-ScheduledTask the state can still read Ready. + not_running += 1 + if not_running >= 2: + code = found.get("TASK_RESULT", "") + hint = TASK_RESULT_HINTS.get(code, "see Task Scheduler's history for the task") + raise LabError(f"{server.hostname}: the scheduled task for '{label}' did not run " + f"(result {code}): {hint}.") + else: + not_running = 0 + tail = found.get("TASK_TAIL", "") + if tail and tail != last_tail: + set_progress(f"{server.hostname}: {tail}") + last_tail = tail + if time.time() > deadline: + raise LabError(f"{server.hostname}: '{label}' did not finish within {timeout // 60} minutes. " + f"Its scheduled task {TASK_PATH}{tag} is still on the server.") + + +def restart(servers, reason): + """Restart servers together and wait until each has booted again.""" + boots = {} + for server in servers: + found, _ = run_ps(server, RESTART) + boots[server.id] = int(found["BOOT"]) + set_progress(f"{server.hostname}: restarting to {reason}") + time.sleep(60) + for server in servers: + wait_for_restart(server, boots[server.id]) + + +def wait_for_restart(server, boot_ticks): + deadline = time.time() + RESTART_WAIT + while True: + rv, output = _execute(server, render(BOOT), 120) + ticks = markers(output).get("BOOT", "") + if rv == 0 and ticks.isdigit() and int(ticks) > boot_ticks: + set_progress(f"{server.hostname}: back up after the restart") + return + if time.time() + POLL_INTERVAL > deadline: + raise LabError(f"{server.hostname} did not come back within {RESTART_WAIT // 60} minutes of its restart.") + time.sleep(POLL_INTERVAL) + + +# ------------------------------------------------------------------- EC2 + +def ec2_client(server): + handler = server.resource_handler.cast() + return handler.get_boto3_client(server.ec2serverinfo.ec2_region, "ec2") + + +def describe_instance(client, server): + reply = client.describe_instances(InstanceIds=[server.resource_handler_svr_id]) + return reply["Reservations"][0]["Instances"][0] + + +def is_metal(instance_type): + return instance_type.partition(".")[2].startswith("metal") + + +def supports_nested(client, instance_type): + """ + Whether AWS lists nested-virtualization in the type's supported processor + features, the check the AWS nested virtualization page gives. The old + botocore model does not know the value, but its parser passes it through. + """ + reply = client.describe_instance_types(InstanceTypes=[instance_type]) + features = reply["InstanceTypes"][0].get("ProcessorInfo", {}).get("SupportedFeatures", []) + return "nested-virtualization" in features + + +@contextmanager +def _raw_reply(client, operation): + """Collect the raw XML replies of operation, for fields the installed botocore model does not parse.""" + replies = [] + + def keep(http_response, **kwargs): + replies.append(http_response.text) + + event = f"after-call.ec2.{operation}" + client.meta.events.register(event, keep) + try: + yield replies + finally: + client.meta.events.unregister(event, keep) + + +@contextmanager +def _nested_virtualization_field(client, keep_cpu_counts): + """ + Add NestedVirtualization=enabled to ModifyInstanceCpuOptions requests. + The botocore on the appliance predates the field and requires CoreCount + and ThreadsPerCore, which the API itself does not; the field is added to + the form body before SigV4 signs it, and the counts are dropped unless + keep_cpu_counts. + """ + def add(params, **kwargs): + body = params["body"] + body["NestedVirtualization"] = "enabled" + if not keep_cpu_counts: + body.pop("CoreCount", None) + body.pop("ThreadsPerCore", None) + + event = "before-call.ec2.ModifyInstanceCpuOptions" + client.meta.events.register(event, add) + try: + yield + finally: + client.meta.events.unregister(event, add) + + +def nested_virtualization_enabled(client, server): + with _raw_reply(client, "DescribeInstances") as replies: + client.describe_instances(InstanceIds=[server.resource_handler_svr_id]) + cpu = re.search(r"(.*?)", replies[-1] if replies else "", re.S) + return bool(cpu and "enabled" in cpu.group(1)) + + +def _modify_cpu_options(client, instance, keep_cpu_counts): + cpu = instance.get("CpuOptions") or {} + with _nested_virtualization_field(client, keep_cpu_counts), _raw_reply(client, "ModifyInstanceCpuOptions") as replies: + client.modify_instance_cpu_options( + InstanceId=instance["InstanceId"], + CoreCount=cpu.get("CoreCount", 1), + ThreadsPerCore=cpu.get("ThreadsPerCore", 1), + ) + return replies[-1] if replies else "" + + +def enable_nested_virtualization(client, server): + """Stop the instance, turn nested virtualization on and start it. Returns what was done.""" + instance = describe_instance(client, server) + instance_type = instance["InstanceType"] + if is_metal(instance_type): + return f"{instance_type} is bare metal; Hyper-V runs without nested virtualization" + if not supports_nested(client, instance_type): + raise LabError(f"{server.hostname} is {instance_type}, which AWS does not list as supporting nested " + "virtualization. Use a size from a family the AWS nested virtualization page lists " + "(for example m8i, c8i, r8i or m7i), or a .metal size.") + if nested_virtualization_enabled(client, server): + return "nested virtualization was already on" + instance_id = instance["InstanceId"] + waiter_config = {"Delay": 15, "MaxAttempts": 80} + set_progress(f"{server.hostname}: stopping {instance_id} to turn on nested virtualization") + client.stop_instances(InstanceIds=[instance_id]) + client.get_waiter("instance_stopped").wait(InstanceIds=[instance_id], WaiterConfig=waiter_config) + try: + reply = _modify_cpu_options(client, instance, keep_cpu_counts=False) + except ClientError as err: + if err.response.get("Error", {}).get("Code") != "MissingParameter": + raise + reply = _modify_cpu_options(client, instance, keep_cpu_counts=True) + if "enabled" not in reply: + logger.warning("ModifyInstanceCpuOptions reply for %s did not echo nestedVirtualization: %s", + instance_id, reply[:500]) + set_progress(f"{server.hostname}: starting {instance_id}") + client.start_instances(InstanceIds=[instance_id]) + client.get_waiter("instance_running").wait(InstanceIds=[instance_id], WaiterConfig=waiter_config) + try: + # A public IP changes across a stop and start. + server.refresh_info(skip_tags=True) + except Exception as err: + logger.warning("refresh_info for %s failed: %s", server.hostname, err) + return "stopped it, turned nested virtualization on and started it" + + +def _primary_interface(instance): + for interface in instance.get("NetworkInterfaces", []): + if interface.get("Attachment", {}).get("DeviceIndex") == 0: + return interface + raise LabError(f"Instance {instance['InstanceId']} has no primary network interface.") + + +def cluster_ip(client, server, assign=False): + """The secondary private IP of the host's primary interface; assigns one when assign and there is none.""" + interface = _primary_interface(describe_instance(client, server)) + secondary = [a["PrivateIpAddress"] for a in interface.get("PrivateIpAddresses", []) if not a.get("Primary")] + if secondary or not assign: + return secondary[0] if secondary else "" + reply = client.assign_private_ip_addresses( + NetworkInterfaceId=interface["NetworkInterfaceId"], SecondaryPrivateIpAddressCount=1, + ) + assigned = [a["PrivateIpAddress"] for a in reply.get("AssignedPrivateIpAddresses", [])] + if not assigned: + raise LabError(f"{server.hostname}: AWS assigned no secondary private IP to {interface['NetworkInterfaceId']}.") + return assigned[0] + + +def ensure_root_size(client, server, size_gb): + """Grow the instance's root EBS volume to size_gb when it is smaller. The guest must then extend C:.""" + instance = describe_instance(client, server) + root = next((m for m in instance.get("BlockDeviceMappings", []) + if m.get("DeviceName") == instance.get("RootDeviceName")), None) + if root is None: + raise LabError(f"{server.hostname}: cannot find the root volume of {instance['InstanceId']}.") + volume_id = root["Ebs"]["VolumeId"] + current = client.describe_volumes(VolumeIds=[volume_id])["Volumes"][0]["Size"] + if current >= size_gb: + return f"root volume {volume_id} is {current} GB" + client.modify_volume(VolumeId=volume_id, Size=int(size_gb)) + # The new size is usable once the modification is optimizing or completed. + deadline = time.time() + 900 + while True: + state = client.describe_volumes_modifications(VolumeIds=[volume_id])["VolumesModifications"][0] + if state["ModificationState"] in ("optimizing", "completed"): + return f"grew root volume {volume_id} from {current} to {size_gb} GB" + if state["ModificationState"] == "failed": + raise LabError(f"{server.hostname}: growing {volume_id} failed: {state.get('StatusMessage', '')}") + if time.time() > deadline: + raise LabError(f"{server.hostname}: growing {volume_id} did not finish within 15 minutes.") + time.sleep(10) + + +def ensure_storage_volume(client, server, size_gb, resource_id): + """Create and attach the lab's gp3 storage volume to server once. Returns (volume ID, what was done).""" + instance = describe_instance(client, server) + instance_id = instance["InstanceId"] + tag_filter = {"Name": f"tag:{VOLUME_TAG}", "Values": [str(resource_id)]} + attached = client.describe_volumes( + Filters=[tag_filter, {"Name": "attachment.instance-id", "Values": [instance_id]}])["Volumes"] + if attached: + return attached[0]["VolumeId"], "already attached" + zone = instance["Placement"]["AvailabilityZone"] + # A volume a failed earlier run created but did not attach. + loose = client.describe_volumes( + Filters=[tag_filter, {"Name": "status", "Values": ["available"]}, + {"Name": "availability-zone", "Values": [zone]}])["Volumes"] + if loose: + volume_id = loose[0]["VolumeId"] + else: + volume_id = client.create_volume( + AvailabilityZone=zone, Size=int(size_gb), VolumeType="gp3", + TagSpecifications=[{"ResourceType": "volume", "Tags": [ + {"Key": VOLUME_TAG, "Value": str(resource_id)}, + {"Key": "Name", "Value": f"{server.hostname} SCVMM lab storage"}, + ]}], + )["VolumeId"] + client.get_waiter("volume_available").wait(VolumeIds=[volume_id], WaiterConfig={"Delay": 5, "MaxAttempts": 60}) + used = {m.get("DeviceName", "").replace("/dev/", "") for m in instance.get("BlockDeviceMappings", [])} + device = next((f"xvd{letter}" for letter in "fghijklmnopqrstuvwxyz" if f"xvd{letter}" not in used), None) + if device is None: + raise LabError(f"{server.hostname}: no free device name between xvdf and xvdz.") + client.attach_volume(Device=device, InstanceId=instance_id, VolumeId=volume_id) + client.get_waiter("volume_in_use").wait(VolumeIds=[volume_id], WaiterConfig={"Delay": 5, "MaxAttempts": 60}) + # Terminating the SCVMM server deletes the volume with it. + client.modify_instance_attribute( + InstanceId=instance_id, + BlockDeviceMappings=[{"DeviceName": device, "Ebs": {"DeleteOnTermination": True}}], + ) + return volume_id, f"created {size_gb} GB gp3 volume {volume_id} and attached it as {device}" From 7931d705915193c84d5b2e763a86d162aa07d155 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:00:12 -0500 Subject: [PATCH 02/22] Point the SCVMM lab tiers at the Windows Server 2025 build with all environments enabled The tier's OS build limits the environments it offers, so enabling all of them leaves only the environments that carry the build. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json | 12 ++++++------ blueprints/BP-9zp8udce/README.md | 15 +++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json index b0a2015a..e7012bbf 100644 --- a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json +++ b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json @@ -3,7 +3,7 @@ "auto_historical_resources": false, "deployment_items": [ { - "all_environments_enabled": false, + "all_environments_enabled": true, "allowed_os_families": [ "Windows" ], @@ -16,8 +16,8 @@ "id": "BDI-wctopceu", "name": "Hyper-V Hosts", "os_build": { - "href": "/api/v3/cmp/osBuilds/OSB-35y5mshd/", - "title": "Windows 2025" + "href": "/api/v3/cmp/osBuilds/OSB-bocl2o1o/", + "title": "Windows Server 2025" }, "rate": null, "restrict_applications": false, @@ -25,7 +25,7 @@ "tier_type": "server" }, { - "all_environments_enabled": false, + "all_environments_enabled": true, "allowed_os_families": [ "Windows" ], @@ -38,8 +38,8 @@ "id": "BDI-olzewnbv", "name": "SCVMM Server", "os_build": { - "href": "/api/v3/cmp/osBuilds/OSB-35y5mshd/", - "title": "Windows 2025" + "href": "/api/v3/cmp/osBuilds/OSB-bocl2o1o/", + "title": "Windows Server 2025" }, "rate": null, "restrict_applications": false, diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 58f5707e..f1306730 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -10,8 +10,8 @@ Every server joins an existing Active Directory domain. The build runs unattende ## Contents | Role | ID | Name | |---|---|---| -| Server tier (seq 1, parallel) | — | Hyper-V Hosts (OS build "Windows 2025"; hostname `hvlab-00X`; order 2 or more) | -| Server tier (seq 2) | — | SCVMM Server (OS build "Windows 2025"; hostname `vmmlab-00X`; order 1) | +| Server tier (seq 1, parallel) | — | Hyper-V Hosts (OS build "Windows Server 2025"; hostname `hvlab-00X`; all environments enabled; order 2 or more) | +| Server tier (seq 2) | — | SCVMM Server (OS build "Windows Server 2025"; hostname `vmmlab-00X`; all environments enabled; order 1) | | Build (Plug-in, seq 3) | OHK-q6fb9833 | Prepare SCVMM Lab on AWS | | Build (Plug-in, seq 4, parallel) | OHK-8f9o1496 | Install SCVMM | | Build (Plug-in, seq 5) | OHK-8ioy2cbi | Configure Hyper-V Hosts | @@ -56,13 +56,12 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster 2. In CloudBolt, go to **Admin > Custom Extensions > Runbooks > File Archives**: - **Settings:** set **Largest upload** to 1100 MB or more, and set a download base URL the lab's VPC can reach. - Create archive `scvmm` and upload `SCVMM_2025.zip` unchanged. -3. Sync the blueprint, then open it in **Catalog**: - - **Hyper-V Hosts** tier: enable the AWS environment, and limit **Instance Type** to sizes AWS lists as supporting nested virtualization, for example `m7i.xlarge`, `m8i.xlarge` or `r7i.xlarge`. Bare metal sizes also work. - - **SCVMM Server** tier: enable the same environment. SCVMM's documented minimum is 8 cores and 16 GB of RAM; `m7i.2xlarge` meets it, and `m7i.xlarge` saves cost in a lab. - - Re-point both tiers' OS build if yours is not "Windows 2025" (`OSB-35y5mshd` is instance-specific). +3. On the AWS environment's **Parameters** tab, add instance types that support nested virtualization to **Instance type**, for example `m7i.xlarge`, `m8i.xlarge` or `r7i.xlarge`. Bare metal sizes also work. SCVMM's documented minimum is 8 cores and 16 GB of RAM; `m7i.2xlarge` meets it, and `m7i.xlarge` saves cost in a lab. +4. Sync the blueprint, then open it in **Catalog**: + - Both tiers have all environments enabled. The tier's OS build limits them to environments that offer it; re-point both tiers to your Windows Server 2025 build (`OSB-bocl2o1o` is instance-specific), or restrict their environments. - If you uploaded under another name, change the `scvmm_media` option. -4. Grant the groups that may order it. -5. Order it with **Hyper-V Hosts** quantity 2 or more and **SCVMM Server** quantity 1. +5. Grant the groups that may order it. +6. Order it with **Hyper-V Hosts** quantity 2 or more and **SCVMM Server** quantity 1. ## Notes - **Re-running a build item.** Every step is skipped when it is already done. From 0d7e356ef328db3970d4fe03fd1509820c3671dd Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 13:57:10 -0500 Subject: [PATCH 03/22] Retry the domain join rename when the domain controller is busy Add-Computer -NewName joins the computer and then renames it. In testing the SCVMM lab's third server joined, but its rename returned 0x200e (The directory service is busy) while the other two servers were restarting and updating their own objects on the same domain controller. The join action now checks whether only the rename failed and retries it with Rename-Computer up to five times, 15 seconds apart, and the rename-only path gets the same retries. Also document the Quantity parameter the SCVMM lab's host tier needs. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 4 +- plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py | 47 ++++++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index f1306730..5d539a61 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -56,7 +56,9 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster 2. In CloudBolt, go to **Admin > Custom Extensions > Runbooks > File Archives**: - **Settings:** set **Largest upload** to 1100 MB or more, and set a download base URL the lab's VPC can reach. - Create archive `scvmm` and upload `SCVMM_2025.zip` unchanged. -3. On the AWS environment's **Parameters** tab, add instance types that support nested virtualization to **Instance type**, for example `m7i.xlarge`, `m8i.xlarge` or `r7i.xlarge`. Bare metal sizes also work. SCVMM's documented minimum is 8 cores and 16 GB of RAM; `m7i.2xlarge` meets it, and `m7i.xlarge` saves cost in a lab. +3. On the AWS environment's **Parameters** tab: + - Add instance types that support nested virtualization to **Instance type**, for example `m7i.xlarge`, `m8i.xlarge` or `r7i.xlarge`. Bare metal sizes also work. SCVMM's documented minimum is 8 cores and 16 GB of RAM; `m7i.2xlarge` meets it, and `m7i.xlarge` saves cost in a lab. + - Add **Quantity** with minimum 1 and maximum 8. Without it the order form has no host count and an order with more than one host is refused. Adding it to the ordering group instead works too. 4. Sync the blueprint, then open it in **Catalog**: - Both tiers have all environments enabled. The tier's OS build limits them to environments that offer it; re-point both tiers to your Windows Server 2025 build (`OSB-bocl2o1o` is instance-specific), or restrict their environments. - If you uploaded under another name, change the `scvmm_media` option. diff --git a/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py b/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py index e31f92ea..920facfa 100644 --- a/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py +++ b/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py @@ -31,8 +31,11 @@ name is not the CloudBolt hostname (AWS Windows AMIs boot as EC2AMAZ-...), so the rename and the join share one restart. A computer already in the domain under another name is renamed with Rename-Computer - and the join account. The restart is scheduled 15 seconds out so the call - returns first. + and the join account; so is one whose join succeeded but whose rename + failed. Renames are tried up to five times, 15 seconds apart, because a + domain controller can answer "The directory service is busy" while other + computers join (seen when a blueprint's servers join at once). The + restart is scheduled 15 seconds out so the call returns first. 2. When the script joined the computer and domain_service_account is set, switch the server's credentials to the service account. 3. Wait for the restart and run VERIFY_SCRIPT until the guest has booted @@ -98,6 +101,20 @@ $ProgressPreference = 'SilentlyContinue' $WarningPreference = 'SilentlyContinue' function Decode([string]$Value) { [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Value)) } +# A domain controller can refuse a rename for a moment with "The directory +# service is busy" (ERROR_DS_BUSY, 0x200e in NetSetup.log), for example while +# other computers join or restart; retry it with the join account. +function Rename-InDomain { + for ($attempt = 1; ; $attempt++) { + try { + Rename-Computer -NewName $NewName -DomainCredential $credential -Force -WarningAction SilentlyContinue + return + } catch { + if ($attempt -ge 5) { throw } + Start-Sleep -Seconds 15 + } + } +} try { $Domain = Decode '__CB_DOMAIN__' $User = Decode '__CB_USER__' @@ -122,7 +139,7 @@ } # Joined under another name: rename it in the domain with the join account. try { - Rename-Computer -NewName $NewName -DomainCredential $credential -Force -WarningAction SilentlyContinue + Rename-InDomain } catch { Write-Output "ERROR: Rename-Computer to $NewName failed: $($_.Exception.Message)" exit 10 @@ -143,8 +160,22 @@ try { Add-Computer @join } catch { - Write-Output "ERROR: Add-Computer failed: $($_.Exception.Message)" - exit 4 + $message = $_.Exception.Message -replace '\s+', ' ' + # -NewName joins first and renames second. When only the rename + # failed, the computer is in the domain under its old name: retry + # the rename on its own. + $joined = Get-CimInstance -ClassName Win32_ComputerSystem + if (-not ($rename -and $joined.PartOfDomain -and $joined.Domain -eq $Domain)) { + Write-Output "ERROR: Add-Computer failed: $message" + exit 4 + } + Write-Output "CB_AD_RENAME_RETRIED=$message" + try { + Rename-InDomain + } catch { + Write-Output "ERROR: joined $Domain as $($cs.Name), but renaming it to $NewName failed: $message Retrying the rename failed too: $($_.Exception.Message)" + exit 10 + } } $result = 'JOINED' } @@ -203,7 +234,7 @@ 7: "The computer is already in a different domain; this action does not move computers between domains.", 10: "The computer is in the domain under another name and could not be renamed. The join account needs " "rights to rename computer objects in its OU (write the computer's name, DNS host name, and service " - "principal names).", + "principal names). 'The directory service is busy' means a domain controller refused every retry.", } # What Windows accepts as a computer name that keeps its full NetBIOS name: @@ -420,6 +451,10 @@ def _join_server(server): if result == "ALREADY_JOINED": set_progress("%s: already in domain %s as %s." % (hostname, domain, name)) else: + retried = markers.get("CB_AD_RENAME_RETRIED") + if retried: + set_progress("%s: joined %s as %s, but the rename to %s failed (%s); retried it on its own." % ( + hostname, domain, old_name, name, retried)) renamed = " (renamed from %s)" % old_name if old_name and old_name.lower() != name.lower() else "" done = "renamed in" if result == "RENAMED" else "joined" set_progress("%s: %s %s as %s%s, waiting for the restart." % (hostname, done, domain, name, renamed)) From beacbf3697c8183dd0bbf35be2841ece9f980600 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:03:54 -0500 Subject: [PATCH 04/22] Rename the guest before joining the domain Replace the rename retry with Microsoft's documented order: Rename-Computer locally, then Add-Computer -Options JoinWithNewName, so AD creates the computer object under the CloudBolt hostname and never renames it. The failure the retry targeted was that AD rename (Add-Computer -NewName joins under the EC2AMAZ name first), and a failed rename left an object under the old name that the cleanup action cannot find. The retry version also broke every WinRM join: CloudBolt sends the script as powershell -encodedcommand on one 8191-character command line, and the added code pushed it to about 10,900. The script's comments move to Python and the script now encodes to 7,576 characters, below main's 7,680. Co-Authored-By: Claude Opus 5.5 --- orchestration_actions/HPA-jjp1vlfi/README.md | 4 +- plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py | 89 ++++++++------------ 2 files changed, 39 insertions(+), 54 deletions(-) diff --git a/orchestration_actions/HPA-jjp1vlfi/README.md b/orchestration_actions/HPA-jjp1vlfi/README.md index 6461a003..0bef5c42 100644 --- a/orchestration_actions/HPA-jjp1vlfi/README.md +++ b/orchestration_actions/HPA-jjp1vlfi/README.md @@ -1,6 +1,6 @@ # Join Windows Server to AD Domain -Post-Provision orchestration action that joins each Windows server in the job to Active Directory by running `Add-Computer` in the guest, in the OU its `domain_ou` parameter names. The domain is the OU's DC components, and the join account is the service account of the LDAP Utility that serves that domain. The computer joins under the CloudBolt hostname: when the guest has another name (AWS Windows AMIs boot as `EC2AMAZ-...`), `Add-Computer -NewName` renames it in the same restart, and a computer already in the domain under another name is renamed with `Rename-Computer`. After the join the action waits for the restart, checks the computer name and the secure channel, and records the computer object's GUID and DN on the server (`ad_computer_object_guid`, `ad_computer_object_dn`). +Post-Provision orchestration action that joins each Windows server in the job to Active Directory by running `Add-Computer` in the guest, in the OU its `domain_ou` parameter names. The domain is the OU's DC components, and the join account is the service account of the LDAP Utility that serves that domain. The computer joins under the CloudBolt hostname: when the guest has another name (AWS Windows AMIs boot as `EC2AMAZ-...`), the guest is renamed first and joins with `-Options JoinWithNewName`, so AD creates the computer object under the CloudBolt hostname in the same restart; a computer already in the domain under another name is renamed with `Rename-Computer`. After the join the action waits for the restart, checks the computer name and the secure channel, and records the computer object's GUID and DN on the server (`ad_computer_object_guid`, `ad_computer_object_dn`). Servers without `domain_ou` are skipped. `domain_to_join` is not read: CloudBolt's own guest customization joins servers that have it. @@ -38,7 +38,7 @@ The switch writes the server's `username` and `password` parameters, the same on - vCenter: CloudBolt's own guest customization joins the domain while the VM is built only when `domain_to_join` is set. With `domain_ou` too, this action then finds it joined, skips the join and restart, keeps the server's credentials, and records the GUID. - A new VM can pass its cloud's reachability check before it takes scripts (the SSM agent registers, WinRM starts), so the action retries for up to 10 minutes while CloudBolt cannot run a script in the guest. On AWS with tech-specific execution, the instance needs an IAM instance profile that allows Systems Manager (`AmazonSSMManagedInstanceCore`). - The script schedules a restart 15 seconds after `Add-Computer`; the action waits up to 20 minutes for the guest to come back in the domain. -- Exit codes in the job log: 3 the domain controller SRV record does not resolve (DNS), 4 `Add-Computer` failed (rights, password, domain controller access, or an existing computer object the join account did not create, which Windows refuses to reuse since KB5020276), 5 the restart could not be scheduled, 7 already in another domain, 9 the name after the restart is not the CloudBolt hostname, 10 renaming a computer already in the domain failed (the join account needs rights to rename computer objects). +- Exit codes in the job log: 3 the domain controller SRV record does not resolve (DNS), 4 `Add-Computer` failed (rights, password, domain controller access, or an existing computer object the join account did not create, which Windows refuses to reuse since KB5020276), 5 the restart could not be scheduled, 7 already in another domain, 9 the name after the restart is not the CloudBolt hostname, 10 renaming a computer already in the domain failed (the join account needs rights to rename computer objects), 11 the guest could not be renamed before the join. - The join password travels in the script body, base64 encoded and decoded into a SecureString, and is scrubbed from the job output. Run Command and WinRM keep no copy; AWS Systems Manager keeps the command in its history, so limit `ssm:ListCommands` on those accounts. The service account's password goes only into the server's encrypted `password` parameter. - Only connection infos labeled `domain_service_account` are accepted, so an order cannot put another connection info's credentials on its server. - Imports enabled with `continue_on_failure: false`, so a failed join fails the order. diff --git a/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py b/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py index 920facfa..483b3eab 100644 --- a/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py +++ b/plugins/OHK-9oqn6pur/OHK-9oqn6pur_script.py @@ -27,15 +27,17 @@ when the computer is already in the domain under its CloudBolt name (CloudBolt's vCenter guest customization joins it when domain_to_join is set). Otherwise it checks that the domain's DC locator SRV record - resolves and runs Add-Computer, with -NewName when the guest's computer - name is not the CloudBolt hostname (AWS Windows AMIs boot as - EC2AMAZ-...), so the rename and the join share one restart. A computer - already in the domain under another name is renamed with Rename-Computer - and the join account; so is one whose join succeeded but whose rename - failed. Renames are tried up to five times, 15 seconds apart, because a - domain controller can answer "The directory service is busy" while other - computers join (seen when a blueprint's servers join at once). The - restart is scheduled 15 seconds out so the call returns first. + resolves and runs Add-Computer. When the guest's computer name is not the + CloudBolt hostname (AWS Windows AMIs boot as EC2AMAZ-...), it first + renames the guest locally and joins with -Options JoinWithNewName, so AD + creates the computer object under the CloudBolt hostname and the rename + and the join share one restart. (Add-Computer -NewName instead joins + under the old name and renames the object in AD, which a domain + controller can refuse with "The directory service is busy" while other + servers join, leaving an object under the old name.) A computer already + in the domain under another name is renamed with Rename-Computer and the + join account. The restart is scheduled 15 seconds out so the call + returns first. 2. When the script joined the computer and domain_service_account is set, switch the server's credentials to the service account. 3. Wait for the restart and run VERIFY_SCRIPT until the guest has booted @@ -96,25 +98,21 @@ CHECK_INTERVAL = 30 RESTART_WAIT = 1200 +# CloudBolt's WinRM transport sends a script as powershell -encodedcommand on +# one command line, limited to 8191 characters, so this script must stay under +# about 3,000 characters with its values filled in: keep comments out of it. +# Notes on it: +# - -ne ignores case, so WEB-01 matches web-01. +# - A new computer is renamed locally first and joins with JoinWithNewName, +# so AD creates its object under the new name. Add-Computer -NewName +# would join under the old name and then rename the object in AD. +# - A computer already in the domain under another name is renamed in the +# domain with the join account. JOIN_SCRIPT = r""" $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $WarningPreference = 'SilentlyContinue' function Decode([string]$Value) { [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Value)) } -# A domain controller can refuse a rename for a moment with "The directory -# service is busy" (ERROR_DS_BUSY, 0x200e in NetSetup.log), for example while -# other computers join or restart; retry it with the join account. -function Rename-InDomain { - for ($attempt = 1; ; $attempt++) { - try { - Rename-Computer -NewName $NewName -DomainCredential $credential -Force -WarningAction SilentlyContinue - return - } catch { - if ($attempt -ge 5) { throw } - Start-Sleep -Seconds 15 - } - } -} try { $Domain = Decode '__CB_DOMAIN__' $User = Decode '__CB_USER__' @@ -122,7 +120,6 @@ $NewName = Decode '__CB_NAME__' $cs = Get-CimInstance -ClassName Win32_ComputerSystem $boot = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().Ticks - # -ne ignores case, so WEB-01 matches web-01. $rename = $cs.Name -ne $NewName Write-Output "CB_AD_COMPUTER_NAME=$($cs.Name)" Write-Output "CB_AD_BOOT_TICKS=$boot" @@ -137,9 +134,8 @@ Write-Output "CB_AD_RESULT=ALREADY_JOINED" exit 0 } - # Joined under another name: rename it in the domain with the join account. try { - Rename-InDomain + Rename-Computer -NewName $NewName -DomainCredential $credential -Force } catch { Write-Output "ERROR: Rename-Computer to $NewName failed: $($_.Exception.Message)" exit 10 @@ -152,30 +148,22 @@ Write-Output "ERROR: _ldap._tcp.dc._msdcs.$Domain does not resolve: $($_.Exception.Message)" exit 3 } - $join = @{ DomainName = $Domain; Credential = $credential; Force = $true; WarningAction = 'SilentlyContinue' } + $join = @{ DomainName = $Domain; Credential = $credential; Force = $true; Options = 'AccountCreate' } if ($OUPath) { $join.OUPath = $OUPath } - # -NewName joins under the new name and renames the computer in the same - # restart (Add-Computer sets JoinWithNewName for it). - if ($rename) { $join.NewName = $NewName } - try { - Add-Computer @join - } catch { - $message = $_.Exception.Message -replace '\s+', ' ' - # -NewName joins first and renames second. When only the rename - # failed, the computer is in the domain under its old name: retry - # the rename on its own. - $joined = Get-CimInstance -ClassName Win32_ComputerSystem - if (-not ($rename -and $joined.PartOfDomain -and $joined.Domain -eq $Domain)) { - Write-Output "ERROR: Add-Computer failed: $message" - exit 4 - } - Write-Output "CB_AD_RENAME_RETRIED=$message" + if ($rename) { try { - Rename-InDomain + Rename-Computer -NewName $NewName -Force } catch { - Write-Output "ERROR: joined $Domain as $($cs.Name), but renaming it to $NewName failed: $message Retrying the rename failed too: $($_.Exception.Message)" - exit 10 + Write-Output "ERROR: Rename-Computer to $NewName failed: $($_.Exception.Message)" + exit 11 } + $join.Options = 'AccountCreate', 'JoinWithNewName' + } + try { + Add-Computer @join + } catch { + Write-Output "ERROR: Add-Computer failed: $($_.Exception.Message)" + exit 4 } $result = 'JOINED' } @@ -234,7 +222,8 @@ 7: "The computer is already in a different domain; this action does not move computers between domains.", 10: "The computer is in the domain under another name and could not be renamed. The join account needs " "rights to rename computer objects in its OU (write the computer's name, DNS host name, and service " - "principal names). 'The directory service is busy' means a domain controller refused every retry.", + "principal names).", + 11: "The guest could not be renamed to its CloudBolt hostname before the join.", } # What Windows accepts as a computer name that keeps its full NetBIOS name: @@ -451,11 +440,7 @@ def _join_server(server): if result == "ALREADY_JOINED": set_progress("%s: already in domain %s as %s." % (hostname, domain, name)) else: - retried = markers.get("CB_AD_RENAME_RETRIED") - if retried: - set_progress("%s: joined %s as %s, but the rename to %s failed (%s); retried it on its own." % ( - hostname, domain, old_name, name, retried)) - renamed = " (renamed from %s)" % old_name if old_name and old_name.lower() != name.lower() else "" + renamed =" (renamed from %s)" % old_name if old_name and old_name.lower() != name.lower() else "" done = "renamed in" if result == "RENAMED" else "joined" set_progress("%s: %s %s as %s%s, waiting for the restart." % (hostname, done, domain, name, renamed)) if result == "JOINED" and account is not None: From 994824a37295905350bdb86f51d216a6af5861a5 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:24:03 -0500 Subject: [PATCH 05/22] Upload long lab scripts in pieces instead of one WinRM command line CloudBolt's WinRM transport runs a script as powershell -encodedcommand on one command line, which Windows caps at 8191 characters (about 3,000 characters of script). Prepare SCVMM Lab on AWS failed in testing with "The command line is too long" when it started its first scheduled task, and every later step's task would too. A script over 2,800 characters is now gzipped, written to the lab folder in base64 pieces of at most 2,400 characters, then read back, deleted and run in the same session, so its output and exit code are unchanged. Tested locally through powershell -EncodedCommand. Co-Authored-By: Claude Opus 5.5 --- .../SHM-dpj24dfj/SHM-dpj24dfj_script.py | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py index 3ca94f00..5cdb8f49 100644 --- a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py +++ b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py @@ -11,7 +11,8 @@ - PowerShell in the guest through Server.execute_script (run_ps). Results come back in CB_LAB_* marker lines and every script exits 0, because CloudBolt's AWS SSM transport reports only the exit code of a failed - script, not its output; + script, not its output. A script too long for WinRM's one command line + is uploaded in pieces and run from the guest (_stage); - long steps, and steps that must run as the domain account, as a one-off scheduled task (run_task) polled every POLL_INTERVAL seconds. No transport holds a session open for an hour, and a step that talks to AD @@ -47,6 +48,7 @@ boto3 EC2 client and waiters: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html """ import base64 +import gzip import re import secrets import time @@ -193,6 +195,32 @@ "0x80070533": "the domain account is disabled", } +# CloudBolt's WinRM transport runs a script as powershell -encodedcommand +# (UTF-16 base64) on one command line, which Windows limits to 8191 +# characters: about 3,000 characters of script. A longer script is gzipped +# and written in CHUNK-sized base64 pieces to the lab folder (SYSTEM and +# Administrators only, because a step can hold the domain account's +# password), then STAGE_RUN reads it back, deletes the file and runs it in +# the same session, so its output and exit code are the script's own. +INLINE_LIMIT = 2800 +CHUNK = 2400 +STAGE_CHUNK = r""" +$ErrorActionPreference = 'Stop' +$r = Join-Path $env:ProgramData 'CloudBolt\ScvmmLab' +if (-not (Test-Path -LiteralPath $r)) { + New-Item -ItemType Directory -Path $r -Force | Out-Null + & icacls.exe $r /inheritance:r /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' | Out-Null +} +[IO.File]::__METHOD__((Join-Path $r '__PATH__'), '__CHUNK__') +""" +STAGE_RUN = r""" +$ErrorActionPreference = 'Stop' +$f = Join-Path $env:ProgramData 'CloudBolt\ScvmmLab\__PATH__' +try { $b = [Convert]::FromBase64String([IO.File]::ReadAllText($f)) } finally { Remove-Item -LiteralPath $f -Force -ErrorAction SilentlyContinue } +$z = New-Object IO.Compression.GZipStream((New-Object IO.MemoryStream(,$b)), [IO.Compression.CompressionMode]::Decompress) +& ([scriptblock]::Create((New-Object IO.StreamReader($z, [Text.Encoding]::UTF8)).ReadToEnd())) +""" + RESTART = r""" Mark 'BOOT' ((Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().Ticks) & shutdown.exe /r /t 15 /d p:4:2 /c 'CloudBolt SCVMM lab: restart to finish installing Windows features.' | Out-Null @@ -328,6 +356,32 @@ def render(body, tokens=None): def _execute(server, script, timeout): """(exit code, output) of a PowerShell script; -1 when CloudBolt could not run it at all.""" + if len(script) > INLINE_LIMIT: + rv, output, script = _stage(server, script) + if rv != 0: + return rv, output + return _run(server, script, timeout) + + +def _stage(server, script): + """ + Upload a script too long for one command line to the guest in pieces. + Returns (exit code, output, bootstrap): bootstrap is a short script that + reads the pieces back, deletes the file and runs the script. + """ + payload = base64.b64encode(gzip.compress(script.encode("utf-8"))).decode("ascii") + path = f"{secrets.token_hex(6)}.b64" + pieces = [payload[i:i + CHUNK] for i in range(0, len(payload), CHUNK)] + for index, piece in enumerate(pieces): + method = "WriteAllText" if index == 0 else "AppendAllText" + rv, output = _run(server, STAGE_CHUNK.replace("__PATH__", path).replace("__METHOD__", method) + .replace("__CHUNK__", piece), 120) + if rv != 0: + return rv, output, "" + return 0, "", STAGE_RUN.replace("__PATH__", path) + + +def _run(server, script, timeout): try: output = server.execute_script( script_contents=script, file_extension="ps1", timeout=timeout, show_streaming_output=False, From 9bed0533c5dd12a94c36c895bee4f414c2b5fcfb Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 14:54:05 -0500 Subject: [PATCH 06/22] Install the hosts' Windows features on every host at once The shared module's run_task started a scheduled task and polled it to the end, so Configure Hyper-V Hosts installed Hyper-V and Failover Clustering one host at a time (about 3.5 minutes each in testing). start_task now starts a task and returns a handle, and wait_tasks polls a set of them together, waits for every one even after a failure, and names every failure. run_task is start_task plus wait_tasks for one task. Co-Authored-By: Claude Opus 5.5 --- plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py | 15 ++- .../SHM-dpj24dfj/SHM-dpj24dfj_script.py | 107 ++++++++++++------ 2 files changed, 82 insertions(+), 40 deletions(-) diff --git a/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py index ca44dbe0..412ee61c 100644 --- a/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py +++ b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py @@ -5,9 +5,9 @@ runs while Install SCVMM (item 4, in parallel) sets up the SCVMM server. Every step is skipped when it is already done, so the item can be re-run. - 1. Per host, as a SYSTEM scheduled task: install the Hyper-V and Failover - Clustering features with their management tools, and start the - Microsoft iSCSI Initiator service. + 1. On every host at once, as a SYSTEM scheduled task: install the Hyper-V + and Failover Clustering features with their management tools, and start + the Microsoft iSCSI Initiator service. 2. Restart the hosts together when a feature asked for it, and wait for them. 3. Per host: check the Hyper-V management service runs, open the firewall @@ -159,11 +159,10 @@ def run(job, resource=None, **kwargs): resource = resource or job.resource_set.first() try: lab = scvmm_lab.Lab(resource) - restart = [] - for host in lab.hosts: - log = scvmm_lab.run_task(host, FEATURES, "install Hyper-V and Failover Clustering", timeout=2700) - if scvmm_lab.markers(log).get("RESTART") == "1": - restart.append(host) + tasks = [scvmm_lab.start_task(host, FEATURES, "install Hyper-V and Failover Clustering") + for host in lab.hosts] + logs = scvmm_lab.wait_tasks(tasks, timeout=2700) + restart = [host for host, log in zip(lab.hosts, logs) if scvmm_lab.markers(log).get("RESTART") == "1"] if restart: scvmm_lab.restart(restart, "finish installing Hyper-V") diff --git a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py index 5cdb8f49..79198a08 100644 --- a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py +++ b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py @@ -14,7 +14,8 @@ script, not its output. A script too long for WinRM's one command line is uploaded in pieces and run from the guest (_stage); - long steps, and steps that must run as the domain account, as a one-off - scheduled task (run_task) polled every POLL_INTERVAL seconds. No + scheduled task polled every POLL_INTERVAL seconds: run_task on one + server, or start_task on each server then wait_tasks for all. No transport holds a session open for an hour, and a step that talks to AD or to other servers signs in with the account's own password, so there is no second hop to lose its credentials on; @@ -444,6 +445,17 @@ def run_task(server, body, label, tokens=None, account=None, timeout=3600, hidde shared module (shared_modules/SHM-v8llc736). temp_dir becomes the task's TMP and TEMP, so large downloads land there. """ + task = start_task(server, body, label, tokens=tokens, account=account, hidden=hidden, temp_dir=temp_dir, + archive_refs=archive_refs, job=job) + return wait_tasks([task], timeout)[0] + + +def start_task(server, body, label, tokens=None, account=None, hidden=(), temp_dir="", archive_refs=None, job=None): + """ + Start body on server as a scheduled task (arguments as for run_task) and + return a handle for wait_tasks. Start one per server, then wait for them + together, so the servers do the step at the same time. + """ hidden = list(hidden) user, password = "", "" if account is not None: @@ -465,39 +477,70 @@ def run_task(server, body, label, tokens=None, account=None, timeout=3600, hidde "TAG": tag, "SCRIPT": step, "USER": user, "PASSWORD": password, "TEMP": temp_dir, }, hidden=hidden) set_progress(f"{server.hostname}: {label} (scheduled task {TASK_PATH}{tag} as {user or 'SYSTEM'})") - deadline = time.time() + timeout - last_tail, not_running = "", 0 - while True: - time.sleep(POLL_INTERVAL) + return {"server": server, "tag": tag, "label": label, "hidden": hidden, + "log": None, "error": None, "tail": "", "not_running": 0} + + +def _poll(task): + """Check one started task once; sets its log when it finished, or its error when it failed.""" + server, tag, label, hidden = task["server"], task["tag"], task["label"], task["hidden"] + try: found, output = run_ps(server, POLL_TASK, tokens={"TAG": tag}, hidden=hidden) - state = found.get("TASK_STATE") - if state == "DONE": - log = "\n".join(line[len("LOG| "):] for line in output.splitlines() if line.startswith("LOG| ")) - log = scrub(log, hidden) - problems = errors(log) - if problems or markers(log).get("STEP") != "OK": - detail = " ".join(problems) or log.strip()[-800:] or f"exit {found.get('TASK_EXIT')}" - raise LabError(f"{server.hostname}: {label} failed: {detail}") - return log - if state == "MISSING": - raise LabError(f"{server.hostname}: the scheduled task for '{label}' disappeared before it finished.") - if state == "NOT_RUNNING": - # Right after Start-ScheduledTask the state can still read Ready. - not_running += 1 - if not_running >= 2: - code = found.get("TASK_RESULT", "") - hint = TASK_RESULT_HINTS.get(code, "see Task Scheduler's history for the task") - raise LabError(f"{server.hostname}: the scheduled task for '{label}' did not run " - f"(result {code}): {hint}.") + except LabError as err: + task["error"] = str(err) + return + state = found.get("TASK_STATE") + if state == "DONE": + log = "\n".join(line[len("LOG| "):] for line in output.splitlines() if line.startswith("LOG| ")) + log = scrub(log, hidden) + problems = errors(log) + if problems or markers(log).get("STEP") != "OK": + detail = " ".join(problems) or log.strip()[-800:] or f"exit {found.get('TASK_EXIT')}" + task["error"] = f"{server.hostname}: {label} failed: {detail}" else: - not_running = 0 - tail = found.get("TASK_TAIL", "") - if tail and tail != last_tail: - set_progress(f"{server.hostname}: {tail}") - last_tail = tail - if time.time() > deadline: - raise LabError(f"{server.hostname}: '{label}' did not finish within {timeout // 60} minutes. " - f"Its scheduled task {TASK_PATH}{tag} is still on the server.") + task["log"] = log + elif state == "MISSING": + task["error"] = f"{server.hostname}: the scheduled task for '{label}' disappeared before it finished." + elif state == "NOT_RUNNING": + # Right after Start-ScheduledTask the state can still read Ready. + task["not_running"] += 1 + if task["not_running"] >= 2: + code = found.get("TASK_RESULT", "") + hint = TASK_RESULT_HINTS.get(code, "see Task Scheduler's history for the task") + task["error"] = (f"{server.hostname}: the scheduled task for '{label}' did not run " + f"(result {code}): {hint}.") + else: + task["not_running"] = 0 + tail = found.get("TASK_TAIL", "") + if tail and tail != task["tail"]: + set_progress(f"{server.hostname}: {tail}") + task["tail"] = tail + + +def wait_tasks(tasks, timeout=3600): + """ + Poll tasks from start_task together every POLL_INTERVAL seconds until each + has finished, and return their logs in the same order. Waits for every + task even after one fails, so none is left running unreported, then raises + LabError naming every failure. + """ + deadline = time.time() + timeout + pending = list(tasks) + while pending: + time.sleep(POLL_INTERVAL) + for task in pending: + _poll(task) + pending = [task for task in pending if task["log"] is None and task["error"] is None] + if pending and time.time() > deadline: + for task in pending: + task["error"] = (f"{task['server'].hostname}: '{task['label']}' did not finish within " + f"{timeout // 60} minutes. Its scheduled task {TASK_PATH}{task['tag']} " + f"is still on the server.") + break + failures = [task["error"] for task in tasks if task["error"]] + if failures: + raise LabError(" ".join(failures)) + return [task["log"] for task in tasks] def restart(servers, reason): From 634fbd9736bf564be76df4dd90aaa30c6847fe98 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 15:11:26 -0500 Subject: [PATCH 07/22] Install SQL Server from the Developer ISO instead of the SSEI bootstrapper In testing the SQL Server 2022 bootstrapper ran for 20 minutes under SYSTEM with no CPU and no files, with or without /IACCEPTSQLSERVERLICENSETERMS. Its download switches are undocumented. Install SCVMM now downloads the Developer ISO from download.microsoft.com with curl.exe, mounts it, copies setup to the lab volume with robocopy and deletes the ISO. Done by hand on the stuck lab server, it downloaded 1.16 GB in 7 seconds and SQL Server setup started from the copied media. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 2 +- plugins/OHK-8f9o1496/OHK-8f9o1496_script.py | 52 ++++++++++++--------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 5d539a61..3cdc9bfe 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -78,7 +78,7 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster None of this has run on a live appliance yet: - **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not move with the core group, keep only the first host's address and pin the group to that host. - **Nested virtualization request without CPU counts.** The plug-in sends `NestedVirtualization` without `CoreCount`/`ThreadsPerCore` (all optional in the API) and retries with them on `MissingParameter`. A dry run from the appliance succeeded with the counts. -- **SQL Server media download.** It uses the installer's own `/Action=Download /MediaType=CAB /Quiet` switches, which Microsoft does not document. +- **SQL Server media download.** The ISO URL in Install SCVMM (`SQL_ISO_URL`) is Microsoft's file, but no Microsoft page documents it, so it can move. - **SQL Server edition.** SCVMM 2025 lists Standard, Enterprise and Datacenter. Developer is the Enterprise engine, for test use only. - **SCVMM settings.** `SqlInstanceName=MSSQLSERVER` for the default instance, and no DKM settings with a Local System service. - **SCSI-3 persistent reservations** on the iSCSI target are not validated: `Test-Cluster` is not run. Run cluster validation in Failover Cluster Manager for a supported configuration. diff --git a/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py b/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py index 9a279ebe..d7b97176 100644 --- a/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py +++ b/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py @@ -10,10 +10,12 @@ has room, and restart the server first if Windows has a restart pending (SQL Server setup refuses to run then). 2. SQL Server 2022 Developer, default instance, Database Engine only, as a - SYSTEM scheduled task. The installer bootstrapper (SSEI) downloads the - media from Microsoft. Its /Action=Download, /MediaPath, /MediaType and - /Quiet switches are not documented; they are the ones the bootstrapper - itself lists. The domain service account and BUILTIN\\Administrators + SYSTEM scheduled task. It downloads the Developer ISO (SQL_ISO_URL, the + file Microsoft's installer offers under Download Media), mounts it and + copies setup to the lab volume. Microsoft's installer bootstrapper + (SSEI) is not used: its download switches are undocumented and it hung + with no output under SYSTEM in testing. If Microsoft moves the ISO, + update SQL_ISO_URL. The domain service account and BUILTIN\\Administrators become sysadmins, because SCVMM setup runs as that account and needs sysadmin. The services keep setup's default virtual accounts. SCVMM 2025 lists Standard, Enterprise and Datacenter editions; Developer is the @@ -40,6 +42,7 @@ SQL Server from the command prompt: https://learn.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-ver16 SQL Server service accounts: https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-windows-service-accounts-and-permissions?view=sql-server-ver16 SQL Server 2022 downloads: https://www.microsoft.com/en-us/sql-server/sql-server-downloads + Mount-DiskImage: https://learn.microsoft.com/en-us/powershell/module/storage/mount-diskimage Windows ADK downloads: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install ADK silent install: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-offline-install ADK command-line options: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/dn621910(v=win.10) @@ -53,7 +56,9 @@ from shared_modules import scvmm_lab from shared_modules.scvmm_lab import LabError -SQL_SSEI_URL = "https://go.microsoft.com/fwlink/p/?linkid=2215158" +# The SQL Server 2022 Developer ISO on Microsoft's download server (checked 2026-11-02: 1,163,053,056 bytes). +SQL_ISO_URL = ("https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/" + "SQLServer2022-x64-ENU-Dev.iso") ADK_URL = "https://go.microsoft.com/fwlink/?linkid=2289980" WINPE_URL = "https://go.microsoft.com/fwlink/?linkid=2289981" MIN_FREE_C_GB = 25 @@ -81,24 +86,27 @@ # SQL Server setup takes DOMAIN\user; resolve a UPN through its SID. $account = (New-Object Security.Principal.NTAccount (Decode '__CB_SYSADMIN__')).Translate([Security.Principal.SecurityIdentifier]).Translate([Security.Principal.NTAccount]).Value $media = Join-Path $root 'Media\SQL' - New-Item -ItemType Directory -Force -Path $media | Out-Null - $ssei = Join-Path $media 'SQL2022-SSEI-Dev.exe' - if (-not (Test-Path -LiteralPath $ssei)) { - Log 'Downloading the SQL Server 2022 Developer installer' - Invoke-WebRequest -Uri (Decode '__CB_SSEI_URL__') -OutFile $ssei -UseBasicParsing - } - $box = Get-ChildItem -LiteralPath $media -Filter 'SQLServer2022-DEV-x64-*.exe' | Select-Object -First 1 - if (-not $box) { - Log 'Downloading the SQL Server 2022 Developer media (CAB)' - $p = Start-Process -FilePath $ssei -ArgumentList '/Action=Download', "/MediaPath=`"$media`"", '/MediaType=CAB', '/Quiet' -Wait -PassThru - $box = Get-ChildItem -LiteralPath $media -Filter 'SQLServer2022-DEV-x64-*.exe' | Select-Object -First 1 - if (-not $box) { throw "The SQL Server installer did not download the media (exit code $($p.ExitCode)); the server needs internet access to download.microsoft.com." } - } $setupDir = Join-Path $media 'setup' if (-not (Test-Path -LiteralPath (Join-Path $setupDir 'setup.exe'))) { - Log 'Extracting the SQL Server media' - $p = Start-Process -FilePath $box.FullName -ArgumentList '/q', "/x:`"$setupDir`"" -Wait -PassThru - if (-not (Test-Path -LiteralPath (Join-Path $setupDir 'setup.exe'))) { throw "Extracting $($box.Name) failed (exit code $($p.ExitCode))." } + New-Item -ItemType Directory -Force -Path $media | Out-Null + $iso = Join-Path $media 'SQLServer2022-x64-ENU-Dev.iso' + if (-not (Test-Path -LiteralPath $iso)) { + Log 'Downloading the SQL Server 2022 Developer ISO' + & curl.exe -sSL --fail -o $iso (Decode '__CB_SQL_ISO_URL__') + if ($LASTEXITCODE) { + Remove-Item -LiteralPath $iso -Force -ErrorAction SilentlyContinue + throw "Downloading the SQL Server ISO failed (curl exit $LASTEXITCODE); the server needs internet access to download.microsoft.com." + } + } + Log 'Copying the SQL Server media from the ISO' + $image = Mount-DiskImage -ImagePath $iso -PassThru + try { + & robocopy.exe ('{0}:\' -f ($image | Get-Volume).DriveLetter) $setupDir /E /NFL /NDL /NJH /NJS /NP | Out-Null + if ($LASTEXITCODE -ge 8) { throw "Copying the SQL Server media failed (robocopy exit $LASTEXITCODE)." } + } finally { + Dismount-DiskImage -ImagePath $iso | Out-Null + } + Remove-Item -LiteralPath $iso -Force } Log "Installing SQL Server 2022 Developer (MSSQLSERVER) with sysadmins $account and BUILTIN\Administrators" $arguments = @('/Q', '/ACTION=Install', '/FEATURES=SQLENGINE', '/INSTANCENAME=MSSQLSERVER', @@ -214,7 +222,7 @@ def run(job, resource=None, **kwargs): set_progress(f"{vmm.hostname}: SQL Server is already installed") else: scvmm_lab.run_task(vmm, INSTALL_SQL, "install SQL Server 2022 Developer", tokens=dict( - tokens, SYSADMIN=lab.username, SSEI_URL=SQL_SSEI_URL), timeout=3600, temp_dir=temp) + tokens, SYSADMIN=lab.username, SQL_ISO_URL=SQL_ISO_URL), timeout=3600, temp_dir=temp) if state["ADK"] == "1" and state["WINPE"] == "1": set_progress(f"{vmm.hostname}: the Windows ADK and WinPE add-on are already installed") else: From 6f65b755e84191572577acf09c7f8411838701f6 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 15:37:05 -0500 Subject: [PATCH 08/22] Download the SCVMM media from Microsoft by default The Evaluation Center's SCVMM 2025 link (go.microsoft.com/fwlink/?linkid=2292412) redirects to download.microsoft.com/.../SCVMM_2025.zip with no registration, so the lab no longer needs a 1 GB upload to File Archives. scvmm_media now holds that link by default; Install SCVMM downloads it with Windows' curl.exe and extracts it with its tar.exe. A File Archives reference still works, for labs without internet access. Install SCVMM also calls curl.exe and tar.exe by their System32 paths and creates the media folder if it is missing. Co-Authored-By: Claude Opus 5.5 --- .../BP-9zp8udce/BP-9zp8udce_metadata.json | 4 +- blueprints/BP-9zp8udce/README.md | 20 +++---- plugins/OHK-8f9o1496/OHK-8f9o1496_script.py | 58 ++++++++++++++----- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json index e7012bbf..7aeadfc7 100644 --- a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json +++ b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json @@ -147,7 +147,7 @@ "allow_multiple": false, "available_all_servers": false, "constraints": "Unconstrained", - "description": "File Archives reference (archive/file[@version]) of the zipped SCVMM 2025 setup folder, pinned as this parameter's only option.", + "description": "Where the SCVMM 2025 setup zip comes from: Microsoft's Evaluation Center link by default, or a File Archives reference (archive/file[@version]) for servers without internet access, pinned as this parameter's only option.", "destination": "Resource", "field_dependency_controlling_set": [], "field_dependency_dependent_set": [], @@ -156,7 +156,7 @@ "label": "SCVMM Setup Media", "name": "scvmm_media", "options": [ - "scvmm/SCVMM_2025.zip" + "https://go.microsoft.com/fwlink/?linkid=2292412" ], "placeholder": null, "relevant_osfamilies": [], diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 3cdc9bfe..5dc80a6b 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -21,7 +21,7 @@ Every server joins an existing Active Directory domain. The build runs unattende | Shared module | SHM-dpj24dfj | `scvmm_lab`: guest scripts, scheduled-task steps, EC2 calls | Blueprint parameters, each pinned as its only option, so the order form hides them: -- `scvmm_media`: the File Archives file holding the SCVMM media (default `scvmm/SCVMM_2025.zip`). +- `scvmm_media`: where `SCVMM_2025.zip` comes from. The default is the Evaluation Center's link, `https://go.microsoft.com/fwlink/?linkid=2292412`, which downloads without registration. For a lab without internet access, set it to a File Archives reference instead, such as `scvmm/SCVMM_2025.zip`. - `scvmm_lab_storage_gb`: size of the lab volume (default 250). ## What gets built @@ -41,10 +41,10 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - is a member of the local Administrators group on the lab servers, for example through a Group Policy linked to their OU; - has **Create Computer objects** on that OU, for the cluster's computer object. - **Teardown rights.** The LDAP Utility's account must be able to delete computer objects in that OU. -- **Runbooks package.** [PKG-v20qv308](../../packages/PKG-v20qv308/) provides the File Archives tab and the `file_archives` shared module. +- **Runbooks package.** [PKG-v20qv308](../../packages/PKG-v20qv308/) provides the `file_archives` shared module that Install SCVMM imports. File Archives itself is needed only when `scvmm_media` names a File Archives file. - **AWS environment.** Windows Server 2025 instances CloudBolt can run scripts on, through SSM (with an instance profile allowing `AmazonSSMManagedInstanceCore`) or through WinRM. - **Security group:** allow all traffic between its own members (a rule whose source is the group itself). - - **Internet access** from the SCVMM server, to download SQL Server and the ADK from Microsoft. + - **Internet access** from the SCVMM server, to download SQL Server, the ADK and the SCVMM media from Microsoft. - **IAM.** The AWS handler's credentials also need: - `ec2:ModifyInstanceCpuOptions`, `ec2:StopInstances`, `ec2:StartInstances`, `ec2:DescribeInstanceTypes` - `ec2:AssignPrivateIpAddresses` @@ -52,18 +52,14 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - `ec2:ModifyVolume`, `ec2:DescribeVolumesModifications` ## Setup -1. Download SCVMM 2025 from the [Evaluation Center](https://www.microsoft.com/en-us/evalcenter/download-system-center-2025). The file is `SCVMM_2025.zip`, about 1 GB. -2. In CloudBolt, go to **Admin > Custom Extensions > Runbooks > File Archives**: - - **Settings:** set **Largest upload** to 1100 MB or more, and set a download base URL the lab's VPC can reach. - - Create archive `scvmm` and upload `SCVMM_2025.zip` unchanged. -3. On the AWS environment's **Parameters** tab: +1. On the AWS environment's **Parameters** tab: - Add instance types that support nested virtualization to **Instance type**, for example `m7i.xlarge`, `m8i.xlarge` or `r7i.xlarge`. Bare metal sizes also work. SCVMM's documented minimum is 8 cores and 16 GB of RAM; `m7i.2xlarge` meets it, and `m7i.xlarge` saves cost in a lab. - Add **Quantity** with minimum 1 and maximum 8. Without it the order form has no host count and an order with more than one host is refused. Adding it to the ordering group instead works too. -4. Sync the blueprint, then open it in **Catalog**: +2. Sync the blueprint, then open it in **Catalog**: - Both tiers have all environments enabled. The tier's OS build limits them to environments that offer it; re-point both tiers to your Windows Server 2025 build (`OSB-bocl2o1o` is instance-specific), or restrict their environments. - - If you uploaded under another name, change the `scvmm_media` option. -5. Grant the groups that may order it. -6. Order it with **Hyper-V Hosts** quantity 2 or more and **SCVMM Server** quantity 1. + - Without internet access from the lab, upload `SCVMM_2025.zip` from the [Evaluation Center](https://www.microsoft.com/en-us/evalcenter/download-system-center-2025) unchanged to File Archives (**Admin > Custom Extensions > Runbooks > File Archives**; raise **Largest upload** to 1100 MB). Then set the `scvmm_media` option to its reference. +3. Grant the groups that may order it. +4. Order it with **Hyper-V Hosts** quantity 2 or more and **SCVMM Server** quantity 1. ## Notes - **Re-running a build item.** Every step is skipped when it is already done. diff --git a/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py b/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py index d7b97176..c93369fc 100644 --- a/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py +++ b/plugins/OHK-8f9o1496/OHK-8f9o1496_script.py @@ -22,18 +22,22 @@ Enterprise engine, licensed for test labs only. 3. Windows ADK Deployment Tools and the WinPE add-on, which SCVMM setup requires, from Microsoft's download links. - 4. The SCVMM 2025 media from File Archives: scvmm_media names the zip - (SCVMM_2025.zip from the Evaluation Center, uploaded unchanged). The - file_archives shared module downloads and checks it on the server; this - moves the extracted folder to the lab volume. + 4. The SCVMM 2025 media, SCVMM_2025.zip from the Evaluation Center. + scvmm_media is either an https link, downloaded with Windows' curl.exe and + extracted with its tar.exe (by default the Evaluation Center's own link, + which redirects to download.microsoft.com with no registration), or a + File Archives reference for servers without internet access, which the + file_archives shared module downloads and checks. The extracted folder + moves to the lab volume. 5. SCVMM setup from the command prompt, as a scheduled task signed in as the domain service account: new database VirtualManagerDB on the local instance, the VMM service as Local System (no distributed key management), the library share on the lab volume, the default ports, no product key (180-day evaluation). -The server downloads SQL Server and the ADK from the internet; with no -internet access, steps 2 and 3 fail with the download error. +The server downloads SQL Server and the ADK from the internet, and the SCVMM +media too unless scvmm_media names a File Archives file; with no internet +access, those steps fail with the download error. CloudBolt renders this file as a template before running it, so it must never contain template tags; values reach the scripts through the __CB_*__ tokens. @@ -92,7 +96,7 @@ $iso = Join-Path $media 'SQLServer2022-x64-ENU-Dev.iso' if (-not (Test-Path -LiteralPath $iso)) { Log 'Downloading the SQL Server 2022 Developer ISO' - & curl.exe -sSL --fail -o $iso (Decode '__CB_SQL_ISO_URL__') + & "$env:SystemRoot\System32\curl.exe" -sSL --fail -o $iso (Decode '__CB_SQL_ISO_URL__') if ($LASTEXITCODE) { Remove-Item -LiteralPath $iso -Force -ErrorAction SilentlyContinue throw "Downloading the SQL Server ISO failed (curl exit $LASTEXITCODE); the server needs internet access to download.microsoft.com." @@ -143,13 +147,30 @@ STAGE_MEDIA = r""" $target = Join-Path (Decode '__CB_ROOT__') 'Media\VMM' - $setup = Get-ChildItem -LiteralPath $env:CB_ARCHIVE_DIR -Filter setup.exe -Recurse -Depth 2 | + $url = Decode '__CB_URL__' + if ($url) { + $from = Join-Path (Decode '__CB_ROOT__') 'Temp\scvmm-media' + if (Test-Path -LiteralPath $from) { Remove-Item -LiteralPath $from -Recurse -Force } + New-Item -ItemType Directory -Force -Path $from | Out-Null + $zip = Join-Path $from 'SCVMM_2025.zip' + Log "Downloading the SCVMM media from $url" + & "$env:SystemRoot\System32\curl.exe" -sSL --fail -o $zip $url + if ($LASTEXITCODE) { throw "Downloading the SCVMM media failed (curl exit $LASTEXITCODE); the server needs internet access to download.microsoft.com." } + Log 'Extracting the SCVMM media' + & "$env:SystemRoot\System32\tar.exe" -xf $zip -C $from + if ($LASTEXITCODE) { throw "Extracting the SCVMM media failed (tar exit $LASTEXITCODE)." } + } else { + $from = $env:CB_ARCHIVE_DIR + } + $setup = Get-ChildItem -LiteralPath $from -Filter setup.exe -Recurse -Depth 2 | Sort-Object { $_.FullName.Length } | Select-Object -First 1 - if (-not $setup) { throw 'The archive has no setup.exe. Upload SCVMM_2025.zip from the Evaluation Center unchanged.' } - Get-ChildItem -LiteralPath $env:CB_ARCHIVE_DIR -Filter *.zip | Remove-Item -Force + if (-not $setup) { throw 'The SCVMM media has no setup.exe. Use SCVMM_2025.zip from the Evaluation Center unchanged.' } + Get-ChildItem -LiteralPath $from -Filter *.zip | Remove-Item -Force Set-Location -LiteralPath $env:SystemDrive\ if (Test-Path -LiteralPath $target) { Remove-Item -LiteralPath $target -Recurse -Force } + New-Item -ItemType Directory -Force -Path (Split-Path -Parent $target) | Out-Null Move-Item -LiteralPath $setup.Directory.FullName -Destination $target + if ($url -and (Test-Path -LiteralPath $from)) { Remove-Item -LiteralPath $from -Recurse -Force } Log "SCVMM media is in $target" """ @@ -202,10 +223,10 @@ def run(job, resource=None, **kwargs): try: lab = scvmm_lab.Lab(resource) vmm = lab.vmm - media_ref = str(resource.get_value_for_custom_field("scvmm_media") or "").strip() - if not media_ref: - raise LabError("scvmm_media is empty. Pin the File Archives reference of SCVMM_2025.zip " - "(for example scvmm/SCVMM_2025.zip) as the blueprint parameter's only option.") + media = str(resource.get_value_for_custom_field("scvmm_media") or "").strip() + if not media: + raise LabError("scvmm_media is empty. Pin Microsoft's SCVMM_2025.zip link, or a File Archives " + "reference such as scvmm/SCVMM_2025.zip, as the blueprint parameter's only option.") state, _ = scvmm_lab.run_ps(vmm, STATE, tokens={"LABEL": scvmm_lab.STORAGE_LABEL}) if state["RESTART_PENDING"] == "1" and state["VMM"] == "0": scvmm_lab.restart([vmm], "clear a pending restart before SQL Server setup") @@ -229,8 +250,13 @@ def run(job, resource=None, **kwargs): scvmm_lab.run_task(vmm, INSTALL_ADK, "install the Windows ADK and WinPE add-on", tokens=dict( tokens, ADK_URL=ADK_URL, WINPE_URL=WINPE_URL), timeout=3600, temp_dir=temp) if state["MEDIA"] == "0": - scvmm_lab.run_task(vmm, STAGE_MEDIA, f"download {media_ref} from File Archives", tokens=tokens, - timeout=3600, temp_dir=temp, archive_refs=[f"{media_ref} extract"], job=job) + if media.lower().startswith("https://"): + scvmm_lab.run_task(vmm, STAGE_MEDIA, "download the SCVMM media from Microsoft", + tokens=dict(tokens, URL=media), timeout=3600, temp_dir=temp) + else: + scvmm_lab.run_task(vmm, STAGE_MEDIA, f"download {media} from File Archives", + tokens=dict(tokens, URL=""), timeout=3600, temp_dir=temp, + archive_refs=[f"{media} extract"], job=job) scvmm_lab.run_task(vmm, INSTALL_VMM, "install SCVMM", tokens=tokens, account=lab.account, timeout=3600, temp_dir=temp) except LabError as err: From 30803d0682ba33093685363af1864ede46feda85 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:25:12 -0500 Subject: [PATCH 09/22] Delete a server's DNS records with its computer object, and check lab DNS before clustering Lab-6's Create Hyper-V Cluster failed because hvlab-002's name still resolved to the deleted lab-1 server's address: AD-integrated zones let only a record's owner update it, so the new server could not replace it. - Delete Windows Computer Object from AD (HPA-q181uofy / OHK-bkoau0j8) now also tombstones the DNS nodes the computer object owns: its host name and the PTR node of each of that name's addresses, in any AD-integrated partition. Nodes another account owns are left alone. Tombstoning follows MS-DNSP (dNSTombstoned TRUE, one DNS_TYPE_ZERO record with EntombedTime), the way the DNS server deletes a node. - ad_domain (SHM-gcba1u31): dns_bases, find_dns_nodes, dns_records, a_addresses, owner_sid (SD flags control, owner only), tombstone_dns_node; computer results carry objectSid. - scvmm_lab.check_dns: from the first host, every lab server's name must resolve to its primary private IP and nothing outside its instance; a wrong name is asked to Register-DnsClient once and rechecked for up to 3 minutes, then the error names each wrong record. Prepare and Create Hyper-V Cluster run it. - Configure Hyper-V Hosts stops the NAT switch's gateway address, the same on every host, from registering in DNS. - PKG-nf407lm5 1.2.0. Co-Authored-By: Claude Opus 5.5 --- CATALOG.md | 8 +- blueprints/BP-9zp8udce/README.md | 15 +- catalog.json | 10 +- .../HPA-q181uofy/HPA-q181uofy_metadata.json | 2 +- orchestration_actions/HPA-q181uofy/README.md | 6 +- orchestration_actions/README.md | 2 +- .../PKG-nf407lm5/PKG-nf407lm5_metadata.json | 6 +- packages/PKG-nf407lm5/README.md | 4 +- packages/README.md | 2 +- plugins/OHK-77f19kly/OHK-77f19kly_script.py | 3 + plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py | 3 + .../OHK-bkoau0j8/OHK-bkoau0j8_metadata.json | 2 +- plugins/OHK-bkoau0j8/OHK-bkoau0j8_script.py | 56 +++++++- plugins/OHK-q6fb9833/OHK-q6fb9833_script.py | 6 +- plugins/README.md | 2 +- shared_modules/README.md | 2 +- .../SHM-dpj24dfj/SHM-dpj24dfj_script.py | 64 +++++++++ .../SHM-gcba1u31/SHM-gcba1u31_metadata.json | 2 +- .../SHM-gcba1u31/SHM-gcba1u31_script.py | 135 +++++++++++++++++- 19 files changed, 297 insertions(+), 33 deletions(-) diff --git a/CATALOG.md b/CATALOG.md index cb21ee32..754f6362 100644 --- a/CATALOG.md +++ b/CATALOG.md @@ -37,7 +37,7 @@ Named sets of content that the Content Package Manager extension (`extensions/XU | HCP Terraform | [PKG-0bo7vlxp](packages/PKG-0bo7vlxp/README.md) | Provisions VMs and no-code modules through HCP Terraform in a workspace per deployment, optionally followed by Ansible job templates, with their day-2 actions, the form options webhook, and the UI extension that adds Terraform tabs. | 1.0.0 | [HCP Terraform VM](blueprints/BP-b0qm83lh/README.md) (blueprint), [HCP Terraform No-Code Module](blueprints/BP-00meiwwz/README.md) (blueprint), [HCP Terraform No-Code + Ansible](blueprints/BP-uh9v24v3/README.md) (blueprint), [Form Options](webhooks/IWH-yj93is5z/) (webhook), [HCP Terraform Workspace](extensions/XUI-ax1sluwi/README.md) (UI extension) | | OpenShift | [PKG-57ltvnbl](packages/PKG-57ltvnbl/README.md) | All OpenShift content: the project landing zone blueprint with its day-2 actions, and the Connect and Workloads tabs on each project. | 1.0.0 | [OpenShift Project](extensions/XUI-y9bdnzxt/README.md) (UI extension), [OpenShift Project Landing Zone](blueprints/BP-tikkhf2y/README.md) (blueprint) | | Runbooks | [PKG-v20qv308](packages/PKG-v20qv308/README.md) | Adds Run Task and Run Workflow, actions that run any Remote Script that fits a VM or an ordered workflow of CloudBolt actions on it, with base, example and installer task scripts, the Runbooks page for building workflows, base actions and file archives, example Linux and Windows workflows whose scripts read a config file from File Archives, and Linux and Windows blueprints that run a workflow. | 1.1.0 | [Runbook Task Template (Windows)](plugins/OHK-lhm2916o/) (plugin), [Runbook Task Template (Linux)](plugins/OHK-iub9a2jg/) (plugin), [Manage Windows Service](plugins/OHK-01kmavro/) (plugin), [Manage Linux Service](plugins/OHK-5yh12jiq/) (plugin), [Run Installer from File Archive (Linux)](plugins/OHK-hgv6wp65/) (plugin), [Run Installer from File Archive (Windows)](plugins/OHK-ow68kerl/) (plugin), [Runbook Tasks](webhooks/IWH-cdf543g3/) (webhook), [Runbook Workflows](webhooks/IWH-xjlrmvc8/) (webhook), [Run Task](server_actions/SVA-4sin3s0q/README.md) (server action), [Run Workflow](server_actions/SVA-j7rbsh39/README.md) (server action), [Runbooks](extensions/XUI-jbm5ac9e/README.md) (UI extension), [Linux VM with Workflow](blueprints/BP-vy9ytey6/README.md) (blueprint), [Windows VM with Workflow](blueprints/BP-6ddlyguv/README.md) (blueprint), [Prepare Linux app host](runbook_workflows/SWF-69r5mmdb/README.md) (Runbooks workflow), [Prepare Windows app host](runbook_workflows/SWF-7s01lyyk/README.md) (Runbooks workflow) | -| Windows AD Domain Join | [PKG-nf407lm5](packages/PKG-nf407lm5/README.md) | Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object at decommission. | 1.1.0 | [Delete Windows Computer Object from AD](orchestration_actions/HPA-q181uofy/README.md) (orchestration action), [Join Windows Server to AD Domain](orchestration_actions/HPA-jjp1vlfi/README.md) (orchestration action), [Suggest Domain OUs](orchestration_actions/HPA-0zcrvpwu/README.md) (orchestration action), [Generate Options for Domain Service Account](orchestration_actions/HPA-g8pqv6uv/README.md) (orchestration action), [Domain OU](parameters/CF-8pif9mbf/README.md) (parameter), [Domain Service Account](parameters/CF-yqmreb5m/README.md) (parameter) | +| Windows AD Domain Join | [PKG-nf407lm5](packages/PKG-nf407lm5/README.md) | Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object and its DNS records at decommission. | 1.2.0 | [Delete Windows Computer Object from AD](orchestration_actions/HPA-q181uofy/README.md) (orchestration action), [Join Windows Server to AD Domain](orchestration_actions/HPA-jjp1vlfi/README.md) (orchestration action), [Suggest Domain OUs](orchestration_actions/HPA-0zcrvpwu/README.md) (orchestration action), [Generate Options for Domain Service Account](orchestration_actions/HPA-g8pqv6uv/README.md) (orchestration action), [Domain OU](parameters/CF-8pif9mbf/README.md) (parameter), [Domain Service Account](parameters/CF-yqmreb5m/README.md) (parameter) | ## Blueprints @@ -179,7 +179,7 @@ Lifecycle hooks. Actions marked disabled ship that way on purpose; read the READ | Azure Resource Manager Rate Hook | [HPA-t7hlyvyy](orchestration_actions/HPA-t7hlyvyy/README.md) | Computes Azure server rates from negotiated Price Sheet prices, falling back to public retail prices. | Compute Server Rate | yes | [Azure Resource Manager Rate Hook](plugins/OHK-vg0rmi7i/) | | Configure Data Disks from Disk Map (Oracle Linux) | [HPA-4ptcwgg4](orchestration_actions/HPA-4ptcwgg4/README.md) | At Post-Provision, turns the disks from each Oracle Linux server's disk_map into LVM volumes with XFS file systems mounted at their mount points inside the guest. | Post-Provision | yes | [Configure Data Disks from Disk Map (Oracle Linux)](plugins/OHK-9h9vphf5/) | | Configure Data Disks from Disk Map (Windows) | [HPA-42uy9dyo](orchestration_actions/HPA-42uy9dyo/README.md) | At Post-Provision, formats the disks from each Windows server's disk_map inside the guest with their drive letters and NTFS labels. | Post-Provision | yes | [Configure Data Disks from Disk Map (Windows)](plugins/OHK-pdwb3xso/) | -| Delete Windows Computer Object from AD | [HPA-q181uofy](orchestration_actions/HPA-q181uofy/README.md) | Deletes the Active Directory computer object of each Windows server being deleted at Pre-Delete. | Pre-Delete | yes | [Delete Windows Computer Object from AD](plugins/OHK-bkoau0j8/) | +| Delete Windows Computer Object from AD | [HPA-q181uofy](orchestration_actions/HPA-q181uofy/README.md) | Deletes the Active Directory computer object and the DNS records of each Windows server being deleted at Pre-Delete. | Pre-Delete | yes | [Delete Windows Computer Object from AD](plugins/OHK-bkoau0j8/) | | Generate options for 'Expiration Date' | [HPA-qb0w86mi](orchestration_actions/HPA-qb0w86mi/README.md) | Pre-fills the Expiration Date order-form parameter with a default of seven days from now. | Generated Parameter Options | yes | [Generate options for 'Expiration Date'](plugins/OHK-cfciy0fo/) | | Generate options for Ansible job template maps | [HPA-aualk6ei](orchestration_actions/HPA-aualk6ei/) | Lists the Variable Maps that are Ansible job template maps so an admin pins a blueprint's ansible_job_template_maps parameter from a dropdown. | Generated Parameter Options | yes | [Generate options for Ansible job template maps](plugins/OHK-7i1fk0l5/) | | Generate Options for Domain Service Account | [HPA-g8pqv6uv](orchestration_actions/HPA-g8pqv6uv/README.md) | Lists every connection info labeled domain_service_account as the choices for the domain_service_account parameter. | Generated Parameter Options | yes | [Generate Options for Domain Service Account](plugins/OHK-ww524a3e/) | @@ -305,7 +305,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Delete Blob Container | [OHK-y1120h61](plugins/OHK-y1120h61/) | Deletes a blob container from the resource's Azure storage account. | CloudBolt Plug-in | [Delete Blob Container](resource_actions/RSA-zmi15uts/) | | Delete Cluster | [OHK-pgbigmd9](plugins/OHK-pgbigmd9/) | Deletes the EKS cluster's node groups, the cluster, its IAM cluster role, the CloudBolt container orchestrator, and the node group sub-resources, refusing while namespace landing zones remain on the cluster. | CloudBolt Plug-in | [AWS EKS](blueprints/BP-r5apcf7e/README.md) | | Delete GKE Node Pool | [OHK-qxdrryt6](plugins/OHK-qxdrryt6/) | Deletes a node pool from the GKE cluster, refusing its last one, and removes the pool's sub-resource. | CloudBolt Plug-in | [Delete GKE Node Pool](resource_actions/RSA-kfd31bur/) | -| Delete Windows Computer Object from AD | [OHK-bkoau0j8](plugins/OHK-bkoau0j8/) | Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server. | CloudBolt Plug-in | [Delete Windows Computer Object from AD](orchestration_actions/HPA-q181uofy/README.md) | +| Delete Windows Computer Object from AD | [OHK-bkoau0j8](plugins/OHK-bkoau0j8/) | Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server, and tombstones the DNS records that computer object owns. | CloudBolt Plug-in | [Delete Windows Computer Object from AD](orchestration_actions/HPA-q181uofy/README.md) | | Deploy AWS App Migration Agent | [OHK-5wpzgw68](plugins/OHK-5wpzgw68/) | Installs the AWS Application Migration Service replication agent on a Linux server. | CloudBolt Plug-in | [Deploy AWS App Migration Agent](server_actions/SVA-mwbtjfr0/README.md) | | Deploy Bicep Template | [OHK-gqvi9kv4](plugins/OHK-gqvi9kv4/) | Deploys an Azure deployment stack from a GitHub-hosted Bicep template after a what-if preview and approval. | CloudBolt Plug-in | [Azure Resource Group - Bicep](blueprints/BP-p7zmh96m/README.md), [Bicep Deployment](blueprints/BP-nibk4erf/README.md) | | Deploy EKS Cluster | [OHK-u4k6dg46](plugins/OHK-u4k6dg46/) | Creates an Amazon EKS cluster and its IAM cluster role in the chosen AWS environment, registers it as a CloudBolt Kubernetes container orchestrator, and stores the cluster details on the resource. | CloudBolt Plug-in | [AWS EKS](blueprints/BP-r5apcf7e/README.md) | @@ -449,7 +449,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | Module | ID | Description | Used by | |---|---|---|---| -| `ad_domain` | [SHM-gcba1u31](shared_modules/SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects. | [Delete Windows Computer Object from AD](plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](plugins/OHK-9oqn6pur/), [Remove Hyper-V Cluster Object](plugins/OHK-kzb6pzzu/), [Suggest Domain OUs](plugins/OHK-z9qrccyu/) | +| `ad_domain` | [SHM-gcba1u31](shared_modules/SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, finds and deletes computer objects, and deletes the DNS records a computer registered. | [Delete Windows Computer Object from AD](plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](plugins/OHK-9oqn6pur/), [Remove Hyper-V Cluster Object](plugins/OHK-kzb6pzzu/), [Suggest Domain OUs](plugins/OHK-z9qrccyu/) | | `aks_namespace` | [SHM-cozv547n](shared_modules/SHM-cozv547n/) | Managed-namespace landing zones, Azure RBAC namespace access, connection details, and GitHub pipeline identities for the AKS Namespace blueprint. | [AKS Namespace](plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](plugins/OHK-vi009xb8/), [Create AKS Namespace](plugins/OHK-kb4pv2yq/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover AKS Namespaces](plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](plugins/OHK-t1r0y1yd/), [Manage AKS Namespace Access](plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](plugins/OHK-jeighfcq/), [Teardown AKS Namespace](plugins/OHK-wmdr2ef5/) | | `aria_connection` | [SHM-u2s2d40p](shared_modules/SHM-u2s2d40p/) | Aria Automation 8 and Aria Orchestrator REST clients built on a CloudBolt ConnectionInfo labeled vra8 or aria, with generate-options helpers for connection and project dropdowns. | [Aria Migration Form Options](plugins/OHK-xhpq1rn3/), [Migrate Aria Automation Deployments](plugins/OHK-7sq2hqrb/), [Migrate Aria Automation Projects](plugins/OHK-gyl8wlrq/), [Run Aria Orchestrator Workflow](plugins/OHK-3bgpjmlr/) | | `azure_aks` | [SHM-ptvp0km4](shared_modules/SHM-ptvp0km4/) | ARM client, cluster and node pool operations, orchestrator registration, and role-assignment helpers for Azure Kubernetes Service content. | [Add AKS Node Pool](plugins/OHK-b7poza8x/), [AKS Cluster Build](plugins/OHK-x13tmam0/), [AKS Cluster Discovery](plugins/OHK-uof2rcaa/), [AKS Cluster Teardown](plugins/OHK-27oemiwb/), [AKS Namespace](plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](plugins/OHK-vi009xb8/), [Create AKS Namespace](plugins/OHK-kb4pv2yq/), [Delete AKS Node Pool](plugins/OHK-czexzrl1/), [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover AKS Namespaces](plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](plugins/OHK-t1r0y1yd/), [List AKS Node Pools](plugins/OHK-0fp008gh/), [Manage AKS Cluster Groups](plugins/OHK-yzmq0kzu/), [Manage AKS Namespace Access](plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](plugins/OHK-jeighfcq/), [Scale AKS Node Pool](plugins/OHK-80c4ibdb/), [Teardown AKS Namespace](plugins/OHK-wmdr2ef5/), [Upgrade AKS Node Pool](plugins/OHK-t0j1w09c/), [Upgrade AKS Version](plugins/OHK-ojf2vvq1/) | diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 5dc80a6b..0b87e29f 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -31,7 +31,7 @@ Blueprint parameters, each pinned as its only option, so the order form hides th | Cluster addresses | Each host gets one secondary private IP. The cluster has one IP address resource per host, each owned only by its host, joined by an OR dependency. The cluster name is `hvc-`. | | Shared storage | The SCVMM server gets a gp3 volume (labeled `CBLab`, deleted with the server) and runs the iSCSI Target Server role. The volume holds a 1 GB disk witness and a cluster shared volume of the volume size minus 40 GB, both dynamically expanding. | | SCVMM server | Root volume grown to 80 GB. SQL Server 2022 Developer (default instance), Windows ADK Deployment Tools + WinPE, and SCVMM 2025 evaluation. The VMM service runs as Local System; the library share is on the lab volume. | -| Hosts | Hyper-V and Failover Clustering are installed. An internal switch `CBLab-NAT` with NAT `192.168.250.0/24` (gateway `.1`) is created on every host. | +| Hosts | Hyper-V and Failover Clustering are installed. An internal switch `CBLab-NAT` with NAT `192.168.250.0/24` (gateway `.1`) is created on every host; its address is not registered in DNS. | | SCVMM | Run As account `CloudBolt SCVMM Lab Hosts` for the domain service account; the cluster is added under All Hosts. | Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster_ips`, `scvmm_lab_vmm_server`. @@ -63,18 +63,21 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster ## Notes - **Re-running a build item.** Every step is skipped when it is already done. +- **DNS names.** Prepare and Create Hyper-V Cluster check that every lab server's name resolves to its own address, because the cluster and SCVMM reach the servers by name. The usual cause of a failure is a record left by an earlier server with the same name. The zone lets only a record's owner update it, so the new server cannot replace it. Delete the record named in the error, then re-run the item. HPA-q181uofy deletes the records of the servers it deletes. - **Slow steps** run as scheduled tasks under `\CloudBolt\` and are polled every 30 seconds. Steps that reach AD or other servers sign in as the domain service account, so there is no double hop. Their logs are in the job's progress. - **The service account's password** goes to the guest inside the script body, base64 encoded for quoting only. On AWS that body stays in Systems Manager's command history. - **Scale-up is not supported.** Order a new lab for more hosts. - **Nested VMs** reach the network only through their host's NAT (`192.168.250.0/24`), because EC2 drops frames from unknown MAC addresses. They are not reachable from the VPC. - **SCVMM has no templates, logical networks or IP pools yet.** Add them in the console. -- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item deletes the cluster's computer object. The servers' own computer objects are deleted only by HPA-q181uofy, when it is installed. +- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item deletes the cluster's computer object. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. -### Untested -None of this has run on a live appliance yet: +### Not yet run live +Domain join through Install SCVMM has run on a live appliance. These have not: +- **Create Hyper-V Cluster and Add Hyper-V Cluster to SCVMM.** - **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not move with the core group, keep only the first host's address and pin the group to that host. -- **Nested virtualization request without CPU counts.** The plug-in sends `NestedVirtualization` without `CoreCount`/`ThreadsPerCore` (all optional in the API) and retries with them on `MissingParameter`. A dry run from the appliance succeeded with the counts. +- **Deleting the cluster's computer object** at teardown, for a lab whose cluster was created. + +### Caveats - **SQL Server media download.** The ISO URL in Install SCVMM (`SQL_ISO_URL`) is Microsoft's file, but no Microsoft page documents it, so it can move. - **SQL Server edition.** SCVMM 2025 lists Standard, Enterprise and Datacenter. Developer is the Enterprise engine, for test use only. -- **SCVMM settings.** `SqlInstanceName=MSSQLSERVER` for the default instance, and no DKM settings with a Local System service. - **SCSI-3 persistent reservations** on the iSCSI target are not validated: `Test-Cluster` is not run. Run cluster validation in Failover Cluster Manager for a supported configuration. diff --git a/catalog.json b/catalog.json index dc559d3f..11bebb85 100644 --- a/catalog.json +++ b/catalog.json @@ -1475,7 +1475,7 @@ "id": "HPA-q181uofy", "type": "orchestration_actions", "name": "Delete Windows Computer Object from AD", - "description": "Deletes the Active Directory computer object of each Windows server being deleted at Pre-Delete.", + "description": "Deletes the Active Directory computer object and the DNS records of each Windows server being deleted at Pre-Delete.", "path": "orchestration_actions/HPA-q181uofy", "readme": "orchestration_actions/HPA-q181uofy/README.md", "uses": [ @@ -1660,12 +1660,12 @@ "id": "PKG-nf407lm5", "type": "packages", "name": "Windows AD Domain Join", - "description": "Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object at decommission.", + "description": "Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object and its DNS records at decommission.", "path": "packages/PKG-nf407lm5", "readme": "packages/PKG-nf407lm5/README.md", "uses": [], "used_by": [], - "version": "1.1.0", + "version": "1.2.0", "contents": [ "orchestration_actions/HPA-q181uofy", "orchestration_actions/HPA-jjp1vlfi", @@ -2916,7 +2916,7 @@ "id": "OHK-bkoau0j8", "type": "plugins", "name": "Delete Windows Computer Object from AD", - "description": "Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server.", + "description": "Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server, and tombstones the DNS records that computer object owns.", "path": "plugins/OHK-bkoau0j8", "readme": null, "uses": [ @@ -6105,7 +6105,7 @@ "id": "SHM-gcba1u31", "type": "shared_modules", "name": "ad_domain", - "description": "Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects.", + "description": "Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, finds and deletes computer objects, and deletes the DNS records a computer registered.", "path": "shared_modules/SHM-gcba1u31", "readme": null, "uses": [], diff --git a/orchestration_actions/HPA-q181uofy/HPA-q181uofy_metadata.json b/orchestration_actions/HPA-q181uofy/HPA-q181uofy_metadata.json index 6c790531..a2b51ccb 100644 --- a/orchestration_actions/HPA-q181uofy/HPA-q181uofy_metadata.json +++ b/orchestration_actions/HPA-q181uofy/HPA-q181uofy_metadata.json @@ -4,7 +4,7 @@ "dependencies": { "hook": "plugins/OHK-bkoau0j8" }, - "description": "Deletes the Active Directory computer object of each Windows server being deleted at Pre-Delete.", + "description": "Deletes the Active Directory computer object and the DNS records of each Windows server being deleted at Pre-Delete.", "enabled": true, "hook_point": "Pre-Delete", "id": "HPA-q181uofy", diff --git a/orchestration_actions/HPA-q181uofy/README.md b/orchestration_actions/HPA-q181uofy/README.md index 23fd3a4f..f31d0a19 100644 --- a/orchestration_actions/HPA-q181uofy/README.md +++ b/orchestration_actions/HPA-q181uofy/README.md @@ -2,6 +2,8 @@ Pre-Delete orchestration action that deletes each Windows server's Active Directory computer object over LDAP, bound as the LDAP Utility for its domain (taken from the recorded object DN, `domain_ou`, or `domain_to_join`, so servers CloudBolt's guest customization joined are covered too). It deletes the object whose GUID [Join Windows Server to AD Domain](../HPA-jjp1vlfi/) recorded. Without a GUID it deletes the object named after the computer, but only when exactly one matches and AD created it after CloudBolt added the server. Child objects, such as BitLocker recovery information, are deleted with it. The guest is not contacted. +It also deletes the DNS records the server registered in AD-integrated zones: its host name and the reverse (PTR) record of each of that name's addresses. A record is deleted only when the computer object owns it, as with every record a server registers through secure dynamic update. Records an administrator created are left alone. Without this, the zone keeps the record. Only its owner can update it, so the next server with the same name cannot register its own. Records are marked deleted the way the DNS server marks them, and DNS servers stop answering for the name at their next directory poll (3 minutes by default). + | Role | ID | Name | |---|---|---| | Orchestration action | HPA-q181uofy | Delete Windows Computer Object from AD (Pre-Delete) | @@ -12,9 +14,11 @@ Part of [PKG-nf407lm5](../../packages/PKG-nf407lm5/). ## Prerequisites - The LDAP Utility's account needs Delete Computer objects on the OUs, plus Delete subtree for objects with children. +- For DNS records, it needs Write on the records in the DNS zones. Members of DnsAdmins and Domain Admins have that by default. Without it the computer object is still deleted and the job reports the DNS failure. - The appliance must reach a domain controller on the utility's port. ## Notes - Imports with `continue_on_failure: true`: an AD error shows in the job without stopping the server's deletion. -- The A record the server registered in AD DNS is not deleted with the computer object. DNS scavenging removes it once it ages out, if scavenging is on for the zone. +- DNS records are found only from a computer object it deletes. A server whose object is already gone keeps its records. +- **Untested live:** the DNS record deletion has run only against a simulated directory, not against a domain controller. - CloudBolt's out-of-the-box "Delete Server from LDAP" action matches on name only. Leave it disabled when this action is enabled. diff --git a/orchestration_actions/README.md b/orchestration_actions/README.md index 2a809f9c..a7732bb0 100644 --- a/orchestration_actions/README.md +++ b/orchestration_actions/README.md @@ -15,7 +15,7 @@ Lifecycle hooks. Actions marked disabled ship that way on purpose; read the READ | Azure Resource Manager Rate Hook | [HPA-t7hlyvyy](HPA-t7hlyvyy/README.md) | Computes Azure server rates from negotiated Price Sheet prices, falling back to public retail prices. | Compute Server Rate | yes | [Azure Resource Manager Rate Hook](../plugins/OHK-vg0rmi7i/) | | Configure Data Disks from Disk Map (Oracle Linux) | [HPA-4ptcwgg4](HPA-4ptcwgg4/README.md) | At Post-Provision, turns the disks from each Oracle Linux server's disk_map into LVM volumes with XFS file systems mounted at their mount points inside the guest. | Post-Provision | yes | [Configure Data Disks from Disk Map (Oracle Linux)](../plugins/OHK-9h9vphf5/) | | Configure Data Disks from Disk Map (Windows) | [HPA-42uy9dyo](HPA-42uy9dyo/README.md) | At Post-Provision, formats the disks from each Windows server's disk_map inside the guest with their drive letters and NTFS labels. | Post-Provision | yes | [Configure Data Disks from Disk Map (Windows)](../plugins/OHK-pdwb3xso/) | -| Delete Windows Computer Object from AD | [HPA-q181uofy](HPA-q181uofy/README.md) | Deletes the Active Directory computer object of each Windows server being deleted at Pre-Delete. | Pre-Delete | yes | [Delete Windows Computer Object from AD](../plugins/OHK-bkoau0j8/) | +| Delete Windows Computer Object from AD | [HPA-q181uofy](HPA-q181uofy/README.md) | Deletes the Active Directory computer object and the DNS records of each Windows server being deleted at Pre-Delete. | Pre-Delete | yes | [Delete Windows Computer Object from AD](../plugins/OHK-bkoau0j8/) | | Generate options for 'Expiration Date' | [HPA-qb0w86mi](HPA-qb0w86mi/README.md) | Pre-fills the Expiration Date order-form parameter with a default of seven days from now. | Generated Parameter Options | yes | [Generate options for 'Expiration Date'](../plugins/OHK-cfciy0fo/) | | Generate options for Ansible job template maps | [HPA-aualk6ei](HPA-aualk6ei/) | Lists the Variable Maps that are Ansible job template maps so an admin pins a blueprint's ansible_job_template_maps parameter from a dropdown. | Generated Parameter Options | yes | [Generate options for Ansible job template maps](../plugins/OHK-7i1fk0l5/) | | Generate Options for Domain Service Account | [HPA-g8pqv6uv](HPA-g8pqv6uv/README.md) | Lists every connection info labeled domain_service_account as the choices for the domain_service_account parameter. | Generated Parameter Options | yes | [Generate Options for Domain Service Account](../plugins/OHK-ww524a3e/) | diff --git a/packages/PKG-nf407lm5/PKG-nf407lm5_metadata.json b/packages/PKG-nf407lm5/PKG-nf407lm5_metadata.json index 441bf79b..c189775d 100644 --- a/packages/PKG-nf407lm5/PKG-nf407lm5_metadata.json +++ b/packages/PKG-nf407lm5/PKG-nf407lm5_metadata.json @@ -7,11 +7,11 @@ "parameters/CF-8pif9mbf", "parameters/CF-yqmreb5m" ], - "description": "Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object at decommission.", + "description": "Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object and its DNS records at decommission.", "id": "PKG-nf407lm5", - "last_updated": "2026-10-26", + "last_updated": "2026-11-02", "metadata_version": "2026.1.0", "minimum_version_required": "", "name": "Windows AD Domain Join", - "version": "1.1.0" + "version": "1.2.0" } diff --git a/packages/PKG-nf407lm5/README.md b/packages/PKG-nf407lm5/README.md index 4ba02aa1..aa757555 100644 --- a/packages/PKG-nf407lm5/README.md +++ b/packages/PKG-nf407lm5/README.md @@ -1,8 +1,8 @@ # Windows AD Domain Join -Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object at decommission. +Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object and its DNS records at decommission. -Content package `PKG-nf407lm5`, version 1.1.0. Sync it from the Content Packages admin page (Content Package Manager UI extension). +Content package `PKG-nf407lm5`, version 1.2.0. Sync it from the Content Packages admin page (Content Package Manager UI extension). | Type | Name | Folder | |---|---|---| diff --git a/packages/README.md b/packages/README.md index 156dac2a..d80f7309 100644 --- a/packages/README.md +++ b/packages/README.md @@ -15,4 +15,4 @@ Named sets of content that the Content Package Manager extension (`extensions/XU | HCP Terraform | [PKG-0bo7vlxp](PKG-0bo7vlxp/README.md) | Provisions VMs and no-code modules through HCP Terraform in a workspace per deployment, optionally followed by Ansible job templates, with their day-2 actions, the form options webhook, and the UI extension that adds Terraform tabs. | 1.0.0 | [HCP Terraform VM](../blueprints/BP-b0qm83lh/README.md) (blueprint), [HCP Terraform No-Code Module](../blueprints/BP-00meiwwz/README.md) (blueprint), [HCP Terraform No-Code + Ansible](../blueprints/BP-uh9v24v3/README.md) (blueprint), [Form Options](../webhooks/IWH-yj93is5z/) (webhook), [HCP Terraform Workspace](../extensions/XUI-ax1sluwi/README.md) (UI extension) | | OpenShift | [PKG-57ltvnbl](PKG-57ltvnbl/README.md) | All OpenShift content: the project landing zone blueprint with its day-2 actions, and the Connect and Workloads tabs on each project. | 1.0.0 | [OpenShift Project](../extensions/XUI-y9bdnzxt/README.md) (UI extension), [OpenShift Project Landing Zone](../blueprints/BP-tikkhf2y/README.md) (blueprint) | | Runbooks | [PKG-v20qv308](PKG-v20qv308/README.md) | Adds Run Task and Run Workflow, actions that run any Remote Script that fits a VM or an ordered workflow of CloudBolt actions on it, with base, example and installer task scripts, the Runbooks page for building workflows, base actions and file archives, example Linux and Windows workflows whose scripts read a config file from File Archives, and Linux and Windows blueprints that run a workflow. | 1.1.0 | [Runbook Task Template (Windows)](../plugins/OHK-lhm2916o/) (plugin), [Runbook Task Template (Linux)](../plugins/OHK-iub9a2jg/) (plugin), [Manage Windows Service](../plugins/OHK-01kmavro/) (plugin), [Manage Linux Service](../plugins/OHK-5yh12jiq/) (plugin), [Run Installer from File Archive (Linux)](../plugins/OHK-hgv6wp65/) (plugin), [Run Installer from File Archive (Windows)](../plugins/OHK-ow68kerl/) (plugin), [Runbook Tasks](../webhooks/IWH-cdf543g3/) (webhook), [Runbook Workflows](../webhooks/IWH-xjlrmvc8/) (webhook), [Run Task](../server_actions/SVA-4sin3s0q/README.md) (server action), [Run Workflow](../server_actions/SVA-j7rbsh39/README.md) (server action), [Runbooks](../extensions/XUI-jbm5ac9e/README.md) (UI extension), [Linux VM with Workflow](../blueprints/BP-vy9ytey6/README.md) (blueprint), [Windows VM with Workflow](../blueprints/BP-6ddlyguv/README.md) (blueprint), [Prepare Linux app host](../runbook_workflows/SWF-69r5mmdb/README.md) (Runbooks workflow), [Prepare Windows app host](../runbook_workflows/SWF-7s01lyyk/README.md) (Runbooks workflow) | -| Windows AD Domain Join | [PKG-nf407lm5](PKG-nf407lm5/README.md) | Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object at decommission. | 1.1.0 | [Delete Windows Computer Object from AD](../orchestration_actions/HPA-q181uofy/README.md) (orchestration action), [Join Windows Server to AD Domain](../orchestration_actions/HPA-jjp1vlfi/README.md) (orchestration action), [Suggest Domain OUs](../orchestration_actions/HPA-0zcrvpwu/README.md) (orchestration action), [Generate Options for Domain Service Account](../orchestration_actions/HPA-g8pqv6uv/README.md) (orchestration action), [Domain OU](../parameters/CF-8pif9mbf/README.md) (parameter), [Domain Service Account](../parameters/CF-yqmreb5m/README.md) (parameter) | +| Windows AD Domain Join | [PKG-nf407lm5](PKG-nf407lm5/README.md) | Joins provisioned Windows servers to Active Directory in the OU picked from a type-ahead domain_ou parameter, optionally switching their CloudBolt credentials to a domain service account, and deletes the computer object and its DNS records at decommission. | 1.2.0 | [Delete Windows Computer Object from AD](../orchestration_actions/HPA-q181uofy/README.md) (orchestration action), [Join Windows Server to AD Domain](../orchestration_actions/HPA-jjp1vlfi/README.md) (orchestration action), [Suggest Domain OUs](../orchestration_actions/HPA-0zcrvpwu/README.md) (orchestration action), [Generate Options for Domain Service Account](../orchestration_actions/HPA-g8pqv6uv/README.md) (orchestration action), [Domain OU](../parameters/CF-8pif9mbf/README.md) (parameter), [Domain Service Account](../parameters/CF-yqmreb5m/README.md) (parameter) | diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_script.py b/plugins/OHK-77f19kly/OHK-77f19kly_script.py index 99bc722a..b153c710 100644 --- a/plugins/OHK-77f19kly/OHK-77f19kly_script.py +++ b/plugins/OHK-77f19kly/OHK-77f19kly_script.py @@ -8,6 +8,8 @@ host's local Administrators group. Each step is skipped when it is already done, so the item can be re-run. + 0. Check that each lab server's name resolves to its own address + (scvmm_lab.check_dns): New-Cluster reaches the hosts by name. 1. Create the cluster hvc- on every host with no storage and the first host's secondary private IP as its address, ignoring the NAT network. Add any host the cluster is missing. @@ -145,6 +147,7 @@ def run(job, resource=None, **kwargs): raise LabError(f"{host.hostname} has no secondary private IP; run Prepare SCVMM Lab on AWS again.") nodes.append(scvmm_lab.computer_name(host)) ips.append(ip) + scvmm_lab.check_dns(lab) log = scvmm_lab.run_task(lab.hosts[0], CREATE_CLUSTER, f"create cluster {lab.cluster_name}", tokens={ "NAME": lab.cluster_name, "NODES": ",".join(nodes), "IPS": ",".join(ips), "NAT_PREFIX": NAT_PREFIX, }, account=lab.account, timeout=2700) diff --git a/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py index 412ee61c..557e4a76 100644 --- a/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py +++ b/plugins/OHK-8ioy2cbi/OHK-8ioy2cbi_script.py @@ -37,6 +37,7 @@ Hyper-V on Windows Server: https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/install-hyper-v New-VMSwitch: https://learn.microsoft.com/en-us/powershell/module/hyper-v/new-vmswitch New-NetNat: https://learn.microsoft.com/en-us/powershell/module/netnat/new-netnat + Set-DnsClient: https://learn.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclient New-IscsiServerTarget: https://learn.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsiservertarget New-IscsiVirtualDisk: https://learn.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsivirtualdisk Add-IscsiVirtualDiskTargetMapping: https://learn.microsoft.com/en-us/powershell/module/iscsitarget/add-iscsivirtualdisktargetmapping @@ -84,6 +85,8 @@ Log "Created internal switch $switch" } $alias = "vEthernet ($switch)" + # Every host has the same NAT gateway address; registered in DNS, it would answer for every host's name. + Set-DnsClient -InterfaceAlias $alias -RegisterThisConnectionsAddress $false if (-not (Get-NetIPAddress -InterfaceAlias $alias -IPAddress $gateway -ErrorAction SilentlyContinue)) { New-NetIPAddress -InterfaceAlias $alias -IPAddress $gateway -PrefixLength ([int]($prefix -split '/')[1]) | Out-Null } diff --git a/plugins/OHK-bkoau0j8/OHK-bkoau0j8_metadata.json b/plugins/OHK-bkoau0j8/OHK-bkoau0j8_metadata.json index 68980887..b0809b96 100644 --- a/plugins/OHK-bkoau0j8/OHK-bkoau0j8_metadata.json +++ b/plugins/OHK-bkoau0j8/OHK-bkoau0j8_metadata.json @@ -4,7 +4,7 @@ "shared_modules/SHM-gcba1u31" ] }, - "description": "Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server.", + "description": "Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server, and tombstones the DNS records that computer object owns.", "id": "OHK-bkoau0j8", "max_retries": 0, "name": "Delete Windows Computer Object from AD", diff --git a/plugins/OHK-bkoau0j8/OHK-bkoau0j8_script.py b/plugins/OHK-bkoau0j8/OHK-bkoau0j8_script.py index 61de2fe9..50916031 100644 --- a/plugins/OHK-bkoau0j8/OHK-bkoau0j8_script.py +++ b/plugins/OHK-bkoau0j8/OHK-bkoau0j8_script.py @@ -24,6 +24,15 @@ together with them through AD's tree delete control. An object that is already gone is reported and counts as success. +With the computer object, it deletes the DNS records the computer registered +in AD-integrated zones: the node for its DNS host name and the reverse (PTR) +node for each IPv4 address that node holds. A node is deleted only when the +computer object owns it, as the node a secure dynamic update creates is, so a +record an administrator made is left alone. AD-integrated zones let only a +record's owner update it, so a record left behind would keep the next server +with the same name from registering its own. Nodes are tombstoned the way the +DNS server deletes them (ad_domain.tombstone_dns_node). + The action's OS family filter (Windows) keeps Linux servers out; the check in _delete_one keeps them out if the filter is edited. The orchestration action continues on failure, so an AD problem is reported in the job without @@ -87,6 +96,41 @@ def _find_target(conn, base, server): return target, "", "" +def _reverse_name(address): + return "%s.in-addr.arpa" % ".".join(reversed(address.split("."))) + + +def _delete_dns(conn, target, fqdn): + """ + Tombstone the DNS nodes the computer object owns for fqdn and for the + reverse names of its addresses. Returns a description of what was done. + """ + sid = target["sid"] + if not sid: + return "its DNS records were left alone: the computer object's SID could not be read" + deleted, foreign = [], [] + names = [fqdn] + while names: + name = names.pop(0) + for dn, entry in ad_domain.find_dns_nodes(conn, name): + if ad_domain.is_tombstoned(entry): + continue + if ad_domain.owner_sid(conn, dn) != sid: + foreign.append(name) + continue + addresses = ad_domain.a_addresses(entry) + ad_domain.tombstone_dns_node(conn, dn, entry) + deleted.append("%s (%s)" % (name, ", ".join(addresses)) if addresses else name) + if name == fqdn: + names += [_reverse_name(address) for address in addresses] + parts = [] + if deleted: + parts.append("deleted DNS records %s" % "; ".join(deleted)) + if foreign: + parts.append("left DNS records %s alone: another account owns them" % ", ".join(foreign)) + return ", ".join(parts) or "found no DNS records of its own for %s" % fqdn + + def _delete_one(server): """Returns (status, message), status SUCCESS, FAILURE, or SKIPPED.""" hostname = server.hostname @@ -94,7 +138,7 @@ def _delete_one(server): return "SKIPPED", "%s: not Windows, skipped." % hostname recorded_dn = str(server.get_value_for_custom_field(DN_FIELD) or "").strip() try: - ldap_utility, _, _ = ad_domain.resolve(server, dn=recorded_dn or None) + ldap_utility, domain, _ = ad_domain.resolve(server, dn=recorded_dn or None) except ValueError as err: return "FAILURE", "%s: cannot tell which domain its computer object is in: %s." % (hostname, err) if ldap_utility is None: @@ -107,6 +151,14 @@ def _delete_one(server): if target is None: return status, "%s: %s in %s." % (hostname, reason, ldap_utility.ldap_domain) ad_domain.delete_entry(conn, target["dn"]) + fqdn = target["dns_host_name"] or "%s.%s" % (ad_domain.computer_name(hostname), domain) + try: + dns = _delete_dns(conn, target, fqdn) + except Exception as err: + message = "%s: deleted computer object %s, but could not delete its DNS records: %s" % ( + hostname, target["dn"], err) + logger.error(message) + return "FAILURE", message finally: conn.unbind_s() except Exception as err: @@ -114,7 +166,7 @@ def _delete_one(server): hostname, ldap_utility.ldap_domain, err) logger.error(message) return "FAILURE", message - return "SUCCESS", "%s: deleted computer object %s." % (hostname, target["dn"]) + return "SUCCESS", "%s: deleted computer object %s; %s." % (hostname, target["dn"], dns) def run(job, *args, **kwargs): diff --git a/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py b/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py index 186dd523..1e95a063 100644 --- a/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py +++ b/plugins/OHK-q6fb9833/OHK-q6fb9833_script.py @@ -7,7 +7,10 @@ 1. Check that every lab server is in the domain under its CloudBolt hostname (Join Windows Server to AD Domain, HPA-jjp1vlfi, joins them at - Post-Provision) and record the domain on the resource. + Post-Provision) and record the domain on the resource. Check that each + server's name resolves to its own address (scvmm_lab.check_dns), so a + stale DNS record fails the build here rather than at Create Hyper-V + Cluster. 2. Per Hyper-V host: check the instance type, stop the instance, turn on nested virtualization and start it again (nothing on .metal sizes), and assign one secondary private IP to its primary interface for the @@ -118,6 +121,7 @@ def run(job, resource=None, **kwargs): domain = _check_domains(lab) resource.set_value_for_custom_field("scvmm_lab_domain", domain) set_progress(f"All {len(lab.servers)} lab servers are in {domain}") + scvmm_lab.check_dns(lab) host_ips, cluster_ips = [], [] for host in lab.hosts: diff --git a/plugins/README.md b/plugins/README.md index b0bffb9f..48ba3fd5 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -72,7 +72,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | Delete Blob Container | [OHK-y1120h61](OHK-y1120h61/) | Deletes a blob container from the resource's Azure storage account. | CloudBolt Plug-in | [Delete Blob Container](../resource_actions/RSA-zmi15uts/) | | Delete Cluster | [OHK-pgbigmd9](OHK-pgbigmd9/) | Deletes the EKS cluster's node groups, the cluster, its IAM cluster role, the CloudBolt container orchestrator, and the node group sub-resources, refusing while namespace landing zones remain on the cluster. | CloudBolt Plug-in | [AWS EKS](../blueprints/BP-r5apcf7e/README.md) | | Delete GKE Node Pool | [OHK-qxdrryt6](OHK-qxdrryt6/) | Deletes a node pool from the GKE cluster, refusing its last one, and removes the pool's sub-resource. | CloudBolt Plug-in | [Delete GKE Node Pool](../resource_actions/RSA-kfd31bur/) | -| Delete Windows Computer Object from AD | [OHK-bkoau0j8](OHK-bkoau0j8/) | Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server. | CloudBolt Plug-in | [Delete Windows Computer Object from AD](../orchestration_actions/HPA-q181uofy/README.md) | +| Delete Windows Computer Object from AD | [OHK-bkoau0j8](OHK-bkoau0j8/) | Deletes a Windows server's Active Directory computer object over LDAP with the LDAP Utility for its domain, matching it by the objectGUID recorded at join or, failing that, by a name created after the server, and tombstones the DNS records that computer object owns. | CloudBolt Plug-in | [Delete Windows Computer Object from AD](../orchestration_actions/HPA-q181uofy/README.md) | | Deploy AWS App Migration Agent | [OHK-5wpzgw68](OHK-5wpzgw68/) | Installs the AWS Application Migration Service replication agent on a Linux server. | CloudBolt Plug-in | [Deploy AWS App Migration Agent](../server_actions/SVA-mwbtjfr0/README.md) | | Deploy Bicep Template | [OHK-gqvi9kv4](OHK-gqvi9kv4/) | Deploys an Azure deployment stack from a GitHub-hosted Bicep template after a what-if preview and approval. | CloudBolt Plug-in | [Azure Resource Group - Bicep](../blueprints/BP-p7zmh96m/README.md), [Bicep Deployment](../blueprints/BP-nibk4erf/README.md) | | Deploy EKS Cluster | [OHK-u4k6dg46](OHK-u4k6dg46/) | Creates an Amazon EKS cluster and its IAM cluster role in the chosen AWS environment, registers it as a CloudBolt Kubernetes container orchestrator, and stores the cluster details on the resource. | CloudBolt Plug-in | [AWS EKS](../blueprints/BP-r5apcf7e/README.md) | diff --git a/shared_modules/README.md b/shared_modules/README.md index 4f0ca69c..f504eace 100644 --- a/shared_modules/README.md +++ b/shared_modules/README.md @@ -5,7 +5,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | Module | ID | Description | Used by | |---|---|---|---| -| `ad_domain` | [SHM-gcba1u31](SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects. | [Delete Windows Computer Object from AD](../plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](../plugins/OHK-9oqn6pur/), [Remove Hyper-V Cluster Object](../plugins/OHK-kzb6pzzu/), [Suggest Domain OUs](../plugins/OHK-z9qrccyu/) | +| `ad_domain` | [SHM-gcba1u31](SHM-gcba1u31/) | Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, finds and deletes computer objects, and deletes the DNS records a computer registered. | [Delete Windows Computer Object from AD](../plugins/OHK-bkoau0j8/), [Join Windows Server to AD Domain](../plugins/OHK-9oqn6pur/), [Remove Hyper-V Cluster Object](../plugins/OHK-kzb6pzzu/), [Suggest Domain OUs](../plugins/OHK-z9qrccyu/) | | `aks_namespace` | [SHM-cozv547n](SHM-cozv547n/) | Managed-namespace landing zones, Azure RBAC namespace access, connection details, and GitHub pipeline identities for the AKS Namespace blueprint. | [AKS Namespace](../plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](../plugins/OHK-vi009xb8/), [Create AKS Namespace](../plugins/OHK-kb4pv2yq/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover AKS Namespaces](../plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](../plugins/OHK-t1r0y1yd/), [Manage AKS Namespace Access](../plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](../plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](../plugins/OHK-jeighfcq/), [Teardown AKS Namespace](../plugins/OHK-wmdr2ef5/) | | `aria_connection` | [SHM-u2s2d40p](SHM-u2s2d40p/) | Aria Automation 8 and Aria Orchestrator REST clients built on a CloudBolt ConnectionInfo labeled vra8 or aria, with generate-options helpers for connection and project dropdowns. | [Aria Migration Form Options](../plugins/OHK-xhpq1rn3/), [Migrate Aria Automation Deployments](../plugins/OHK-7sq2hqrb/), [Migrate Aria Automation Projects](../plugins/OHK-gyl8wlrq/), [Run Aria Orchestrator Workflow](../plugins/OHK-3bgpjmlr/) | | `azure_aks` | [SHM-ptvp0km4](SHM-ptvp0km4/) | ARM client, cluster and node pool operations, orchestrator registration, and role-assignment helpers for Azure Kubernetes Service content. | [Add AKS Node Pool](../plugins/OHK-b7poza8x/), [AKS Cluster Build](../plugins/OHK-x13tmam0/), [AKS Cluster Discovery](../plugins/OHK-uof2rcaa/), [AKS Cluster Teardown](../plugins/OHK-27oemiwb/), [AKS Namespace](../plugins/OHK-735mhtvh/), [AKS Namespace Connection Details](../plugins/OHK-vi009xb8/), [Create AKS Namespace](../plugins/OHK-kb4pv2yq/), [Delete AKS Node Pool](../plugins/OHK-czexzrl1/), [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover AKS Namespaces](../plugins/OHK-tybit8su/), [Extend AKS Namespace Expiration](../plugins/OHK-t1r0y1yd/), [List AKS Node Pools](../plugins/OHK-0fp008gh/), [Manage AKS Cluster Groups](../plugins/OHK-yzmq0kzu/), [Manage AKS Namespace Access](../plugins/OHK-cqkwd0mq/), [Manage AKS Namespace Pipeline Identity](../plugins/OHK-4rucefwc/), [Request AKS Namespace Quota Change](../plugins/OHK-jeighfcq/), [Scale AKS Node Pool](../plugins/OHK-80c4ibdb/), [Teardown AKS Namespace](../plugins/OHK-wmdr2ef5/), [Upgrade AKS Node Pool](../plugins/OHK-t0j1w09c/), [Upgrade AKS Version](../plugins/OHK-ojf2vvq1/) | diff --git a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py index 79198a08..8640219d 100644 --- a/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py +++ b/shared_modules/SHM-dpj24dfj/SHM-dpj24dfj_script.py @@ -20,6 +20,8 @@ or to other servers signs in with the account's own password, so there is no second hop to lose its credentials on; - restarts (restart, wait_for_restart); + - checking that every lab server's name resolves to its own address + (check_dns), before the steps that reach the servers by name; - EC2 calls through the handler's boto3 client: nested virtualization, the hosts' cluster IP addresses and the storage volume. @@ -36,6 +38,9 @@ Server.execute_script, AWS SSM: typings/infrastructure/models.pyi, resourcehandlers/aws run_script_on_guest Register-ScheduledTask: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask New-ScheduledTaskPrincipal: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal + Resolve-DnsName: https://learn.microsoft.com/en-us/powershell/module/dnsclient/resolve-dnsname + Register-DnsClient: https://learn.microsoft.com/en-us/powershell/module/dnsclient/register-dnsclient + Clear-DnsClientCache: https://learn.microsoft.com/en-us/powershell/module/dnsclient/clear-dnsclientcache Nested virtualization: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-ec2-nested-virtualization.html ModifyInstanceCpuOptions: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyInstanceCpuOptions.html AssignPrivateIpAddresses: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AssignPrivateIpAddresses.html @@ -232,6 +237,22 @@ Mark 'BOOT' ((Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime.ToUniversalTime().Ticks) """ +DNS_RESOLVE = r""" + $names = @((Decode '__CB_NAMES__') -split ',') + Clear-DnsClientCache + for ($i = 0; $i -lt $names.Count; $i++) { + $found = @(Lookup { Resolve-DnsName -Name $names[$i] -Type A -DnsOnly -NoHostsFile -ErrorAction Stop } | + Where-Object { $_.Type -eq 'A' } | ForEach-Object { $_.IPAddress }) + Mark "DNS_$i" ($found -join ' ') + } +""" + +DNS_REGISTER = r""" + Register-DnsClient +""" + +DNS_WAIT = 180 + class LabError(Exception): """A problem to show the user as the build item's error.""" @@ -568,6 +589,49 @@ def wait_for_restart(server, boot_ticks): time.sleep(POLL_INTERVAL) +def check_dns(lab, wait=DNS_WAIT): + """ + Check, from the first host, that every lab server's name resolves to its + primary private IP and to no address outside its own instance: the cluster + and SCVMM reach the servers by name. A server whose name resolves + elsewhere, or not at all, is asked to register again (Register-DnsClient) + and checked until wait seconds pass. Raises LabError naming each wrong name. + """ + servers = lab.servers + names = [lab.fqdn(server) for server in servers] + expected = [] + for server in servers: + instance = describe_instance(ec2_client(server), server) + own = {address["PrivateIpAddress"] for interface in instance.get("NetworkInterfaces", []) + for address in interface.get("PrivateIpAddresses", [])} + expected.append((instance["PrivateIpAddress"], own)) + deadline = time.time() + wait + asked = set() + while True: + found, _ = run_ps(lab.hosts[0], DNS_RESOLVE, tokens={"NAMES": ",".join(names)}) + answers = [set(found.get(f"DNS_{i}", "").split()) for i in range(len(servers))] + wrong = [i for i, answer in enumerate(answers) if expected[i][0] not in answer or not answer <= expected[i][1]] + if not wrong: + set_progress("DNS: " + ", ".join(f"{name} is {ip}" for name, (ip, _) in zip(names, expected))) + return + if time.time() + POLL_INTERVAL > deadline: + break + for i in wrong: + if i not in asked: + asked.add(i) + run_ps(servers[i], DNS_REGISTER) + set_progress(f"DNS: {names[i]} resolves to {', '.join(sorted(answers[i])) or 'nothing'}, not " + f"{expected[i][0]}; asked {servers[i].hostname} to register its name again") + time.sleep(POLL_INTERVAL) + problems = [f"{names[i]} resolves to {', '.join(sorted(answers[i])) or 'nothing'}, not {expected[i][0]}" + for i in wrong] + raise LabError( + "; ".join(problems) + ". The cluster and SCVMM reach the lab servers by name. The usual cause is a DNS " + "record an earlier server with the same name left behind: the zone lets only a record's owner update " + f"it, so the new server cannot replace it. Delete those records in the {lab.domain} zone, then run this " + "build item again.") + + # ------------------------------------------------------------------- EC2 def ec2_client(server): diff --git a/shared_modules/SHM-gcba1u31/SHM-gcba1u31_metadata.json b/shared_modules/SHM-gcba1u31/SHM-gcba1u31_metadata.json index 5c947846..fba5fa25 100644 --- a/shared_modules/SHM-gcba1u31/SHM-gcba1u31_metadata.json +++ b/shared_modules/SHM-gcba1u31/SHM-gcba1u31_metadata.json @@ -1,5 +1,5 @@ { - "description": "Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, and finds and deletes computer objects.", + "description": "Finds the Active Directory domain and LDAP Utility for a server from its domain_ou or domain_to_join, binds with that utility, finds and deletes computer objects, and deletes the DNS records a computer registered.", "id": "SHM-gcba1u31", "label": "AD Domain", "max_retries": 0, diff --git a/shared_modules/SHM-gcba1u31/SHM-gcba1u31_script.py b/shared_modules/SHM-gcba1u31/SHM-gcba1u31_script.py index 34f83e55..7d0bb36b 100644 --- a/shared_modules/SHM-gcba1u31/SHM-gcba1u31_script.py +++ b/shared_modules/SHM-gcba1u31/SHM-gcba1u31_script.py @@ -3,7 +3,8 @@ The domain comes from the LDAP Utility that a server's domain_to_join parameter names. This module binds with that utility's service account, searches the -domain for organizational units, and finds and deletes computer objects. Its +domain for organizational units, finds and deletes computer objects, and +deletes the DNS records a computer registered in AD-integrated zones. Its callers are the OU suggestions action, the Windows join action, and the computer object cleanup action. @@ -18,7 +19,18 @@ DN parsing: https://www.python-ldap.org/en/latest/reference/ldap-dn.html Controls: https://www.python-ldap.org/en/latest/reference/ldap-controls.html AD tree delete control: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ldap/ldap-server-tree-delete-oid + AD SD flags control: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ldap/ldap-server-sd-flags-oid + Security descriptor: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/7d4dac05-9cef-4563-a058-f108abecce1d + SID layout: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/f992ad60-0fe4-4b87-9fed-beb478836861 + dnsRecord layout: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/6912b338-5472-4f59-b912-0edb536b6ed8 + Record types: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/ac793981-1c60-43b8-be59-cdbb5c4ecb8a + Deleting a node's last record (dnsTombstoned): + https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/37eea101-00b8-4958-99eb-de8cda4b8417 + DNS_RPC_RECORD_TS: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/def7736a-dd09-4b4a-b8d6-6a702a7ecde0 """ +import socket +import struct +import time import uuid from datetime import datetime, timezone @@ -37,7 +49,22 @@ # store under a computer object. TREE_DELETE_OID = "1.2.840.113556.1.4.805" -COMPUTER_ATTRS = ["objectGUID", "sAMAccountName", "dNSHostName", "whenCreated"] +# LDAP_SERVER_SD_FLAGS_OID asking for OWNER_SECURITY_INFORMATION (1) only, so +# reading nTSecurityDescriptor needs no right to the SACL. The value is the BER +# encoding of SEQUENCE { INTEGER 1 }. +SD_FLAGS_OID = "1.2.840.113556.1.4.801" +SD_OWNER_ONLY = b"\x30\x03\x02\x01\x01" + +# dnsRecord values (MS-DNSP 2.3.2.2): a 24-byte header, then the record data. +DNS_RECORD_HEADER = 24 +DNS_RECORD_VERSION = 5 +DNS_TYPE_ZERO = 0x0000 +DNS_TYPE_A = 0x0001 +RANK_ZONE = 0xF0 +# 1970-01-01 as a FILETIME: 100-nanosecond intervals since 1601-01-01 UTC. +FILETIME_UNIX_EPOCH = 116444736000000000 + +COMPUTER_ATTRS = ["objectGUID", "objectSid", "sAMAccountName", "dNSHostName", "whenCreated"] def utilities(): @@ -221,6 +248,7 @@ def _computer(dn, entry): return { "dn": dn, "guid": guid_text(raw_guid) if len(raw_guid) == 16 else "", + "sid": _first(entry, "objectSid"), "sam_account_name": _first(entry, "sAMAccountName").decode("utf-8", "ignore"), "dns_host_name": _first(entry, "dNSHostName").decode("utf-8", "ignore"), "created": created, @@ -252,3 +280,106 @@ def delete_entry(conn, dn): def computer_name(hostname): """The Windows computer name for a host name: its first label, cut to the 15-character NetBIOS limit.""" return str(hostname).split(".")[0][:15] + + +def dns_bases(conn): + """ + The containers of the AD-integrated DNS zones on the directory conn is + bound to: CN=MicrosoftDNS in each DomainDnsZones or ForestDnsZones + application partition its root DSE lists in namingContexts, and + CN=MicrosoftDNS,CN=System of the domain partition, for zones stored there. + """ + entries = conn.search_ext_s("", ldap.SCOPE_BASE, "(objectClass=*)", ["namingContexts", "defaultNamingContext"]) + contexts, default = [], "" + for _, entry in entries: + entry = entry or {} + contexts += [value.decode("utf-8") for value in entry.get("namingContexts") or []] + default = default or _first(entry, "defaultNamingContext").decode("utf-8") + bases = ["CN=MicrosoftDNS,%s" % context for context in contexts + if context.split(",", 1)[0].upper() in ("DC=DOMAINDNSZONES", "DC=FORESTDNSZONES")] + if default: + bases.append("CN=MicrosoftDNS,CN=System,%s" % default) + return bases + + +def find_dns_nodes(conn, fqdn): + """ + The dnsNode objects that hold fqdn's records, as (dn, entry) with + dnsRecord and dNSTombstoned. A node's DN is DC=, + DC=,CN=MicrosoftDNS,..., so its two first DC values joined by a dot + are fqdn; the name in the zone can have dots itself. + """ + fqdn = fqdn.strip(".").lower() + labels = fqdn.split(".") + relative = [".".join(labels[:i]) for i in range(1, len(labels))] + if not relative: + return [] + filterstr = "(&(objectClass=dnsNode)(|%s))" % "".join("(dc=%s)" % escape_filter_chars(name) for name in relative) + nodes = [] + for base in dns_bases(conn): + try: + entries = _search(conn, base, filterstr, ["dnsRecord", "dNSTombstoned"], 20) + except (ldap.NO_SUCH_OBJECT, ldap.REFERRAL): + continue + for dn, entry in entries: + rdns = ldap.dn.str2dn(dn) + if len(rdns) > 1 and ("%s.%s" % (rdns[0][0][1], rdns[1][0][1])).lower() == fqdn: + nodes.append((dn, entry)) + return nodes + + +def dns_records(entry): + """(type, serial, data) of each record in a dnsNode's dnsRecord values.""" + records = [] + for raw in entry.get("dnsRecord") or []: + if len(raw) < DNS_RECORD_HEADER: + continue + length, rtype = struct.unpack_from("= offset + 8: + return descriptor[offset:offset + 8 + 4 * descriptor[offset + 1]] + return b"" + + +def tombstone_dns_node(conn, dn, entry): + """ + Delete every record of a dnsNode the way a DNS server does when it deletes + the last record at a node: dNSTombstoned TRUE, and dnsRecord a single + DNS_TYPE_ZERO record whose data is the deletion time (EntombedTime). DNS + servers read the change at their next directory poll and drop the name, as + they do for a deletion another DNS server made, and their tombstone cleanup + removes the object later. The name is free to register again. + """ + serial = max([serial for _, serial, _ in dns_records(entry)] or [0]) + entombed = int(time.time() * 10 ** 7) + FILETIME_UNIX_EPOCH + # DataLength, Type, Version, Rank, Flags, Serial; TtlSeconds is big-endian; + # Reserved, TimeStamp; then the 8-byte EntombedTime. + record = (struct.pack("I", 0) + struct.pack(" Date: Tue, 3 Nov 2026 06:46:13 -0500 Subject: [PATCH 10/22] Create the lab cluster without needing its name to resolve, and wait for it before SCVMM adds it New-Cluster ends by opening the cluster by name, which failed on lab-7: the cluster registered its name with one domain controller, and the hosts' resolvers answered "no such name" for about 18 minutes (replication plus a cached negative answer). Create Hyper-V Cluster now works on the local cluster and carries on when only that last step fails. Add Hyper-V Cluster to SCVMM waits up to an hour for the name to resolve from the SCVMM server. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 1 + plugins/OHK-77f19kly/OHK-77f19kly_script.py | 53 +++++++++++++-------- plugins/OHK-ive3ka22/OHK-ive3ka22_script.py | 37 ++++++++++++++ 3 files changed, 72 insertions(+), 19 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 0b87e29f..6408d31f 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -64,6 +64,7 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster ## Notes - **Re-running a build item.** Every step is skipped when it is already done. - **DNS names.** Prepare and Create Hyper-V Cluster check that every lab server's name resolves to its own address, because the cluster and SCVMM reach the servers by name. The usual cause of a failure is a record left by an earlier server with the same name. The zone lets only a record's owner update it, so the new server cannot replace it. Delete the record named in the error, then re-run the item. HPA-q181uofy deletes the records of the servers it deletes. +- **The cluster's name** is registered with one domain controller while the cluster is created. Other DNS servers answer for it only after directory replication. A resolver that cached "no such name" during creation keeps that answer until it expires, which can take up to the zone's minimum TTL (an hour by default). So Add Hyper-V Cluster to SCVMM waits up to an hour for the name to resolve from the SCVMM server; in testing it took about 18 minutes. Create Hyper-V Cluster does not need the name. - **Slow steps** run as scheduled tasks under `\CloudBolt\` and are polled every 30 seconds. Steps that reach AD or other servers sign in as the domain service account, so there is no double hop. Their logs are in the job's progress. - **The service account's password** goes to the guest inside the script body, base64 encoded for quoting only. On AWS that body stays in Systems Manager's command history. - **Scale-up is not supported.** Order a new lab for more hosts. diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_script.py b/plugins/OHK-77f19kly/OHK-77f19kly_script.py index b153c710..d0fa4722 100644 --- a/plugins/OHK-77f19kly/OHK-77f19kly_script.py +++ b/plugins/OHK-77f19kly/OHK-77f19kly_script.py @@ -12,7 +12,12 @@ (scvmm_lab.check_dns): New-Cluster reaches the hosts by name. 1. Create the cluster hvc- on every host with no storage and the first host's secondary private IP as its address, ignoring the NAT - network. Add any host the cluster is missing. + network. Add any host the cluster is missing. The cluster registers its + name with one domain controller, and the name resolves elsewhere only + after directory replication, so every step works on the local cluster + rather than on its name. New-Cluster's own last step opens the cluster + by name; when only that fails, the cluster is there and the item goes + on. Add Hyper-V Cluster to SCVMM waits for the name. 2. Give the core network name one IP address resource per host, each host's secondary private IP, possible owner that host only, joined by an OR dependency. EC2 delivers an address only to the interface it is @@ -61,48 +66,58 @@ $natPrefix = Decode '__CB_NAT_PREFIX__' $natAddress = ($natPrefix -split '/')[0] + # The cmdlets below work on the local cluster, not on its name: the name resolves only once its DNS + # record reaches the DNS servers this host uses. $cluster = Lookup { Get-Cluster -ErrorAction Stop } if ($cluster -and $cluster.Name -ne $name) { throw "$env:COMPUTERNAME is already in cluster $($cluster.Name)." } if (-not $cluster) { Log "Creating cluster $name on $($nodes -join ', ') with address $($ips[0])" - New-Cluster -Name $name -Node $nodes -StaticAddress $ips[0] -IgnoreNetwork $natPrefix -NoStorage | Out-Null + try { + New-Cluster -Name $name -Node $nodes -StaticAddress $ips[0] -IgnoreNetwork $natPrefix -NoStorage | Out-Null + } catch { + # New-Cluster's last step opens the new cluster by name. + $failure = $_ + $cluster = Lookup { Get-Cluster -ErrorAction Stop } + if (-not $cluster -or $cluster.Name -ne $name) { throw $failure } + Log "Cluster $name is created; its name does not resolve here yet: $($failure.Exception.Message)" + } } - $members = @(Get-ClusterNode -Cluster $name | ForEach-Object { $_.Name.ToLower() }) + $members = @(Get-ClusterNode | ForEach-Object { $_.Name.ToLower() }) foreach ($node in $nodes) { if ($members -notcontains $node.ToLower()) { Log "Adding node $node" - Add-ClusterNode -Cluster $name -Name $node -NoStorage | Out-Null + Add-ClusterNode -Name $node -NoStorage | Out-Null } } - $nat = Get-ClusterNetwork -Cluster $name | Where-Object { $_.Address -eq $natAddress } + $nat = Get-ClusterNetwork | Where-Object { $_.Address -eq $natAddress } foreach ($n in $nat) { if ($n.Role -ne 0) { $n.Role = 0; Log "Cluster network $($n.Name) ($natPrefix) set to no cluster traffic" } } - $network = Get-ClusterNetwork -Cluster $name | Where-Object { $_.Address -ne $natAddress -and $_.Role -ne 0 } | Select-Object -First 1 + $network = Get-ClusterNetwork | Where-Object { $_.Address -ne $natAddress -and $_.Role -ne 0 } | Select-Object -First 1 if (-not $network) { throw 'The cluster has no network for its IP addresses.' } - $core = Get-ClusterResource -Cluster $name | Where-Object { $_.OwnerGroup -eq 'Cluster Group' } + $core = Get-ClusterResource | Where-Object { $_.OwnerGroup -eq 'Cluster Group' } $nameResource = $core | Where-Object { $_.ResourceType -eq 'Network Name' } | Select-Object -First 1 $ipResources = @() for ($i = 0; $i -lt $nodes.Count; $i++) { $resource = $core | Where-Object { $_.ResourceType -eq 'IP Address' } | Where-Object { (Get-ClusterParameter -InputObject $_ -Name Address).Value -eq $ips[$i] } | Select-Object -First 1 if (-not $resource) { - $resource = Add-ClusterResource -Cluster $name -Name "Cluster IP Address $($ips[$i])" -ResourceType 'IP Address' -Group 'Cluster Group' + $resource = Add-ClusterResource -Name "Cluster IP Address $($ips[$i])" -ResourceType 'IP Address' -Group 'Cluster Group' $resource | Set-ClusterParameter -Multiple @{ Address = $ips[$i]; SubnetMask = $network.AddressMask; Network = $network.Name; EnableDhcp = 0 } Log "Added IP address resource $($ips[$i]) for $($nodes[$i])" } - Set-ClusterOwnerNode -Cluster $name -Resource $resource.Name -Owners $nodes[$i] | Out-Null + Set-ClusterOwnerNode -Resource $resource.Name -Owners $nodes[$i] | Out-Null $ipResources += $resource.Name } $expression = ($ipResources | ForEach-Object { "[$_]" }) -join ' or ' - Set-ClusterResourceDependency -Cluster $name -Resource $nameResource.Name -Dependency $expression | Out-Null - Start-ClusterGroup -Cluster $name -Name 'Cluster Group' | Out-Null - $settings = Get-Cluster -Name $name + Set-ClusterResourceDependency -Resource $nameResource.Name -Dependency $expression | Out-Null + Start-ClusterGroup -Name 'Cluster Group' | Out-Null + $settings = Get-Cluster if ($settings.SameSubnetThreshold -lt 10) { $settings.SameSubnetThreshold = 10 } $witnessName = 'CBLab Witness' $csvName = 'CBLab CSV' - $diskResources = @(Get-ClusterResource -Cluster $name | Where-Object { $_.ResourceType -eq 'Physical Disk' } | ForEach-Object { $_.Name }) + $diskResources = @(Get-ClusterResource | Where-Object { $_.ResourceType -eq 'Physical Disk' } | ForEach-Object { $_.Name }) # The smaller iSCSI disk (1 GB) is the witness, the larger the cluster shared volume. $iscsi = @(Get-Disk | Where-Object { $_.BusType -eq 'iSCSI' } | Sort-Object Size) $plan = @( @@ -120,19 +135,19 @@ New-Partition -DiskNumber $disk.Number -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel $item.Label -Confirm:$false | Out-Null Log "Formatted iSCSI disk $($disk.Number) ($([math]::Round($disk.Size / 1GB)) GB) as $($item.Label)" } - $available = Get-ClusterAvailableDisk -Cluster $name -Disk (Get-Disk -Number $disk.Number) + $available = Get-ClusterAvailableDisk -Disk (Get-Disk -Number $disk.Number) if (-not $available) { throw "iSCSI disk $($disk.Number) cannot be added to the cluster; check every host sees it." } $added = $available | Add-ClusterDisk $added.Name = $item.Resource Log "Added cluster disk $($item.Resource)" } - if ((Get-ClusterQuorum -Cluster $name).QuorumResource.Name -ne $witnessName) { - Set-ClusterQuorum -Cluster $name -DiskWitness $witnessName | Out-Null + if ((Get-ClusterQuorum).QuorumResource.Name -ne $witnessName) { + Set-ClusterQuorum -DiskWitness $witnessName | Out-Null } - $csv = Lookup { Get-ClusterSharedVolume -Cluster $name -Name $csvName -ErrorAction Stop } - if (-not $csv) { $csv = Add-ClusterSharedVolume -Cluster $name -Name $csvName } + $csv = Lookup { Get-ClusterSharedVolume -Name $csvName -ErrorAction Stop } + if (-not $csv) { $csv = Add-ClusterSharedVolume -Name $csvName } Mark 'CSV_PATH' $csv.SharedVolumeInfo.FriendlyVolumeName - Mark 'OWNER' (Get-ClusterGroup -Cluster $name -Name 'Cluster Group').OwnerNode.Name + Mark 'OWNER' (Get-ClusterGroup -Name 'Cluster Group').OwnerNode.Name """ diff --git a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py index b2cbbe58..f54e039f 100644 --- a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py +++ b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py @@ -6,6 +6,12 @@ scheduled task signed in as the domain service account (an SCVMM administrator, because it installed SCVMM): + 0. Wait up to CLUSTER_DNS_WAIT seconds for the cluster's name to resolve, + from the SCVMM server, to one of the cluster's addresses. The cluster + registers its name with one domain controller; DNS servers that read + the zone from other domain controllers answer for it only after + directory replication, and a resolver that cached "no such name" keeps + answering that until the cached answer expires. 1. Create the Run As account RUN_AS for the domain service account, unless it exists. SCVMM uses it to install its agent on every node; it must be a domain account in each node's local Administrators group. @@ -18,6 +24,7 @@ contain template tags; values reach the scripts through the __CB_*__ tokens. References: + Resolve-DnsName: https://learn.microsoft.com/en-us/powershell/module/dnsclient/resolve-dnsname Add existing Hyper-V hosts and clusters: https://learn.microsoft.com/en-us/system-center/vmm/hyper-v-existing?view=sc-vmm-2025 Ports and protocols: https://learn.microsoft.com/en-us/system-center/vmm/plan-ports-protocols?view=sc-vmm-2025 Get-SCVMMServer: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmmserver?view=systemcenter-ps-2025 @@ -26,12 +33,15 @@ Add-SCVMHostCluster: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/add-scvmhostcluster?view=systemcenter-ps-2025 Get-SCVMHostCluster: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmhostcluster?view=systemcenter-ps-2025 """ +import time + from common.methods import set_progress from shared_modules import scvmm_lab from shared_modules.scvmm_lab import LabError RUN_AS = "CloudBolt SCVMM Lab Hosts" +CLUSTER_DNS_WAIT = 3600 ADD_CLUSTER = r""" Import-Module VirtualMachineManager @@ -60,10 +70,37 @@ """ +def wait_for_cluster_name(lab): + """Wait until the cluster's name resolves from the SCVMM server to one of its addresses.""" + addresses = {scvmm_lab.cluster_ip(scvmm_lab.ec2_client(host), host) for host in lab.hosts} - {None} + started = time.time() + deadline = started + CLUSTER_DNS_WAIT + next_report = started + while True: + found, _ = scvmm_lab.run_ps(lab.vmm, scvmm_lab.DNS_RESOLVE, tokens={"NAMES": lab.cluster_fqdn}) + answer = set(found.get("DNS_0", "").split()) + if answer & addresses: + set_progress(f"DNS: {lab.cluster_fqdn} is {', '.join(sorted(answer))}") + return + if time.time() + scvmm_lab.POLL_INTERVAL > deadline: + break + if time.time() >= next_report: + set_progress(f"DNS: waiting for {lab.cluster_fqdn} to resolve from {lab.vmm.hostname} " + f"({int(time.time() - started) // 60} of {CLUSTER_DNS_WAIT // 60} minutes)") + next_report += 600 + time.sleep(scvmm_lab.POLL_INTERVAL) + raise LabError( + f"{lab.cluster_fqdn} still resolves to {', '.join(sorted(answer)) or 'nothing'} from {lab.vmm.hostname} " + f"after {CLUSTER_DNS_WAIT // 60} minutes, not to the cluster's {', '.join(sorted(addresses))}. The cluster " + "registers its name with one domain controller; the other DNS servers answer for it after directory " + "replication. Run this build item again once the name resolves.") + + def run(job, resource=None, **kwargs): resource = resource or job.resource_set.first() try: lab = scvmm_lab.Lab(resource) + wait_for_cluster_name(lab) log = scvmm_lab.run_task(lab.vmm, ADD_CLUSTER, f"add cluster {lab.cluster_fqdn} to SCVMM", tokens={ "CLUSTER": lab.cluster_fqdn, "RUN_AS": RUN_AS, "USER": lab.username, "PASSWORD": lab.password, }, account=lab.account, hidden=[lab.password], timeout=2700) From aba40d3ffba714e051c9c28d44d4d0edafa7a1d5 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 07:28:36 -0500 Subject: [PATCH 11/22] Retry the local cluster after New-Cluster fails, and destroy the lab cluster at teardown On lab-8, the local Get-Cluster in Create Hyper-V Cluster's fallback did not answer in the moment New-Cluster failed to open the new cluster by name, so the fallback gave up. It now retries for up to 10 minutes and logs why. Windows protects a cluster's computer object from accidental deletion, so the LDAP Utility could not delete hvc-513. The teardown now turns off DNS registration on the running hosts, then runs Remove-Cluster -CleanupAD as the domain account that created the object, and deletes it over LDAP only when it is still there. The lab-7 hosts' DNS records came back after the cleanup action deleted them: their cluster IPs moved while they shut down, and each registered its name again. Co-Authored-By: Claude Opus 5.5 --- CATALOG.md | 4 +- .../BP-9zp8udce/BP-9zp8udce_metadata.json | 2 +- blueprints/BP-9zp8udce/README.md | 12 +- catalog.json | 6 +- orchestration_actions/HPA-q181uofy/README.md | 2 +- plugins/OHK-77f19kly/OHK-77f19kly_script.py | 16 ++- .../OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json | 7 +- plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py | 119 ++++++++++++++---- plugins/README.md | 2 +- shared_modules/README.md | 2 +- 10 files changed, 129 insertions(+), 43 deletions(-) diff --git a/CATALOG.md b/CATALOG.md index 754f6362..5540c38d 100644 --- a/CATALOG.md +++ b/CATALOG.md @@ -381,7 +381,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | OpenShift Project Landing Zone | [OHK-prew0osh](plugins/OHK-prew0osh/) | Creates an OpenShift project with quota, limits, network policies, and an optional role binding, then pins a CloudBolt environment to it. | CloudBolt Plug-in | [OpenShift Project Landing Zone](blueprints/BP-tikkhf2y/README.md) | | Order Counts by Blueprint | [OHK-yjblxbwg](plugins/OHK-yjblxbwg/) | | CloudBolt Plug-in | [Order Counts by Blueprint](mcp_tool_actions/MTA-lp8lgi7e/) | | Prepare SCVMM Lab on AWS | [OHK-q6fb9833](plugins/OHK-q6fb9833/) | Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | -| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](plugins/OHK-kzb6pzzu/) | Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | +| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](plugins/OHK-kzb6pzzu/) | Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Remove Resource Group from Environments | [OHK-vm5p34w3](plugins/OHK-vm5p34w3/) | Removes the deleted resource group's resource_group_arm option from environments on the same subscription. | CloudBolt Plug-in | [Azure Resource Group - Bicep](blueprints/BP-p7zmh96m/README.md) | | Remove Servers from Ansible Automation Platform | [OHK-8v830go3](plugins/OHK-8v830go3/) | Removes the host records a deployment's servers hold in Ansible Automation Platform inventories through CloudBolt's own connector method, before the infrastructure is destroyed; a missing host or unreachable AAP is a warning, never a blocker. | CloudBolt Plug-in | standalone | | Request AKS Namespace Quota Change | [OHK-jeighfcq](plugins/OHK-jeighfcq/) | Moves an AKS namespace landing zone to a different size tier after approval and mirrors the new quota into its environment. | CloudBolt Plug-in | [Request AKS Namespace Quota Change](resource_actions/RSA-7wdigcpr/) | @@ -470,7 +470,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | `openshift_landing_zone` | [SHM-qmiweowv](shared_modules/SHM-qmiweowv/) | OpenShift REST client, size-tier catalog, and environment helpers for the landing-zone blueprint. | [Deploy Test Workload](plugins/OHK-ljgoxser/), [Discover OpenShift Project Landing Zones](plugins/OHK-e7albpni/), [Extend Expiration](plugins/OHK-3w9nejn3/), [Manage Team Access](plugins/OHK-9zzqqz7t/), [OpenShift Project Landing Zone](plugins/OHK-prew0osh/), [Request Quota Change](plugins/OHK-ug53cdbx/), [Teardown OpenShift Project Landing Zone](plugins/OHK-mpe8fl3d/) | | `runbook_tasks` | [SHM-571l7249](shared_modules/SHM-571l7249/) | Finds the Remote Scripts that can run on a VM, checks credentials and task inputs, and runs a chosen script for the Run Task action and its form webhook. | [Run Task](plugins/OHK-o4tgygjs/), [Runbook Tasks](plugins/OHK-bf3iyg9j/), [runbook_workflows](shared_modules/SHM-nznzhpp0/) | | `runbook_workflows` | [SHM-nznzhpp0](shared_modules/SHM-nznzhpp0/) | Stores workflows, works out which workflows and step actions fit a VM or a workflow's filters, builds the run form's prompts, and runs a workflow's steps in order with outputs passed between them, and exports and imports workflows for content packages. | [Run Workflow](plugins/OHK-69gk5ne9/), [Runbook Workflows](plugins/OHK-9ewh41dg/) | -| `scvmm_lab` | [SHM-dpj24dfj](shared_modules/SHM-dpj24dfj/) | Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler. | [Add Hyper-V Cluster to SCVMM](plugins/OHK-ive3ka22/), [Configure Hyper-V Hosts](plugins/OHK-8ioy2cbi/), [Create Hyper-V Cluster](plugins/OHK-77f19kly/), [Install SCVMM](plugins/OHK-8f9o1496/), [Prepare SCVMM Lab on AWS](plugins/OHK-q6fb9833/) | +| `scvmm_lab` | [SHM-dpj24dfj](shared_modules/SHM-dpj24dfj/) | Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler. | [Add Hyper-V Cluster to SCVMM](plugins/OHK-ive3ka22/), [Configure Hyper-V Hosts](plugins/OHK-8ioy2cbi/), [Create Hyper-V Cluster](plugins/OHK-77f19kly/), [Install SCVMM](plugins/OHK-8f9o1496/), [Prepare SCVMM Lab on AWS](plugins/OHK-q6fb9833/), [Remove Hyper-V Cluster Object](plugins/OHK-kzb6pzzu/) | | `servicenow_requests` | [SHM-ww6b1uwj](shared_modules/SHM-ww6b1uwj/) | ServiceNow REQ/RITM client plus the order-summary, catalog-variable, and identifier-storage helpers shared by the ServiceNow request actions. | [ServiceNow Request Approval Sync](plugins/OHK-bsqictlo/), [ServiceNow Request: Close](plugins/OHK-htrxkps2/), [ServiceNow Request: Close on Denial](plugins/OHK-w8exctx7/), [ServiceNow Request: Open](plugins/OHK-o4qmnffy/) | | `tfc_api` | [SHM-jlguerjr](shared_modules/SHM-jlguerjr/) | HCP Terraform REST client and run engine for workspace-per-deployment provisioning. | [Deploy Latest Version](plugins/OHK-4y8f1vff/), [Discover HCP Terraform No-Code Workspaces](plugins/OHK-b1n02ula/), [Form Options](plugins/OHK-fx500o2r/), [Generate options for HCP Terraform coordinates](plugins/OHK-529jjzli/), [HCP Terraform No-Code Module](plugins/OHK-axtt0yqq/), [HCP Terraform VM](plugins/OHK-pvo05e24/), [Resize](plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](plugins/OHK-2b9qu490/), [Terraform Update](plugins/OHK-lvy5tj0y/) | | `vm_adoption` | [SHM-9h13o859](shared_modules/SHM-9h13o859/) | Adopts the VMs a Terraform deployment created (from its cloudbolt_vm_ids output) as CloudBolt Server records under the resource, hydrated through the Azure, AWS, or VMware handler, and retires them on teardown. | [Deploy Latest Version](plugins/OHK-4y8f1vff/), [HCP Terraform No-Code Module](plugins/OHK-axtt0yqq/), [HCP Terraform VM](plugins/OHK-pvo05e24/), [Resize](plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](plugins/OHK-2b9qu490/), [Terraform Update](plugins/OHK-lvy5tj0y/) | diff --git a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json index 7aeadfc7..c1ccc915 100644 --- a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json +++ b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json @@ -210,7 +210,7 @@ "hook": "plugins/OHK-kzb6pzzu" }, "deploy_seq": -1, - "description": "Deletes the cluster's computer object from Active Directory; the servers and the storage volume are deleted with the resource.", + "description": "Destroys the cluster from a running host and deletes its computer object from Active Directory; the servers and the storage volume are deleted with the resource.", "enabled": true, "execute_in_parallel": false, "id": "BDI-w9x43skq", diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 6408d31f..56d1a6d1 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -17,7 +17,7 @@ Every server joins an existing Active Directory domain. The build runs unattende | Build (Plug-in, seq 5) | OHK-8ioy2cbi | Configure Hyper-V Hosts | | Build (Plug-in, seq 6) | OHK-77f19kly | Create Hyper-V Cluster | | Build (Plug-in, seq 7) | OHK-ive3ka22 | Add Hyper-V Cluster to SCVMM | -| Teardown | OHK-kzb6pzzu | Remove Hyper-V Cluster Object | +| Teardown (before the servers are deleted) | OHK-kzb6pzzu | Remove Hyper-V Cluster Object: destroys the cluster with `Remove-Cluster -CleanupAD` on a running host, which deletes its computer object | | Shared module | SHM-dpj24dfj | `scvmm_lab`: guest scripts, scheduled-task steps, EC2 calls | Blueprint parameters, each pinned as its only option, so the order form hides them: @@ -40,7 +40,7 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Domain join content.** Install [PKG-nf407lm5](../../packages/PKG-nf407lm5/) (Join Windows Server to AD Domain), with `domain_ou` and `domain_service_account` set on the AWS environment. Every lab server must get the same `domain_service_account`. That account: - is a member of the local Administrators group on the lab servers, for example through a Group Policy linked to their OU; - has **Create Computer objects** on that OU, for the cluster's computer object. -- **Teardown rights.** The LDAP Utility's account must be able to delete computer objects in that OU. +- **Teardown rights.** The LDAP Utility's account must be able to delete computer objects in that OU. Windows protects the cluster's computer object from accidental deletion, so the teardown deletes it from a host, as the domain service account that created it; the LDAP Utility deletes it only when no host is running and the object is not protected. - **Runbooks package.** [PKG-v20qv308](../../packages/PKG-v20qv308/) provides the `file_archives` shared module that Install SCVMM imports. File Archives itself is needed only when `scvmm_media` names a File Archives file. - **AWS environment.** Windows Server 2025 instances CloudBolt can run scripts on, through SSM (with an instance profile allowing `AmazonSSMManagedInstanceCore`) or through WinRM. - **Security group:** allow all traffic between its own members (a rule whose source is the group itself). @@ -70,13 +70,13 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Scale-up is not supported.** Order a new lab for more hosts. - **Nested VMs** reach the network only through their host's NAT (`192.168.250.0/24`), because EC2 drops frames from unknown MAC addresses. They are not reachable from the VPC. - **SCVMM has no templates, logical networks or IP pools yet.** Add them in the console. -- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item deletes the cluster's computer object. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. +- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object. The cluster name's DNS record stays; the name is unique per lab. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. ### Not yet run live -Domain join through Install SCVMM has run on a live appliance. These have not: -- **Create Hyper-V Cluster and Add Hyper-V Cluster to SCVMM.** +Domain join through Install SCVMM, and New-Cluster itself, have run on a live appliance. These have not: +- **The rest of Create Hyper-V Cluster and Add Hyper-V Cluster to SCVMM.** - **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not move with the core group, keep only the first host's address and pin the group to that host. -- **Deleting the cluster's computer object** at teardown, for a lab whose cluster was created. +- **The teardown's `Remove-Cluster -CleanupAD`.** Deleting the cluster's computer object over LDAP was refused, because Windows protects it. ### Caveats - **SQL Server media download.** The ISO URL in Install SCVMM (`SQL_ISO_URL`) is Microsoft's file, but no Microsoft page documents it, so it can move. diff --git a/catalog.json b/catalog.json index 11bebb85..fa651da0 100644 --- a/catalog.json +++ b/catalog.json @@ -3548,10 +3548,11 @@ "id": "OHK-kzb6pzzu", "type": "plugins", "name": "Remove Hyper-V Cluster Object", - "description": "Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted.", + "description": "Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted.", "path": "plugins/OHK-kzb6pzzu", "readme": null, "uses": [ + "shared_modules/SHM-dpj24dfj", "shared_modules/SHM-gcba1u31" ], "used_by": [ @@ -6083,7 +6084,8 @@ "plugins/OHK-8ioy2cbi", "plugins/OHK-77f19kly", "plugins/OHK-8f9o1496", - "plugins/OHK-q6fb9833" + "plugins/OHK-q6fb9833", + "plugins/OHK-kzb6pzzu" ] }, { diff --git a/orchestration_actions/HPA-q181uofy/README.md b/orchestration_actions/HPA-q181uofy/README.md index f31d0a19..b7cffa06 100644 --- a/orchestration_actions/HPA-q181uofy/README.md +++ b/orchestration_actions/HPA-q181uofy/README.md @@ -20,5 +20,5 @@ Part of [PKG-nf407lm5](../../packages/PKG-nf407lm5/). ## Notes - Imports with `continue_on_failure: true`: an AD error shows in the job without stopping the server's deletion. - DNS records are found only from a computer object it deletes. A server whose object is already gone keeps its records. -- **Untested live:** the DNS record deletion has run only against a simulated directory, not against a domain controller. +- A server registers its name again whenever its addresses change, and it keeps working credentials until it is off. One whose addresses change while it shuts down, such as a failover cluster node whose cluster is still running, gets its record back after this action. Turn off its DNS registration or destroy the cluster first, as the SCVMM lab's teardown does. - CloudBolt's out-of-the-box "Delete Server from LDAP" action matches on name only. Leave it disabled when this action is enabled. diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_script.py b/plugins/OHK-77f19kly/OHK-77f19kly_script.py index d0fa4722..be72badd 100644 --- a/plugins/OHK-77f19kly/OHK-77f19kly_script.py +++ b/plugins/OHK-77f19kly/OHK-77f19kly_script.py @@ -75,11 +75,17 @@ try { New-Cluster -Name $name -Node $nodes -StaticAddress $ips[0] -IgnoreNetwork $natPrefix -NoStorage | Out-Null } catch { - # New-Cluster's last step opens the new cluster by name. - $failure = $_ - $cluster = Lookup { Get-Cluster -ErrorAction Stop } - if (-not $cluster -or $cluster.Name -ne $name) { throw $failure } - Log "Cluster $name is created; its name does not resolve here yet: $($failure.Exception.Message)" + # New-Cluster's last step opens the new cluster by name. The local cluster service can take a + # while longer to answer. + $failure = $_.Exception.Message + $why = '' + $deadline = (Get-Date).AddMinutes(10) + while (-not $cluster -and (Get-Date) -lt $deadline) { + try { $cluster = Get-Cluster -ErrorAction Stop } catch { $why = $_.Exception.Message; Start-Sleep -Seconds 15 } + } + if (-not $cluster) { throw "New-Cluster: $failure The local cluster did not answer for 10 minutes: $why" } + if ($cluster.Name -ne $name) { throw "New-Cluster: $failure $env:COMPUTERNAME is in cluster $($cluster.Name)." } + Log "Cluster $name is created; New-Cluster could not open it by name: $failure" } } $members = @(Get-ClusterNode | ForEach-Object { $_.Name.ToLower() }) diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json index d98dba64..1fdf0229 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json @@ -1,10 +1,11 @@ { "dependencies": { "sharedModules": [ - "shared_modules/SHM-gcba1u31" + "shared_modules/SHM-gcba1u31", + "shared_modules/SHM-dpj24dfj" ] }, - "description": "Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted.", + "description": "Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted.", "id": "OHK-kzb6pzzu", "max_retries": 0, "name": "Remove Hyper-V Cluster Object", @@ -13,4 +14,4 @@ "shared": false, "target_os_families": [], "type": "CloudBolt Plug-in" -} \ No newline at end of file +} diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py index a750ca2c..fbd4835a 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py @@ -1,29 +1,98 @@ """ Remove Hyper-V Cluster Object -Teardown item of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce). -Create Hyper-V Cluster made a computer object for the cluster name (the CNO) -in the hosts' OU. This deletes it over LDAP with the LDAP Utility that serves -the lab's domain, the same utility Join Windows Server to AD Domain joins with, -through the ad_domain shared module (shared_modules/SHM-gcba1u31). The -servers' own computer objects are left to Delete Windows Computer Object from -AD (HPA-q181uofy), and the servers and the storage volume are deleted with -the resource. +Teardown item of the SCVMM Lab on AWS blueprint (blueprints/BP-9zp8udce). It +runs before CloudBolt deletes the lab's servers (deploy_seq -1). Create +Hyper-V Cluster made a computer object for the cluster name (the CNO) in the +hosts' OU, and Windows protects that object from accidental deletion, so the +LDAP Utility is refused when it deletes it. + + 1. Turn off DNS registration on every running host. A host registers its + name again whenever its addresses change, and cluster IP addresses move + when the cluster is destroyed or a node shuts down; its record would + then outlive the cleanup Delete Windows Computer Object from AD does + before CloudBolt deletes it. + 2. While a host is running, destroy the cluster from it with + Remove-Cluster -CleanupAD, as a scheduled task signed in as the domain + service account. That account created the CNO, and -CleanupAD deletes + it with the cluster. + 3. When the CNO is still there, delete it over LDAP with the LDAP Utility + that serves the lab's domain, the same utility Join Windows Server to AD + Domain joins with, through the ad_domain shared module + (shared_modules/SHM-gcba1u31). + +The servers' own computer objects are left to Delete Windows Computer Object +from AD (HPA-q181uofy), and the servers and the storage volume are deleted +with the resource. Idempotent: a lab that never got a cluster, or a CNO that is already gone, ends with SUCCESS; a CNO that cannot be deleted ends with WARNING so the rest of the delete goes on. CloudBolt renders this file as a template before running it, so it must never -contain template tags. +contain template tags; values reach the script through the __CB_*__ tokens. + +References: + Set-DnsClient: https://learn.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclient + Remove-Cluster: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/remove-cluster + CNO protected from accidental delete: https://learn.microsoft.com/en-us/troubleshoot/windows-server/high-availability/event-id-1222-create-failover-cluster """ from common.methods import set_progress from utilities.logger import ThreadLogger -from shared_modules import ad_domain +from shared_modules import ad_domain, scvmm_lab +from shared_modules.scvmm_lab import LabError logger = ThreadLogger(__name__) +DNS_OFF = r""" + Get-DnsClient | Where-Object { $_.RegisterThisConnectionsAddress } | ForEach-Object { + Set-DnsClient -InterfaceIndex $_.InterfaceIndex -RegisterThisConnectionsAddress $false + } +""" + +REMOVE_CLUSTER = r""" + Import-Module FailoverClusters + $name = Decode '__CB_NAME__' + $cluster = Lookup { Get-Cluster -ErrorAction Stop } + if (-not $cluster) { + Log "$env:COMPUTERNAME is in no cluster" + } elseif ($cluster.Name -ne $name) { + throw "$env:COMPUTERNAME is in cluster $($cluster.Name), not $name." + } else { + Log "Destroying cluster $name and deleting its Active Directory objects" + Remove-Cluster -Force -CleanupAD + Log "Destroyed cluster $name" + } +""" + + +def destroy_cluster(resource, name): + """ + Turn off DNS registration on the running hosts, then run + Remove-Cluster -CleanupAD on the first of them. Returns a note for the + job's output. + """ + try: + lab = scvmm_lab.Lab(resource) + except LabError as err: + return f"Remove-Cluster was not run: {err}" + running = [host for host in lab.hosts if host.power_status == "POWERON"] + if not running: + return "Remove-Cluster was not run: no host is running." + for host in running: + try: + scvmm_lab.run_ps(host, DNS_OFF) + set_progress(f"{host.hostname}: DNS registration turned off") + except LabError as err: + set_progress(f"{host.hostname}: could not turn off DNS registration: {err}") + try: + scvmm_lab.run_task(running[0], REMOVE_CLUSTER, f"destroy cluster {name}", tokens={"NAME": name}, + account=lab.account, timeout=900) + except LabError as err: + return f"Remove-Cluster failed: {err}" + return f"Destroyed cluster {name} on {running[0].hostname}." + def run(job, resource=None, **kwargs): resource = resource or job.resource_set.first() @@ -32,29 +101,37 @@ def run(job, resource=None, **kwargs): if not cluster or not domain: return "SUCCESS", "The lab has no cluster recorded; no computer object to delete.", "" name = cluster.split(".")[0] + note = destroy_cluster(resource, name) + set_progress(note) matches = [u for u in ad_domain.utilities() if ad_domain.utility_domain(u) == domain] if len(matches) != 1: - return "WARNING", "", (f"{len(matches)} LDAP Utilities serve {domain}, so the computer object of cluster " - f"{name} was not deleted. Delete it in Active Directory.") + return "WARNING", note, (f"{len(matches)} LDAP Utilities serve {domain}, so the computer object of " + f"cluster {name} was not checked. Delete it in Active Directory if it is there.") + dn = "" try: conn = ad_domain.connect(matches[0]) try: found = ad_domain.find_computers(conn, ad_domain.search_base(matches[0], conn), name=name) if not found: - return "SUCCESS", f"Cluster {name} has no computer object in {domain}; nothing to delete.", "" + return "SUCCESS", f"{note} Cluster {name} has no computer object left in {domain}.", "" if len(found) > 1: - return "WARNING", "", f"Found several computer objects named {name} in {domain}; none was deleted." + return "WARNING", note, f"Found several computer objects named {name} in {domain}; none was deleted." + dn = found[0]["dn"] dns_name = (found[0]["dns_host_name"] or "").lower() if dns_name and dns_name != cluster: - return "WARNING", "", (f"Computer object {found[0]['dn']} has DNS name {dns_name}, not {cluster}; " - "it was not deleted.") - set_progress(f"Deleting {found[0]['dn']}") - ad_domain.delete_entry(conn, found[0]["dn"]) + return "WARNING", note, (f"Computer object {dn} has DNS name {dns_name}, not {cluster}; " + "it was not deleted.") + set_progress(f"Deleting {dn}") + ad_domain.delete_entry(conn, dn) finally: conn.unbind_s() + except ad_domain.ldap.INSUFFICIENT_ACCESS: + return "WARNING", note, (f"The LDAP Utility may not delete {dn}: Windows protects a cluster's computer " + "object from accidental deletion. Clear Protect from accidental deletion on it " + "in Active Directory Administrative Center, then delete it.") except Exception as err: logger.exception("Deleting the computer object of cluster %s failed", name) - return "WARNING", "", (f"Could not delete the computer object of cluster {name}: {err}. The LDAP Utility's " - "account needs the right to delete computer objects in the hosts' OU.") - return "SUCCESS", f"Deleted the computer object of cluster {name} from {domain}.", "" + return "WARNING", note, (f"Could not delete the computer object of cluster {name}: {err}. The LDAP " + "Utility's account needs the right to delete computer objects in the hosts' OU.") + return "SUCCESS", f"{note} Deleted the computer object of cluster {name} from {domain}.", "" diff --git a/plugins/README.md b/plugins/README.md index 48ba3fd5..ffce8500 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -148,7 +148,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | OpenShift Project Landing Zone | [OHK-prew0osh](OHK-prew0osh/) | Creates an OpenShift project with quota, limits, network policies, and an optional role binding, then pins a CloudBolt environment to it. | CloudBolt Plug-in | [OpenShift Project Landing Zone](../blueprints/BP-tikkhf2y/README.md) | | Order Counts by Blueprint | [OHK-yjblxbwg](OHK-yjblxbwg/) | | CloudBolt Plug-in | [Order Counts by Blueprint](../mcp_tool_actions/MTA-lp8lgi7e/) | | Prepare SCVMM Lab on AWS | [OHK-q6fb9833](OHK-q6fb9833/) | Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | -| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](OHK-kzb6pzzu/) | Deletes the SCVMM lab cluster's computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | +| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](OHK-kzb6pzzu/) | Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Remove Resource Group from Environments | [OHK-vm5p34w3](OHK-vm5p34w3/) | Removes the deleted resource group's resource_group_arm option from environments on the same subscription. | CloudBolt Plug-in | [Azure Resource Group - Bicep](../blueprints/BP-p7zmh96m/README.md) | | Remove Servers from Ansible Automation Platform | [OHK-8v830go3](OHK-8v830go3/) | Removes the host records a deployment's servers hold in Ansible Automation Platform inventories through CloudBolt's own connector method, before the infrastructure is destroyed; a missing host or unreachable AAP is a warning, never a blocker. | CloudBolt Plug-in | standalone | | Request AKS Namespace Quota Change | [OHK-jeighfcq](OHK-jeighfcq/) | Moves an AKS namespace landing zone to a different size tier after approval and mirrors the new quota into its environment. | CloudBolt Plug-in | [Request AKS Namespace Quota Change](../resource_actions/RSA-7wdigcpr/) | diff --git a/shared_modules/README.md b/shared_modules/README.md index f504eace..0de82751 100644 --- a/shared_modules/README.md +++ b/shared_modules/README.md @@ -26,7 +26,7 @@ Reusable Python libraries imported by plugins as `shared_modules.`. A modu | `openshift_landing_zone` | [SHM-qmiweowv](SHM-qmiweowv/) | OpenShift REST client, size-tier catalog, and environment helpers for the landing-zone blueprint. | [Deploy Test Workload](../plugins/OHK-ljgoxser/), [Discover OpenShift Project Landing Zones](../plugins/OHK-e7albpni/), [Extend Expiration](../plugins/OHK-3w9nejn3/), [Manage Team Access](../plugins/OHK-9zzqqz7t/), [OpenShift Project Landing Zone](../plugins/OHK-prew0osh/), [Request Quota Change](../plugins/OHK-ug53cdbx/), [Teardown OpenShift Project Landing Zone](../plugins/OHK-mpe8fl3d/) | | `runbook_tasks` | [SHM-571l7249](SHM-571l7249/) | Finds the Remote Scripts that can run on a VM, checks credentials and task inputs, and runs a chosen script for the Run Task action and its form webhook. | [Run Task](../plugins/OHK-o4tgygjs/), [Runbook Tasks](../plugins/OHK-bf3iyg9j/), [runbook_workflows](SHM-nznzhpp0/) | | `runbook_workflows` | [SHM-nznzhpp0](SHM-nznzhpp0/) | Stores workflows, works out which workflows and step actions fit a VM or a workflow's filters, builds the run form's prompts, and runs a workflow's steps in order with outputs passed between them, and exports and imports workflows for content packages. | [Run Workflow](../plugins/OHK-69gk5ne9/), [Runbook Workflows](../plugins/OHK-9ewh41dg/) | -| `scvmm_lab` | [SHM-dpj24dfj](SHM-dpj24dfj/) | Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler. | [Add Hyper-V Cluster to SCVMM](../plugins/OHK-ive3ka22/), [Configure Hyper-V Hosts](../plugins/OHK-8ioy2cbi/), [Create Hyper-V Cluster](../plugins/OHK-77f19kly/), [Install SCVMM](../plugins/OHK-8f9o1496/), [Prepare SCVMM Lab on AWS](../plugins/OHK-q6fb9833/) | +| `scvmm_lab` | [SHM-dpj24dfj](SHM-dpj24dfj/) | Runs the SCVMM Lab on AWS blueprint's guest steps as marker-reporting PowerShell or polled scheduled tasks, and its EC2 steps (nested virtualization, cluster IPs, storage volume) through the AWS handler. | [Add Hyper-V Cluster to SCVMM](../plugins/OHK-ive3ka22/), [Configure Hyper-V Hosts](../plugins/OHK-8ioy2cbi/), [Create Hyper-V Cluster](../plugins/OHK-77f19kly/), [Install SCVMM](../plugins/OHK-8f9o1496/), [Prepare SCVMM Lab on AWS](../plugins/OHK-q6fb9833/), [Remove Hyper-V Cluster Object](../plugins/OHK-kzb6pzzu/) | | `servicenow_requests` | [SHM-ww6b1uwj](SHM-ww6b1uwj/) | ServiceNow REQ/RITM client plus the order-summary, catalog-variable, and identifier-storage helpers shared by the ServiceNow request actions. | [ServiceNow Request Approval Sync](../plugins/OHK-bsqictlo/), [ServiceNow Request: Close](../plugins/OHK-htrxkps2/), [ServiceNow Request: Close on Denial](../plugins/OHK-w8exctx7/), [ServiceNow Request: Open](../plugins/OHK-o4qmnffy/) | | `tfc_api` | [SHM-jlguerjr](SHM-jlguerjr/) | HCP Terraform REST client and run engine for workspace-per-deployment provisioning. | [Deploy Latest Version](../plugins/OHK-4y8f1vff/), [Discover HCP Terraform No-Code Workspaces](../plugins/OHK-b1n02ula/), [Form Options](../plugins/OHK-fx500o2r/), [Generate options for HCP Terraform coordinates](../plugins/OHK-529jjzli/), [HCP Terraform No-Code Module](../plugins/OHK-axtt0yqq/), [HCP Terraform VM](../plugins/OHK-pvo05e24/), [Resize](../plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](../plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](../plugins/OHK-2b9qu490/), [Terraform Update](../plugins/OHK-lvy5tj0y/) | | `vm_adoption` | [SHM-9h13o859](SHM-9h13o859/) | Adopts the VMs a Terraform deployment created (from its cloudbolt_vm_ids output) as CloudBolt Server records under the resource, hydrated through the Azure, AWS, or VMware handler, and retires them on teardown. | [Deploy Latest Version](../plugins/OHK-4y8f1vff/), [HCP Terraform No-Code Module](../plugins/OHK-axtt0yqq/), [HCP Terraform VM](../plugins/OHK-pvo05e24/), [Resize](../plugins/OHK-9xffkz53/), [Teardown HCP Terraform No-Code Module](../plugins/OHK-y9d1uwhw/), [Teardown HCP Terraform VM](../plugins/OHK-2b9qu490/), [Terraform Update](../plugins/OHK-lvy5tj0y/) | From 169983528850bf0cc4bd844071bd632f8869666d Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 08:07:59 -0500 Subject: [PATCH 12/22] Say when the teardown found no cluster instead of claiming it destroyed one Lab-9 was canceled before Create Hyper-V Cluster, and its teardown reported "Destroyed cluster hvc-515". The script now marks whether it ran Remove-Cluster, and the note says the host is in no cluster otherwise. Also updates the blueprint README's list of what has not run live. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 7 +++---- plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py | 12 +++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 56d1a6d1..209be2f0 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -73,10 +73,9 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object. The cluster name's DNS record stays; the name is unique per lab. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. ### Not yet run live -Domain join through Install SCVMM, and New-Cluster itself, have run on a live appliance. These have not: -- **The rest of Create Hyper-V Cluster and Add Hyper-V Cluster to SCVMM.** -- **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not move with the core group, keep only the first host's address and pin the group to that host. -- **The teardown's `Remove-Cluster -CleanupAD`.** Deleting the cluster's computer object over LDAP was refused, because Windows protects it. +Everything through Create Hyper-V Cluster, and the teardown, have run on a live appliance. These have not: +- **Add Hyper-V Cluster to SCVMM**, and New-Cluster carrying on after it cannot open the new cluster by name. +- **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. Failing the core group over to another host is untested. If the cluster name does not come online there, keep only the first host's address and pin the group to that host. ### Caveats - **SQL Server media download.** The ISO URL in Install SCVMM (`SQL_ISO_URL`) is Microsoft's file, but no Microsoft page documents it, so it can move. diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py index fbd4835a..dccfe375 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py @@ -56,13 +56,13 @@ $name = Decode '__CB_NAME__' $cluster = Lookup { Get-Cluster -ErrorAction Stop } if (-not $cluster) { - Log "$env:COMPUTERNAME is in no cluster" + Mark 'DESTROYED' 'none' } elseif ($cluster.Name -ne $name) { throw "$env:COMPUTERNAME is in cluster $($cluster.Name), not $name." } else { Log "Destroying cluster $name and deleting its Active Directory objects" Remove-Cluster -Force -CleanupAD - Log "Destroyed cluster $name" + Mark 'DESTROYED' $name } """ @@ -87,11 +87,13 @@ def destroy_cluster(resource, name): except LabError as err: set_progress(f"{host.hostname}: could not turn off DNS registration: {err}") try: - scvmm_lab.run_task(running[0], REMOVE_CLUSTER, f"destroy cluster {name}", tokens={"NAME": name}, - account=lab.account, timeout=900) + log = scvmm_lab.run_task(running[0], REMOVE_CLUSTER, f"destroy cluster {name}", tokens={"NAME": name}, + account=lab.account, timeout=900) except LabError as err: return f"Remove-Cluster failed: {err}" - return f"Destroyed cluster {name} on {running[0].hostname}." + if scvmm_lab.markers(log).get("DESTROYED") == name: + return f"Destroyed cluster {name} on {running[0].hostname}." + return f"{running[0].hostname} is in no cluster." def run(job, resource=None, **kwargs): From be5a04c8e542d4a74b3398b0271cc656153a6a1f Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 08:45:38 -0500 Subject: [PATCH 13/22] Point every Create Hyper-V Cluster cmdlet at this host, not the cluster name On lab-10, New-Cluster succeeded and the next cmdlet, Get-ClusterNode with no -Cluster, failed with "An error occurred opening cluster 'hvc-528'" (event 4657 in FailoverClustering-Manager/Admin): without a cluster argument the cmdlets open the local cluster by its name, which does not resolve yet. OpenCluster accepts a node name, and the cmdlets work through it while the name does not resolve, so every cmdlet now passes -Cluster $env:COMPUTERNAME. After New-Cluster, success or not, the item waits up to 10 minutes for the cluster to answer on this host. Co-Authored-By: Claude Opus 5.5 --- plugins/OHK-77f19kly/OHK-77f19kly_script.py | 72 +++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_script.py b/plugins/OHK-77f19kly/OHK-77f19kly_script.py index be72badd..f268758d 100644 --- a/plugins/OHK-77f19kly/OHK-77f19kly_script.py +++ b/plugins/OHK-77f19kly/OHK-77f19kly_script.py @@ -14,10 +14,12 @@ the first host's secondary private IP as its address, ignoring the NAT network. Add any host the cluster is missing. The cluster registers its name with one domain controller, and the name resolves elsewhere only - after directory replication, so every step works on the local cluster - rather than on its name. New-Cluster's own last step opens the cluster - by name; when only that fails, the cluster is there and the item goes - on. Add Hyper-V Cluster to SCVMM waits for the name. + after directory replication. A cluster cmdlet given no cluster, or the + cluster's name, opens the cluster by that name, so every cmdlet here + names this host instead, which the cluster API accepts. New-Cluster's + own last step opens the cluster by name; when only that fails, the + cluster is there and the item goes on. Add Hyper-V Cluster to SCVMM + waits for the name. 2. Give the core network name one IP address resource per host, each host's secondary private IP, possible owner that host only, joined by an OR dependency. EC2 delivers an address only to the interface it is @@ -39,6 +41,7 @@ References: New-Cluster: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/new-cluster + OpenCluster, node name allowed: https://learn.microsoft.com/en-us/windows/win32/api/clusapi/nf-clusapi-opencluster Add-ClusterNode: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clusternode Add-ClusterResource: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clusterresource Set-ClusterParameter: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterparameter?view=windowsserver2019-ps @@ -66,64 +69,65 @@ $natPrefix = Decode '__CB_NAT_PREFIX__' $natAddress = ($natPrefix -split '/')[0] - # The cmdlets below work on the local cluster, not on its name: the name resolves only once its DNS - # record reaches the DNS servers this host uses. - $cluster = Lookup { Get-Cluster -ErrorAction Stop } + # Every cmdlet names this host as its cluster. Given no cluster, or the cluster's name, a cmdlet opens the + # cluster by name, which fails until the name's DNS record reaches the DNS servers this host uses. + $target = $env:COMPUTERNAME + $cluster = Lookup { Get-Cluster -Name $target -ErrorAction Stop } if ($cluster -and $cluster.Name -ne $name) { throw "$env:COMPUTERNAME is already in cluster $($cluster.Name)." } if (-not $cluster) { Log "Creating cluster $name on $($nodes -join ', ') with address $($ips[0])" + $failure = '' try { New-Cluster -Name $name -Node $nodes -StaticAddress $ips[0] -IgnoreNetwork $natPrefix -NoStorage | Out-Null } catch { - # New-Cluster's last step opens the new cluster by name. The local cluster service can take a - # while longer to answer. + # Its last step opens the new cluster by name. $failure = $_.Exception.Message - $why = '' - $deadline = (Get-Date).AddMinutes(10) - while (-not $cluster -and (Get-Date) -lt $deadline) { - try { $cluster = Get-Cluster -ErrorAction Stop } catch { $why = $_.Exception.Message; Start-Sleep -Seconds 15 } - } - if (-not $cluster) { throw "New-Cluster: $failure The local cluster did not answer for 10 minutes: $why" } - if ($cluster.Name -ne $name) { throw "New-Cluster: $failure $env:COMPUTERNAME is in cluster $($cluster.Name)." } - Log "Cluster $name is created; New-Cluster could not open it by name: $failure" } + $why = '' + $deadline = (Get-Date).AddMinutes(10) + while (-not $cluster -and (Get-Date) -lt $deadline) { + try { $cluster = Get-Cluster -Name $target -ErrorAction Stop } catch { $why = $_.Exception.Message; Start-Sleep -Seconds 15 } + } + if (-not $cluster) { throw "New-Cluster: $failure The cluster did not answer on $target for 10 minutes: $why" } + if ($cluster.Name -ne $name) { throw "$env:COMPUTERNAME is in cluster $($cluster.Name), not $name." } + Log "Cluster $name is created$(if ($failure) { "; New-Cluster could not open it by name: $failure" })" } - $members = @(Get-ClusterNode | ForEach-Object { $_.Name.ToLower() }) + $members = @(Get-ClusterNode -Cluster $target | ForEach-Object { $_.Name.ToLower() }) foreach ($node in $nodes) { if ($members -notcontains $node.ToLower()) { Log "Adding node $node" - Add-ClusterNode -Name $node -NoStorage | Out-Null + Add-ClusterNode -Cluster $target -Name $node -NoStorage | Out-Null } } - $nat = Get-ClusterNetwork | Where-Object { $_.Address -eq $natAddress } + $nat = Get-ClusterNetwork -Cluster $target | Where-Object { $_.Address -eq $natAddress } foreach ($n in $nat) { if ($n.Role -ne 0) { $n.Role = 0; Log "Cluster network $($n.Name) ($natPrefix) set to no cluster traffic" } } - $network = Get-ClusterNetwork | Where-Object { $_.Address -ne $natAddress -and $_.Role -ne 0 } | Select-Object -First 1 + $network = Get-ClusterNetwork -Cluster $target | Where-Object { $_.Address -ne $natAddress -and $_.Role -ne 0 } | Select-Object -First 1 if (-not $network) { throw 'The cluster has no network for its IP addresses.' } - $core = Get-ClusterResource | Where-Object { $_.OwnerGroup -eq 'Cluster Group' } + $core = Get-ClusterResource -Cluster $target | Where-Object { $_.OwnerGroup -eq 'Cluster Group' } $nameResource = $core | Where-Object { $_.ResourceType -eq 'Network Name' } | Select-Object -First 1 $ipResources = @() for ($i = 0; $i -lt $nodes.Count; $i++) { $resource = $core | Where-Object { $_.ResourceType -eq 'IP Address' } | Where-Object { (Get-ClusterParameter -InputObject $_ -Name Address).Value -eq $ips[$i] } | Select-Object -First 1 if (-not $resource) { - $resource = Add-ClusterResource -Name "Cluster IP Address $($ips[$i])" -ResourceType 'IP Address' -Group 'Cluster Group' + $resource = Add-ClusterResource -Cluster $target -Name "Cluster IP Address $($ips[$i])" -ResourceType 'IP Address' -Group 'Cluster Group' $resource | Set-ClusterParameter -Multiple @{ Address = $ips[$i]; SubnetMask = $network.AddressMask; Network = $network.Name; EnableDhcp = 0 } Log "Added IP address resource $($ips[$i]) for $($nodes[$i])" } - Set-ClusterOwnerNode -Resource $resource.Name -Owners $nodes[$i] | Out-Null + Set-ClusterOwnerNode -Cluster $target -Resource $resource.Name -Owners $nodes[$i] | Out-Null $ipResources += $resource.Name } $expression = ($ipResources | ForEach-Object { "[$_]" }) -join ' or ' - Set-ClusterResourceDependency -Resource $nameResource.Name -Dependency $expression | Out-Null - Start-ClusterGroup -Name 'Cluster Group' | Out-Null - $settings = Get-Cluster + Set-ClusterResourceDependency -Cluster $target -Resource $nameResource.Name -Dependency $expression | Out-Null + Start-ClusterGroup -Cluster $target -Name 'Cluster Group' | Out-Null + $settings = Get-Cluster -Name $target if ($settings.SameSubnetThreshold -lt 10) { $settings.SameSubnetThreshold = 10 } $witnessName = 'CBLab Witness' $csvName = 'CBLab CSV' - $diskResources = @(Get-ClusterResource | Where-Object { $_.ResourceType -eq 'Physical Disk' } | ForEach-Object { $_.Name }) + $diskResources = @(Get-ClusterResource -Cluster $target | Where-Object { $_.ResourceType -eq 'Physical Disk' } | ForEach-Object { $_.Name }) # The smaller iSCSI disk (1 GB) is the witness, the larger the cluster shared volume. $iscsi = @(Get-Disk | Where-Object { $_.BusType -eq 'iSCSI' } | Sort-Object Size) $plan = @( @@ -141,19 +145,19 @@ New-Partition -DiskNumber $disk.Number -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel $item.Label -Confirm:$false | Out-Null Log "Formatted iSCSI disk $($disk.Number) ($([math]::Round($disk.Size / 1GB)) GB) as $($item.Label)" } - $available = Get-ClusterAvailableDisk -Disk (Get-Disk -Number $disk.Number) + $available = Get-ClusterAvailableDisk -Cluster $target -Disk (Get-Disk -Number $disk.Number) if (-not $available) { throw "iSCSI disk $($disk.Number) cannot be added to the cluster; check every host sees it." } $added = $available | Add-ClusterDisk $added.Name = $item.Resource Log "Added cluster disk $($item.Resource)" } - if ((Get-ClusterQuorum).QuorumResource.Name -ne $witnessName) { - Set-ClusterQuorum -DiskWitness $witnessName | Out-Null + if ((Get-ClusterQuorum -Cluster $target).QuorumResource.Name -ne $witnessName) { + Set-ClusterQuorum -Cluster $target -DiskWitness $witnessName | Out-Null } - $csv = Lookup { Get-ClusterSharedVolume -Name $csvName -ErrorAction Stop } - if (-not $csv) { $csv = Add-ClusterSharedVolume -Name $csvName } + $csv = Lookup { Get-ClusterSharedVolume -Cluster $target -Name $csvName -ErrorAction Stop } + if (-not $csv) { $csv = Add-ClusterSharedVolume -Cluster $target -Name $csvName } Mark 'CSV_PATH' $csv.SharedVolumeInfo.FriendlyVolumeName - Mark 'OWNER' (Get-ClusterGroup -Name 'Cluster Group').OwnerNode.Name + Mark 'OWNER' (Get-ClusterGroup -Cluster $target -Name 'Cluster Group').OwnerNode.Name """ From 498fa84c9af3c71ee36dbc5894b406013c65bdf3 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 08:54:19 -0500 Subject: [PATCH 14/22] Look up the lab cluster in SCVMM by listing clusters, not Get-SCVMHostCluster -Name On lab-10, Get-SCVMHostCluster -Name threw "A cluster with the name 'hvc-528.' does not exist" for a cluster SCVMM did not manage yet, so Add Hyper-V Cluster to SCVMM failed before adding it. It now lists the clusters and matches the FQDN or the short name. Co-Authored-By: Claude Opus 5.5 --- plugins/OHK-ive3ka22/OHK-ive3ka22_script.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py index f54e039f..409f651f 100644 --- a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py +++ b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py @@ -47,6 +47,7 @@ Import-Module VirtualMachineManager $vmm = Get-SCVMMServer -ComputerName $env:COMPUTERNAME $clusterName = Decode '__CB_CLUSTER__' + $shortName = ($clusterName -split '\.')[0] $runAsName = Decode '__CB_RUN_AS__' $runAs = Get-SCRunAsAccount -VMMServer $vmm -Name $runAsName if (-not $runAs) { @@ -55,12 +56,13 @@ $runAs = New-SCRunAsAccount -VMMServer $vmm -Name $runAsName -Credential $credential -Description 'Domain service account of the CloudBolt SCVMM lab; local administrator on every Hyper-V host.' Log "Created Run As account $runAsName" } - $cluster = Get-SCVMHostCluster -VMMServer $vmm -Name $clusterName + # Get-SCVMHostCluster -Name throws for a cluster SCVMM does not manage, so list them and match the name. + $cluster = Get-SCVMHostCluster -VMMServer $vmm | Where-Object { $_.Name -in $clusterName, $shortName } | Select-Object -First 1 if (-not $cluster) { $allHosts = Get-SCVMHostGroup -VMMServer $vmm | Where-Object { $_.Path -eq 'All Hosts' } Log "Adding cluster $clusterName to All Hosts" Add-SCVMHostCluster -VMMServer $vmm -Name $clusterName -VMHostGroup $allHosts -Credential $runAs | Out-Null - $cluster = Get-SCVMHostCluster -VMMServer $vmm -Name $clusterName + $cluster = Get-SCVMHostCluster -VMMServer $vmm | Where-Object { $_.Name -in $clusterName, $shortName } | Select-Object -First 1 } if (-not $cluster) { throw "SCVMM does not list cluster $clusterName after Add-SCVMHostCluster." } $nodes = @($cluster.Nodes) From 3a1011bfd55262259852c2f7c948dccaf067f456 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:04:42 -0500 Subject: [PATCH 15/22] Give the SCVMM Run As account DOMAIN\user, not user@domain On lab-10, SCVMM's "Discover clusters and their nodes" failed with AMHostAccessDenied. hvlab-003's Security log showed why: event 4625, NTLM logon for user "user@" in domain "localhost", no such user. SCVMM treats a user@domain name as a local account. Add Hyper-V Cluster to SCVMM now resolves the account to DOMAIN\user through its SID, and corrects a Run As account it made earlier with the other form. Co-Authored-By: Claude Opus 5.5 --- plugins/OHK-ive3ka22/OHK-ive3ka22_script.py | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py index 409f651f..add45ef0 100644 --- a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py +++ b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py @@ -12,9 +12,11 @@ the zone from other domain controllers answer for it only after directory replication, and a resolver that cached "no such name" keeps answering that until the cached answer expires. - 1. Create the Run As account RUN_AS for the domain service account, unless - it exists. SCVMM uses it to install its agent on every node; it must be - a domain account in each node's local Administrators group. + 1. Create the Run As account RUN_AS for the domain service account, in + DOMAIN\\user form, or correct it when it exists with another user name. + SCVMM uses it to install its agent on every node; it must be a domain + account in each node's local Administrators group. Given a user@domain + name, SCVMM signs in to the nodes with it as a local account. 2. Add the cluster to the All Hosts group with Add-SCVMHostCluster, unless SCVMM already manages it, and report each node's state. @@ -29,6 +31,7 @@ Ports and protocols: https://learn.microsoft.com/en-us/system-center/vmm/plan-ports-protocols?view=sc-vmm-2025 Get-SCVMMServer: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmmserver?view=systemcenter-ps-2025 New-SCRunAsAccount: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/new-scrunasaccount?view=systemcenter-ps-2025 + Set-SCRunAsAccount: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/set-scrunasaccount?view=systemcenter-ps-2025 Get-SCVMHostGroup: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmhostgroup?view=systemcenter-ps-2025 Add-SCVMHostCluster: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/add-scvmhostcluster?view=systemcenter-ps-2025 Get-SCVMHostCluster: https://learn.microsoft.com/en-us/powershell/module/virtualmachinemanager/get-scvmhostcluster?view=systemcenter-ps-2025 @@ -49,12 +52,19 @@ $clusterName = Decode '__CB_CLUSTER__' $shortName = ($clusterName -split '\.')[0] $runAsName = Decode '__CB_RUN_AS__' + # SCVMM signs in with a user@domain name as a local account of that name (event 4625, domain localhost), + # so the Run As account gets DOMAIN\user, resolved through the account's SID. + $sid = (New-Object Security.Principal.NTAccount (Decode '__CB_USER__')).Translate([Security.Principal.SecurityIdentifier]) + $user = $sid.Translate([Security.Principal.NTAccount]).Value + $secret = ConvertTo-SecureString -String (Decode '__CB_PASSWORD__') -AsPlainText -Force + $credential = New-Object System.Management.Automation.PSCredential -ArgumentList $user, $secret $runAs = Get-SCRunAsAccount -VMMServer $vmm -Name $runAsName if (-not $runAs) { - $secret = ConvertTo-SecureString -String (Decode '__CB_PASSWORD__') -AsPlainText -Force - $credential = New-Object System.Management.Automation.PSCredential -ArgumentList (Decode '__CB_USER__'), $secret $runAs = New-SCRunAsAccount -VMMServer $vmm -Name $runAsName -Credential $credential -Description 'Domain service account of the CloudBolt SCVMM lab; local administrator on every Hyper-V host.' - Log "Created Run As account $runAsName" + Log "Created Run As account $runAsName for $user" + } elseif ("$($runAs.Domain)\$($runAs.UserName)" -ne $user) { + $runAs = Set-SCRunAsAccount -RunAsAccount $runAs -Credential $credential + Log "Run As account $runAsName now signs in as $user" } # Get-SCVMHostCluster -Name throws for a cluster SCVMM does not manage, so list them and match the name. $cluster = Get-SCVMHostCluster -VMMServer $vmm | Where-Object { $_.Name -in $clusterName, $shortName } | Select-Object -First 1 From 05114deab32ee8dc4f4a2ec0118a19aa847bb417 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:22:17 -0500 Subject: [PATCH 16/22] Accept an SCVMM add that reports an error when every node is managed and responding On lab-10, Add-SCVMHostCluster installed the SCVMM agent on both hosts and SCVMM lists the cluster with both nodes OK and Responding, but the add job failed: SCVMM's BITS endpoint answered HTTP 500 (0x801901F4) when copying the DHCP server extension, DHCPExtn.msi, to the hosts. Add Hyper-V Cluster to SCVMM now ends with WARNING and SCVMM's message in that case, and still fails when a node is not responding. The README notes the caveat. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 1 + plugins/OHK-ive3ka22/OHK-ive3ka22_script.py | 28 +++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 209be2f0..4835d535 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -78,6 +78,7 @@ Everything through Create Hyper-V Cluster, and the teardown, have run on a live - **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. Failing the core group over to another host is untested. If the cluster name does not come online there, keep only the first host's address and pin the group to that host. ### Caveats +- **SCVMM's DHCP server extension.** On the test lab, SCVMM installed its agent on both hosts, but its BITS endpoint answered HTTP 500 when copying the DHCP server extension (`DHCPExtn.msi`) to them, so the add job failed. Add Hyper-V Cluster to SCVMM then ends with a warning that quotes SCVMM's message. The cluster and its nodes are managed. The extension is needed only for SCVMM-managed DHCP on virtual networks. - **SQL Server media download.** The ISO URL in Install SCVMM (`SQL_ISO_URL`) is Microsoft's file, but no Microsoft page documents it, so it can move. - **SQL Server edition.** SCVMM 2025 lists Standard, Enterprise and Datacenter. Developer is the Enterprise engine, for test use only. - **SCSI-3 persistent reservations** on the iSCSI target are not validated: `Test-Cluster` is not run. Run cluster validation in Failover Cluster Manager for a supported configuration. diff --git a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py index add45ef0..15e754c4 100644 --- a/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py +++ b/plugins/OHK-ive3ka22/OHK-ive3ka22_script.py @@ -18,7 +18,11 @@ account in each node's local Administrators group. Given a user@domain name, SCVMM signs in to the nodes with it as a local account. 2. Add the cluster to the All Hosts group with Add-SCVMHostCluster, unless - SCVMM already manages it, and report each node's state. + SCVMM already manages it, and report each node's state. When the add + job fails but SCVMM lists the cluster with every node responding, the + item ends with WARNING and SCVMM's message: on the test lab, the agent + installed and only the copy of the DHCP server extension to the hosts + failed (HTTP 500 from SCVMM's BITS endpoint). Re-running it after a success changes nothing. @@ -68,16 +72,26 @@ } # Get-SCVMHostCluster -Name throws for a cluster SCVMM does not manage, so list them and match the name. $cluster = Get-SCVMHostCluster -VMMServer $vmm | Where-Object { $_.Name -in $clusterName, $shortName } | Select-Object -First 1 + $addError = '' if (-not $cluster) { $allHosts = Get-SCVMHostGroup -VMMServer $vmm | Where-Object { $_.Path -eq 'All Hosts' } Log "Adding cluster $clusterName to All Hosts" - Add-SCVMHostCluster -VMMServer $vmm -Name $clusterName -VMHostGroup $allHosts -Credential $runAs | Out-Null + # The add job can fail after the agent is installed and the nodes are managed, for instance when the + # DHCP server extension cannot be copied to the hosts; the node states below decide. + try { Add-SCVMHostCluster -VMMServer $vmm -Name $clusterName -VMHostGroup $allHosts -Credential $runAs | Out-Null } + catch { $addError = $_.Exception.Message } $cluster = Get-SCVMHostCluster -VMMServer $vmm | Where-Object { $_.Name -in $clusterName, $shortName } | Select-Object -First 1 } - if (-not $cluster) { throw "SCVMM does not list cluster $clusterName after Add-SCVMHostCluster." } + if (-not $cluster) { throw "SCVMM does not list cluster $clusterName after Add-SCVMHostCluster. $addError" } $nodes = @($cluster.Nodes) foreach ($node in $nodes) { Log "$($node.Name): $($node.OverallState), $($node.CommunicationState)" } + $responding = @($nodes | Where-Object { "$($_.CommunicationState)" -eq 'Responding' }) + if ($addError) { + if ($responding.Count -lt $nodes.Count) { throw "Add-SCVMHostCluster: $addError" } + Mark 'ADD_WARNING' $addError + } Mark 'NODES' $nodes.Count + Mark 'RESPONDING' $responding.Count Mark 'SHARED_VOLUMES' ((@($cluster.SharedVolumes) | ForEach-Object { $_.Name }) -join ' ') """ @@ -124,5 +138,9 @@ def run(job, resource=None, **kwargs): f"shared volumes: {found.get('SHARED_VOLUMES') or 'none reported'}") except LabError as err: return "FAILURE", "", str(err) - return "SUCCESS", (f"SCVMM on {lab.fqdn(lab.vmm)} manages cluster {lab.cluster_fqdn} with {nodes} Hyper-V " - f"hosts, using Run As account '{RUN_AS}'."), "" + output = (f"SCVMM on {lab.fqdn(lab.vmm)} manages cluster {lab.cluster_fqdn} with {nodes} Hyper-V hosts, " + f"using Run As account '{RUN_AS}'.") + if found.get("ADD_WARNING"): + return "WARNING", output, (f"Every node is managed and responding, but SCVMM reported an error while adding " + f"the cluster: {found['ADD_WARNING']}") + return "SUCCESS", output, "" From 2a383b155715982e00edeb9ba6b972b77d687bc7 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:25:41 -0500 Subject: [PATCH 17/22] Record what the SCVMM lab has run live Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 4835d535..89bfa42b 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -73,8 +73,9 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object. The cluster name's DNS record stays; the name is unique per lab. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. ### Not yet run live -Everything through Create Hyper-V Cluster, and the teardown, have run on a live appliance. These have not: -- **Add Hyper-V Cluster to SCVMM**, and New-Cluster carrying on after it cannot open the new cluster by name. +Every build item and the teardown have run on a live appliance, and a lab finished with SCVMM managing the cluster. Its last items ran after fixes, resumed from where the deployment paused. These have not run in one uninterrupted build: +- **New-Cluster on a fresh lab with the fixed script**, including going on when it cannot open the new cluster by name. +- **Creating the Run As account as DOMAIN\user, and the warning when SCVMM's add job fails but every node responds.** - **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. Failing the core group over to another host is untested. If the cluster name does not come online there, keep only the first host's address and pin the group to that host. ### Caveats From dfb2a434c8183db595a2ea3702ee450488431085 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Wed, 4 Nov 2026 05:55:38 -0500 Subject: [PATCH 18/22] Move the core cluster group to the first host before limiting IP owners New-Cluster brought lab-12's core group online on the second host, and Windows refuses to remove a node from the possible owners of a resource online on it, so Create Hyper-V Cluster failed on every run. Co-Authored-By: Claude Opus 5.5 --- plugins/OHK-77f19kly/OHK-77f19kly_script.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/OHK-77f19kly/OHK-77f19kly_script.py b/plugins/OHK-77f19kly/OHK-77f19kly_script.py index f268758d..c4cc49b9 100644 --- a/plugins/OHK-77f19kly/OHK-77f19kly_script.py +++ b/plugins/OHK-77f19kly/OHK-77f19kly_script.py @@ -27,6 +27,10 @@ belongs to the node that owns the core group. This is the IP layout and possible-owner setting of AWS's guidance for clusters on EC2, which describes nodes in separate subnets; the hosts here share one subnet. + New-Cluster can bring the core group online on another host, and + Windows refuses to remove a node from the possible owners of a resource + online on that node (ERROR_INVALID_STATE), so the core group first + moves to this host, which owns the first address. 3. Keep the NAT network (every host has the same gateway address on it) out of cluster traffic, and raise SameSubnetThreshold to 10 as AWS recommends. @@ -47,6 +51,8 @@ Set-ClusterParameter: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterparameter?view=windowsserver2019-ps IP Address private properties: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mscs/ip-address-private-properties Set-ClusterOwnerNode: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterownernode + ApiRemoveResourceNode (owner): https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cmrp/39e9d80a-00b3-4570-b977-48196e2d6abf + Move-ClusterGroup: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/move-clustergroup Set-ClusterResourceDependency: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/set-clusterresourcedependency Add-ClusterDisk: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clusterdisk Add-ClusterSharedVolume: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/add-clustersharedvolume @@ -105,6 +111,17 @@ $network = Get-ClusterNetwork -Cluster $target | Where-Object { $_.Address -ne $natAddress -and $_.Role -ne 0 } | Select-Object -First 1 if (-not $network) { throw 'The cluster has no network for its IP addresses.' } + # Windows will not remove a node from the possible owners of a resource online on it, and New-Cluster can bring + # the core group online on another host. This host owns the first address, so the core group comes here first. + $coreGroup = Get-ClusterGroup -Cluster $target -Name 'Cluster Group' + $from = $coreGroup.OwnerNode.Name + if ($from -ne $env:COMPUTERNAME) { + try { + Move-ClusterGroup -Cluster $target -Name 'Cluster Group' -Node $env:COMPUTERNAME | Out-Null + Log "Moved the core cluster group from $from to $env:COMPUTERNAME" + } catch { Log "Could not move the core cluster group from $from to $($env:COMPUTERNAME): $($_.Exception.Message)" } + } + $core = Get-ClusterResource -Cluster $target | Where-Object { $_.OwnerGroup -eq 'Cluster Group' } $nameResource = $core | Where-Object { $_.ResourceType -eq 'Network Name' } | Select-Object -First 1 $ipResources = @() From f3cd8702d2d6bbc7ac58e25f59f5bfd41b183128 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Wed, 4 Nov 2026 05:55:38 -0500 Subject: [PATCH 19/22] Report why Remove-Cluster failed at teardown, not only its generic message Co-Authored-By: Claude Opus 5.5 --- plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py index dccfe375..a24ca525 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py @@ -61,7 +61,13 @@ throw "$env:COMPUTERNAME is in cluster $($cluster.Name), not $name." } else { Log "Destroying cluster $name and deleting its Active Directory objects" - Remove-Cluster -Force -CleanupAD + # Remove-Cluster's own message is generic; the reason is in the inner exceptions. + try { Remove-Cluster -Force -CleanupAD } + catch { + $reasons = @(); $e = $_.Exception + while ($e) { $reasons += $e.Message; $e = $e.InnerException } + throw ($reasons -join ' ') + } Mark 'DESTROYED' $name } """ From 499aef73417cb2436b6128c300ca6b41dc4bc1c7 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Wed, 4 Nov 2026 06:56:43 -0500 Subject: [PATCH 20/22] Record the uninterrupted SCVMM lab build and its teardown Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 89bfa42b..760d1624 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -64,7 +64,7 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster ## Notes - **Re-running a build item.** Every step is skipped when it is already done. - **DNS names.** Prepare and Create Hyper-V Cluster check that every lab server's name resolves to its own address, because the cluster and SCVMM reach the servers by name. The usual cause of a failure is a record left by an earlier server with the same name. The zone lets only a record's owner update it, so the new server cannot replace it. Delete the record named in the error, then re-run the item. HPA-q181uofy deletes the records of the servers it deletes. -- **The cluster's name** is registered with one domain controller while the cluster is created. Other DNS servers answer for it only after directory replication. A resolver that cached "no such name" during creation keeps that answer until it expires, which can take up to the zone's minimum TTL (an hour by default). So Add Hyper-V Cluster to SCVMM waits up to an hour for the name to resolve from the SCVMM server; in testing it took about 18 minutes. Create Hyper-V Cluster does not need the name. +- **The cluster's name** is registered with one domain controller while the cluster is created. Other DNS servers answer for it only after directory replication. A resolver that cached "no such name" during creation keeps that answer until it expires, which can take up to the zone's minimum TTL (an hour by default). So Add Hyper-V Cluster to SCVMM waits up to an hour for the name to resolve from the SCVMM server; in testing it took from one to 18 minutes. Create Hyper-V Cluster does not need the name. - **Slow steps** run as scheduled tasks under `\CloudBolt\` and are polled every 30 seconds. Steps that reach AD or other servers sign in as the domain service account, so there is no double hop. Their logs are in the job's progress. - **The service account's password** goes to the guest inside the script body, base64 encoded for quoting only. On AWS that body stays in Systems Manager's command history. - **Scale-up is not supported.** Order a new lab for more hosts. @@ -73,13 +73,12 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object. The cluster name's DNS record stays; the name is unique per lab. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. ### Not yet run live -Every build item and the teardown have run on a live appliance, and a lab finished with SCVMM managing the cluster. Its last items ran after fixes, resumed from where the deployment paused. These have not run in one uninterrupted build: -- **New-Cluster on a fresh lab with the fixed script**, including going on when it cannot open the new cluster by name. -- **Creating the Run As account as DOMAIN\user, and the warning when SCVMM's add job fails but every node responds.** -- **Cluster address in one subnet.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. Failing the core group over to another host is untested. If the cluster name does not come online there, keep only the first host's address and pin the group to that host. +A lab built in one uninterrupted run, in 43 minutes, with SCVMM managing the cluster, and its teardown destroyed the cluster and deleted its computer object. Not yet run: +- **Failing the core group over to another host.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not come online on the other host, keep only the first host's address and pin the group to that host. +- **Teardown of a cluster whose creation failed partway.** On one such lab, `Remove-Cluster` failed with only a generic message, and the cluster's computer object was left in Active Directory. The teardown now reports the underlying error. ### Caveats -- **SCVMM's DHCP server extension.** On the test lab, SCVMM installed its agent on both hosts, but its BITS endpoint answered HTTP 500 when copying the DHCP server extension (`DHCPExtn.msi`) to them, so the add job failed. Add Hyper-V Cluster to SCVMM then ends with a warning that quotes SCVMM's message. The cluster and its nodes are managed. The extension is needed only for SCVMM-managed DHCP on virtual networks. +- **SCVMM's DHCP server extension.** On the test labs, SCVMM installed its agent on both hosts, but copying the DHCP server extension (`DHCPExtn.msi`) to them over BITS failed, so the add job failed. Add Hyper-V Cluster to SCVMM then ends with a warning that quotes SCVMM's message. The cluster and its nodes are managed. The extension is needed only for SCVMM-managed DHCP on virtual networks. - **SQL Server media download.** The ISO URL in Install SCVMM (`SQL_ISO_URL`) is Microsoft's file, but no Microsoft page documents it, so it can move. - **SQL Server edition.** SCVMM 2025 lists Standard, Enterprise and Datacenter. Developer is the Enterprise engine, for test use only. - **SCSI-3 persistent reservations** on the iSCSI target are not validated: `Test-Cluster` is not run. Run cluster validation in Failover Cluster Manager for a supported configuration. From 08b98ecdc2ea2cf27b9433c4ecc65a65d32c3562 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Wed, 4 Nov 2026 07:13:19 -0500 Subject: [PATCH 21/22] Delete the lab cluster's DNS record and its protected computer object at teardown Remove-Cluster leaves the cluster name's DNS record, so the teardown reads the cluster computer object's SID first and afterwards tombstones the records it owned. When Remove-Cluster leaves the protected computer object behind, a running host removes the protection and deletes it as the domain service account that created it. Co-Authored-By: Claude Opus 5.5 --- CATALOG.md | 2 +- .../BP-9zp8udce/BP-9zp8udce_metadata.json | 2 +- blueprints/BP-9zp8udce/README.md | 8 +- catalog.json | 2 +- .../OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json | 2 +- plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py | 176 ++++++++++++++---- plugins/README.md | 2 +- 7 files changed, 149 insertions(+), 45 deletions(-) diff --git a/CATALOG.md b/CATALOG.md index 5540c38d..f86e4154 100644 --- a/CATALOG.md +++ b/CATALOG.md @@ -381,7 +381,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | OpenShift Project Landing Zone | [OHK-prew0osh](plugins/OHK-prew0osh/) | Creates an OpenShift project with quota, limits, network policies, and an optional role binding, then pins a CloudBolt environment to it. | CloudBolt Plug-in | [OpenShift Project Landing Zone](blueprints/BP-tikkhf2y/README.md) | | Order Counts by Blueprint | [OHK-yjblxbwg](plugins/OHK-yjblxbwg/) | | CloudBolt Plug-in | [Order Counts by Blueprint](mcp_tool_actions/MTA-lp8lgi7e/) | | Prepare SCVMM Lab on AWS | [OHK-q6fb9833](plugins/OHK-q6fb9833/) | Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | -| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](plugins/OHK-kzb6pzzu/) | Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | +| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](plugins/OHK-kzb6pzzu/) | Destroys the SCVMM lab's cluster and deletes its computer object and DNS record from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](blueprints/BP-9zp8udce/README.md) | | Remove Resource Group from Environments | [OHK-vm5p34w3](plugins/OHK-vm5p34w3/) | Removes the deleted resource group's resource_group_arm option from environments on the same subscription. | CloudBolt Plug-in | [Azure Resource Group - Bicep](blueprints/BP-p7zmh96m/README.md) | | Remove Servers from Ansible Automation Platform | [OHK-8v830go3](plugins/OHK-8v830go3/) | Removes the host records a deployment's servers hold in Ansible Automation Platform inventories through CloudBolt's own connector method, before the infrastructure is destroyed; a missing host or unreachable AAP is a warning, never a blocker. | CloudBolt Plug-in | standalone | | Request AKS Namespace Quota Change | [OHK-jeighfcq](plugins/OHK-jeighfcq/) | Moves an AKS namespace landing zone to a different size tier after approval and mirrors the new quota into its environment. | CloudBolt Plug-in | [Request AKS Namespace Quota Change](resource_actions/RSA-7wdigcpr/) | diff --git a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json index c1ccc915..fe220188 100644 --- a/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json +++ b/blueprints/BP-9zp8udce/BP-9zp8udce_metadata.json @@ -210,7 +210,7 @@ "hook": "plugins/OHK-kzb6pzzu" }, "deploy_seq": -1, - "description": "Destroys the cluster from a running host and deletes its computer object from Active Directory; the servers and the storage volume are deleted with the resource.", + "description": "Destroys the cluster from a running host and deletes its computer object and DNS record from Active Directory; the servers and the storage volume are deleted with the resource.", "enabled": true, "execute_in_parallel": false, "id": "BDI-w9x43skq", diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 760d1624..915e8f1f 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -17,7 +17,7 @@ Every server joins an existing Active Directory domain. The build runs unattende | Build (Plug-in, seq 5) | OHK-8ioy2cbi | Configure Hyper-V Hosts | | Build (Plug-in, seq 6) | OHK-77f19kly | Create Hyper-V Cluster | | Build (Plug-in, seq 7) | OHK-ive3ka22 | Add Hyper-V Cluster to SCVMM | -| Teardown (before the servers are deleted) | OHK-kzb6pzzu | Remove Hyper-V Cluster Object: destroys the cluster with `Remove-Cluster -CleanupAD` on a running host, which deletes its computer object | +| Teardown (before the servers are deleted) | OHK-kzb6pzzu | Remove Hyper-V Cluster Object: destroys the cluster with `Remove-Cluster -CleanupAD` on a running host, which deletes its computer object, then deletes the cluster name's DNS record | | Shared module | SHM-dpj24dfj | `scvmm_lab`: guest scripts, scheduled-task steps, EC2 calls | Blueprint parameters, each pinned as its only option, so the order form hides them: @@ -40,7 +40,7 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Domain join content.** Install [PKG-nf407lm5](../../packages/PKG-nf407lm5/) (Join Windows Server to AD Domain), with `domain_ou` and `domain_service_account` set on the AWS environment. Every lab server must get the same `domain_service_account`. That account: - is a member of the local Administrators group on the lab servers, for example through a Group Policy linked to their OU; - has **Create Computer objects** on that OU, for the cluster's computer object. -- **Teardown rights.** The LDAP Utility's account must be able to delete computer objects in that OU. Windows protects the cluster's computer object from accidental deletion, so the teardown deletes it from a host, as the domain service account that created it; the LDAP Utility deletes it only when no host is running and the object is not protected. +- **Teardown rights.** The LDAP Utility's account must be able to delete computer objects in that OU and DNS records in the domain's zone. Windows protects the cluster's computer object from accidental deletion, so the teardown deletes it from a running host as the domain service account that created it. When `Remove-Cluster` leaves the object behind, that account removes the protection and deletes it. - **Runbooks package.** [PKG-v20qv308](../../packages/PKG-v20qv308/) provides the `file_archives` shared module that Install SCVMM imports. File Archives itself is needed only when `scvmm_media` names a File Archives file. - **AWS environment.** Windows Server 2025 instances CloudBolt can run scripts on, through SSM (with an instance profile allowing `AmazonSSMManagedInstanceCore`) or through WinRM. - **Security group:** allow all traffic between its own members (a rule whose source is the group itself). @@ -70,12 +70,12 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Scale-up is not supported.** Order a new lab for more hosts. - **Nested VMs** reach the network only through their host's NAT (`192.168.250.0/24`), because EC2 drops frames from unknown MAC addresses. They are not reachable from the VPC. - **SCVMM has no templates, logical networks or IP pools yet.** Add them in the console. -- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object. The cluster name's DNS record stays; the name is unique per lab. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. +- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object and the cluster name's DNS record. A DNS record another account owns is left alone and reported. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. ### Not yet run live A lab built in one uninterrupted run, in 43 minutes, with SCVMM managing the cluster, and its teardown destroyed the cluster and deleted its computer object. Not yet run: - **Failing the core group over to another host.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not come online on the other host, keep only the first host's address and pin the group to that host. -- **Teardown of a cluster whose creation failed partway.** On one such lab, `Remove-Cluster` failed with only a generic message, and the cluster's computer object was left in Active Directory. The teardown now reports the underlying error. +- **Teardown of a cluster whose creation failed partway.** On one such lab, `Remove-Cluster` failed with only a generic message, and the cluster's computer object was left in Active Directory. The teardown now reports the underlying error, and removes the protection and deletes the object from a host; that path has not run live. ### Caveats - **SCVMM's DHCP server extension.** On the test labs, SCVMM installed its agent on both hosts, but copying the DHCP server extension (`DHCPExtn.msi`) to them over BITS failed, so the add job failed. Add Hyper-V Cluster to SCVMM then ends with a warning that quotes SCVMM's message. The cluster and its nodes are managed. The extension is needed only for SCVMM-managed DHCP on virtual networks. diff --git a/catalog.json b/catalog.json index fa651da0..0d5ded1a 100644 --- a/catalog.json +++ b/catalog.json @@ -3548,7 +3548,7 @@ "id": "OHK-kzb6pzzu", "type": "plugins", "name": "Remove Hyper-V Cluster Object", - "description": "Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted.", + "description": "Destroys the SCVMM lab's cluster and deletes its computer object and DNS record from Active Directory when the lab is deleted.", "path": "plugins/OHK-kzb6pzzu", "readme": null, "uses": [ diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json index 1fdf0229..3b90ae21 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_metadata.json @@ -5,7 +5,7 @@ "shared_modules/SHM-dpj24dfj" ] }, - "description": "Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted.", + "description": "Destroys the SCVMM lab's cluster and deletes its computer object and DNS record from Active Directory when the lab is deleted.", "id": "OHK-kzb6pzzu", "max_retries": 0, "name": "Remove Hyper-V Cluster Object", diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py index a24ca525..7d9e00de 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py @@ -5,37 +5,50 @@ runs before CloudBolt deletes the lab's servers (deploy_seq -1). Create Hyper-V Cluster made a computer object for the cluster name (the CNO) in the hosts' OU, and Windows protects that object from accidental deletion, so the -LDAP Utility is refused when it deletes it. +LDAP Utility is refused when it deletes it. The cluster name's DNS record is +owned by the CNO. - 1. Turn off DNS registration on every running host. A host registers its + 1. Read the CNO's SID over LDAP with the LDAP Utility that serves the lab's + domain, the same utility Join Windows Server to AD Domain joins with, + through the ad_domain shared module (shared_modules/SHM-gcba1u31). + 2. Turn off DNS registration on every running host. A host registers its name again whenever its addresses change, and cluster IP addresses move when the cluster is destroyed or a node shuts down; its record would then outlive the cleanup Delete Windows Computer Object from AD does before CloudBolt deletes it. - 2. While a host is running, destroy the cluster from it with + 3. While a host is running, destroy the cluster from it with Remove-Cluster -CleanupAD, as a scheduled task signed in as the domain service account. That account created the CNO, and -CleanupAD deletes it with the cluster. - 3. When the CNO is still there, delete it over LDAP with the LDAP Utility - that serves the lab's domain, the same utility Join Windows Server to AD - Domain joins with, through the ad_domain shared module - (shared_modules/SHM-gcba1u31). + 4. When the CNO is still there, delete it over LDAP. When Windows' protection + refuses that, delete it from a running host as the domain service + account: it owns the object, so it may remove the protection's Deny + entries for Everyone and allow itself to delete it. + 5. Delete the cluster name's DNS records that the CNO owned, the way Delete + Windows Computer Object from AD (plugins/OHK-bkoau0j8) deletes a + server's own records. Remove-Cluster leaves them, and a record owned by + another account is left alone. The servers' own computer objects are left to Delete Windows Computer Object from AD (HPA-q181uofy), and the servers and the storage volume are deleted with the resource. Idempotent: a lab that never got a cluster, or a CNO that is already gone, -ends with SUCCESS; a CNO that cannot be deleted ends with WARNING so the -rest of the delete goes on. +ends with SUCCESS; anything left behind ends with WARNING so the rest of the +delete goes on. CloudBolt renders this file as a template before running it, so it must never -contain template tags; values reach the script through the __CB_*__ tokens. +contain template tags; values reach the scripts through the __CB_*__ tokens. References: Set-DnsClient: https://learn.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclient Remove-Cluster: https://learn.microsoft.com/en-us/powershell/module/failoverclusters/remove-cluster CNO protected from accidental delete: https://learn.microsoft.com/en-us/troubleshoot/windows-server/high-availability/event-id-1222-create-failover-cluster + Protection is Deny entries for Everyone: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc739350(v=ws.10) + DirectoryEntry.ObjectSecurity: https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.directoryentry.objectsecurity + ActiveDirectorySecurity.RemoveAccess: https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.activedirectorysecurity.removeaccess + ActiveDirectoryAccessRule: https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.activedirectoryaccessrule.-ctor + DirectoryEntry.DeleteTree: https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.directoryentry.deletetree """ from common.methods import set_progress from utilities.logger import ThreadLogger @@ -72,6 +85,24 @@ } """ +DELETE_PROTECTED = r""" + Add-Type -AssemblyName System.DirectoryServices + $dn = Decode '__CB_DN__' + $entry = New-Object System.DirectoryServices.DirectoryEntry ('LDAP://{0}/{1}' -f (Decode '__CB_DOMAIN__'), $dn) + $entry.Options.SecurityMasks = [System.DirectoryServices.SecurityMasks]::Dacl + $security = $entry.ObjectSecurity + # The protection is Deny entries for Everyone, which outrank any Allow. The owner may change permissions. + $security.RemoveAccess((New-Object Security.Principal.SecurityIdentifier 'S-1-1-0'), [Security.AccessControl.AccessControlType]::Deny) + $me = [Security.Principal.WindowsIdentity]::GetCurrent().User + $rights = [System.DirectoryServices.ActiveDirectoryRights]'Delete, DeleteTree' + $security.AddAccessRule((New-Object System.DirectoryServices.ActiveDirectoryAccessRule $me, $rights, ([Security.AccessControl.AccessControlType]::Allow))) + $entry.ObjectSecurity = $security + $entry.CommitChanges() + Log "Removed the protection from accidental deletion on $dn" + $entry.DeleteTree() + Mark 'DELETED' $dn +""" + def destroy_cluster(resource, name): """ @@ -102,6 +133,54 @@ def destroy_cluster(resource, name): return f"{running[0].hostname} is in no cluster." +def lookup_cno(conn, base, name, cluster): + """The cluster's computer object, or None. Raises LabError when another object could be meant.""" + found = ad_domain.find_computers(conn, base, name=name) + if not found: + return None + if len(found) > 1: + raise LabError(f"Found several computer objects named {name}; none was deleted.") + dns_name = (found[0]["dns_host_name"] or "").lower() + if dns_name and dns_name != cluster: + raise LabError(f"Computer object {found[0]['dn']} has DNS name {dns_name}, not {cluster}; it was not deleted.") + return found[0] + + +def delete_protected(resource, dn, domain): + """Delete the protected CNO from a running host as the domain service account. Returns the host name.""" + lab = scvmm_lab.Lab(resource) + running = [host for host in lab.hosts if host.power_status == "POWERON"] + if not running: + raise LabError("no host is running to delete it from.") + log = scvmm_lab.run_task(running[0], DELETE_PROTECTED, f"delete {dn}", tokens={"DN": dn, "DOMAIN": domain}, + account=lab.account, timeout=600) + if scvmm_lab.markers(log).get("DELETED") != dn: + raise LabError(f"{running[0].hostname} did not report {dn} deleted.") + return running[0].hostname + + +def delete_cluster_dns(conn, cluster, sid): + """ + Tombstone the DNS nodes of the cluster name that its CNO owned. Returns + (note, problem), problem empty when nothing was left behind. + """ + deleted, kept = [], False + for dn, entry in ad_domain.find_dns_nodes(conn, cluster): + if ad_domain.is_tombstoned(entry): + continue + if not sid or ad_domain.owner_sid(conn, dn) != sid: + kept = True + continue + deleted += ad_domain.a_addresses(entry) + ad_domain.tombstone_dns_node(conn, dn, entry) + note = f"Deleted the DNS record of {cluster} ({', '.join(deleted) or 'no address'})." if deleted else "" + if kept: + why = ("another account owns it" if sid else + "the cluster's computer object was already gone, so who owns the record could not be checked") + return note, f"Left the DNS record of {cluster} alone: {why}. Delete it in DNS Manager." + return note or f"{cluster} has no DNS record left.", "" + + def run(job, resource=None, **kwargs): resource = resource or job.resource_set.first() cluster = str(resource.get_value_for_custom_field("scvmm_lab_cluster") or "").strip().lower() @@ -109,37 +188,62 @@ def run(job, resource=None, **kwargs): if not cluster or not domain: return "SUCCESS", "The lab has no cluster recorded; no computer object to delete.", "" name = cluster.split(".")[0] + matches = [u for u in ad_domain.utilities() if ad_domain.utility_domain(u) == domain] + utility = matches[0] if len(matches) == 1 else None + + # Remove-Cluster -CleanupAD deletes the CNO, whose SID owns the cluster name's DNS record. + sid = b"" + if utility: + try: + conn = ad_domain.connect(utility) + try: + cno = lookup_cno(conn, ad_domain.search_base(utility, conn), name, cluster) + sid = cno["sid"] if cno else b"" + finally: + conn.unbind_s() + except Exception as err: + logger.warning("Reading the computer object of cluster %s failed: %s", name, err) + note = destroy_cluster(resource, name) set_progress(note) + if not utility: + return "WARNING", note, (f"{len(matches)} LDAP Utilities serve {domain}, so the computer object and DNS record " + f"of cluster {name} were not checked. Delete them in Active Directory if they are there.") - matches = [u for u in ad_domain.utilities() if ad_domain.utility_domain(u) == domain] - if len(matches) != 1: - return "WARNING", note, (f"{len(matches)} LDAP Utilities serve {domain}, so the computer object of " - f"cluster {name} was not checked. Delete it in Active Directory if it is there.") - dn = "" + notes, problems = [note], [] try: - conn = ad_domain.connect(matches[0]) + conn = ad_domain.connect(utility) try: - found = ad_domain.find_computers(conn, ad_domain.search_base(matches[0], conn), name=name) - if not found: - return "SUCCESS", f"{note} Cluster {name} has no computer object left in {domain}.", "" - if len(found) > 1: - return "WARNING", note, f"Found several computer objects named {name} in {domain}; none was deleted." - dn = found[0]["dn"] - dns_name = (found[0]["dns_host_name"] or "").lower() - if dns_name and dns_name != cluster: - return "WARNING", note, (f"Computer object {dn} has DNS name {dns_name}, not {cluster}; " - "it was not deleted.") - set_progress(f"Deleting {dn}") - ad_domain.delete_entry(conn, dn) + cno = lookup_cno(conn, ad_domain.search_base(utility, conn), name, cluster) + if not cno: + notes.append(f"Cluster {name} has no computer object left in {domain}.") + else: + set_progress(f"Deleting {cno['dn']}") + try: + ad_domain.delete_entry(conn, cno["dn"]) + notes.append(f"Deleted the computer object of cluster {name} from {domain}.") + except ad_domain.ldap.INSUFFICIENT_ACCESS: + try: + host = delete_protected(resource, cno["dn"], domain) + notes.append(f"Removed the protection from accidental deletion on {cno['dn']} and deleted it " + f"from {host}.") + except LabError as err: + problems.append( + f"The LDAP Utility may not delete {cno['dn']}: Windows protects a cluster's computer object " + f"from accidental deletion, and deleting it from a host failed: {err} Clear Protect from " + "accidental deletion on it in Active Directory Administrative Center, then delete it.") + dns_note, dns_problem = delete_cluster_dns(conn, cluster, sid) + notes += [dns_note] if dns_note else [] + problems += [dns_problem] if dns_problem else [] finally: conn.unbind_s() - except ad_domain.ldap.INSUFFICIENT_ACCESS: - return "WARNING", note, (f"The LDAP Utility may not delete {dn}: Windows protects a cluster's computer " - "object from accidental deletion. Clear Protect from accidental deletion on it " - "in Active Directory Administrative Center, then delete it.") + except LabError as err: + problems.append(str(err)) except Exception as err: - logger.exception("Deleting the computer object of cluster %s failed", name) - return "WARNING", note, (f"Could not delete the computer object of cluster {name}: {err}. The LDAP " - "Utility's account needs the right to delete computer objects in the hosts' OU.") - return "SUCCESS", f"{note} Deleted the computer object of cluster {name} from {domain}.", "" + logger.exception("Deleting the computer object or DNS record of cluster %s failed", name) + problems.append(f"Could not delete the computer object or DNS record of cluster {name}: {err}. The LDAP " + f"Utility's account needs the right to delete computer objects in the hosts' OU and DNS records " + f"in the {domain} zone.") + if problems: + return "WARNING", " ".join(notes), " ".join(problems) + return "SUCCESS", " ".join(notes), "" diff --git a/plugins/README.md b/plugins/README.md index ffce8500..4d384f30 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -148,7 +148,7 @@ Python and remote-script actions. Plugins that belong to a blueprint or action a | OpenShift Project Landing Zone | [OHK-prew0osh](OHK-prew0osh/) | Creates an OpenShift project with quota, limits, network policies, and an optional role binding, then pins a CloudBolt environment to it. | CloudBolt Plug-in | [OpenShift Project Landing Zone](../blueprints/BP-tikkhf2y/README.md) | | Order Counts by Blueprint | [OHK-yjblxbwg](OHK-yjblxbwg/) | | CloudBolt Plug-in | [Order Counts by Blueprint](../mcp_tool_actions/MTA-lp8lgi7e/) | | Prepare SCVMM Lab on AWS | [OHK-q6fb9833](OHK-q6fb9833/) | Checks the SCVMM lab servers are in the domain, turns on nested virtualization and assigns a cluster IP on each Hyper-V host, and attaches and formats the gp3 lab volume on the SCVMM server with the iSCSI Target Server role. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | -| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](OHK-kzb6pzzu/) | Destroys the SCVMM lab's cluster and deletes its computer object from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | +| Remove Hyper-V Cluster Object | [OHK-kzb6pzzu](OHK-kzb6pzzu/) | Destroys the SCVMM lab's cluster and deletes its computer object and DNS record from Active Directory when the lab is deleted. | CloudBolt Plug-in | [SCVMM Lab on AWS](../blueprints/BP-9zp8udce/README.md) | | Remove Resource Group from Environments | [OHK-vm5p34w3](OHK-vm5p34w3/) | Removes the deleted resource group's resource_group_arm option from environments on the same subscription. | CloudBolt Plug-in | [Azure Resource Group - Bicep](../blueprints/BP-p7zmh96m/README.md) | | Remove Servers from Ansible Automation Platform | [OHK-8v830go3](OHK-8v830go3/) | Removes the host records a deployment's servers hold in Ansible Automation Platform inventories through CloudBolt's own connector method, before the infrastructure is destroyed; a missing host or unreachable AAP is a warning, never a blocker. | CloudBolt Plug-in | standalone | | Request AKS Namespace Quota Change | [OHK-jeighfcq](OHK-jeighfcq/) | Moves an AKS namespace landing zone to a different size tier after approval and mirrors the new quota into its environment. | CloudBolt Plug-in | [Request AKS Namespace Quota Change](../resource_actions/RSA-7wdigcpr/) | From ff579d124686ed22ada9be7e33ee67d1287708a6 Mon Sep 17 00:00:00 2001 From: Mike Bombard <37379633+mbomb67@users.noreply.github.com> Date: Wed, 4 Nov 2026 08:04:00 -0500 Subject: [PATCH 22/22] Say that Remove-Cluster removes the cluster's DNS record itself A lab teardown found no DNS record of the cluster left after Remove-Cluster, so the teardown's DNS step only catches a record when Remove-Cluster did not run or failed. The record an earlier lab left came from a teardown that never ran Remove-Cluster. Co-Authored-By: Claude Opus 5.5 --- blueprints/BP-9zp8udce/README.md | 8 ++++---- plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/blueprints/BP-9zp8udce/README.md b/blueprints/BP-9zp8udce/README.md index 915e8f1f..8faca92e 100644 --- a/blueprints/BP-9zp8udce/README.md +++ b/blueprints/BP-9zp8udce/README.md @@ -17,7 +17,7 @@ Every server joins an existing Active Directory domain. The build runs unattende | Build (Plug-in, seq 5) | OHK-8ioy2cbi | Configure Hyper-V Hosts | | Build (Plug-in, seq 6) | OHK-77f19kly | Create Hyper-V Cluster | | Build (Plug-in, seq 7) | OHK-ive3ka22 | Add Hyper-V Cluster to SCVMM | -| Teardown (before the servers are deleted) | OHK-kzb6pzzu | Remove Hyper-V Cluster Object: destroys the cluster with `Remove-Cluster -CleanupAD` on a running host, which deletes its computer object, then deletes the cluster name's DNS record | +| Teardown (before the servers are deleted) | OHK-kzb6pzzu | Remove Hyper-V Cluster Object: destroys the cluster with `Remove-Cluster -CleanupAD` on a running host, which deletes its computer object and DNS record, and deletes whichever of them is left | | Shared module | SHM-dpj24dfj | `scvmm_lab`: guest scripts, scheduled-task steps, EC2 calls | Blueprint parameters, each pinned as its only option, so the order form hides them: @@ -70,12 +70,12 @@ Resource attributes: `scvmm_lab_domain`, `scvmm_lab_cluster`, `scvmm_lab_cluster - **Scale-up is not supported.** Order a new lab for more hosts. - **Nested VMs** reach the network only through their host's NAT (`192.168.250.0/24`), because EC2 drops frames from unknown MAC addresses. They are not reachable from the VPC. - **SCVMM has no templates, logical networks or IP pools yet.** Add them in the console. -- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster and deletes its computer object and the cluster name's DNS record. A DNS record another account owns is left alone and reported. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. +- **Deleting the lab** deletes the instances. The storage volume goes with the SCVMM server, and the teardown item destroys the cluster, which deletes its computer object and the cluster name's DNS record. When `Remove-Cluster` does not run or fails, the teardown deletes them itself; a DNS record another account owns is left alone and reported. The servers' own computer objects and DNS records are deleted only by HPA-q181uofy, when it is installed. ### Not yet run live -A lab built in one uninterrupted run, in 43 minutes, with SCVMM managing the cluster, and its teardown destroyed the cluster and deleted its computer object. Not yet run: +Two labs built in one uninterrupted run each, in 43 minutes, with SCVMM managing the cluster. Their teardowns destroyed the cluster and deleted its computer object, and the second found no DNS record of the cluster left. Not yet run: - **Failing the core group over to another host.** One IP resource per host is AWS's clustering pattern for hosts in separate subnets; here the hosts share a subnet. If the cluster name does not come online on the other host, keep only the first host's address and pin the group to that host. -- **Teardown of a cluster whose creation failed partway.** On one such lab, `Remove-Cluster` failed with only a generic message, and the cluster's computer object was left in Active Directory. The teardown now reports the underlying error, and removes the protection and deletes the object from a host; that path has not run live. +- **Teardown of a cluster whose creation failed partway.** On one such lab, `Remove-Cluster` failed with only a generic message, and the cluster's computer object was left in Active Directory. The teardown now reports the underlying error, removes the protection and deletes the object from a host, and deletes the DNS record the object owned; those paths have not run live. ### Caveats - **SCVMM's DHCP server extension.** On the test labs, SCVMM installed its agent on both hosts, but copying the DHCP server extension (`DHCPExtn.msi`) to them over BITS failed, so the add job failed. Add Hyper-V Cluster to SCVMM then ends with a warning that quotes SCVMM's message. The cluster and its nodes are managed. The extension is needed only for SCVMM-managed DHCP on virtual networks. diff --git a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py index 7d9e00de..3450e69c 100644 --- a/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py +++ b/plugins/OHK-kzb6pzzu/OHK-kzb6pzzu_script.py @@ -5,8 +5,8 @@ runs before CloudBolt deletes the lab's servers (deploy_seq -1). Create Hyper-V Cluster made a computer object for the cluster name (the CNO) in the hosts' OU, and Windows protects that object from accidental deletion, so the -LDAP Utility is refused when it deletes it. The cluster name's DNS record is -owned by the CNO. +LDAP Utility is refused when it deletes it. The CNO owns the cluster name's +DNS record. 1. Read the CNO's SID over LDAP with the LDAP Utility that serves the lab's domain, the same utility Join Windows Server to AD Domain joins with, @@ -24,10 +24,11 @@ refuses that, delete it from a running host as the domain service account: it owns the object, so it may remove the protection's Deny entries for Everyone and allow itself to delete it. - 5. Delete the cluster name's DNS records that the CNO owned, the way Delete - Windows Computer Object from AD (plugins/OHK-bkoau0j8) deletes a - server's own records. Remove-Cluster leaves them, and a record owned by - another account is left alone. + 5. Delete any DNS record of the cluster name that the CNO owned, the way + Delete Windows Computer Object from AD (plugins/OHK-bkoau0j8) deletes a + server's own records. Remove-Cluster removes the record when it + succeeds; this catches the record when it did not run or failed. A + record owned by another account is left alone. The servers' own computer objects are left to Delete Windows Computer Object from AD (HPA-q181uofy), and the servers and the storage volume are deleted