azure: add Ignition config generation from IMDS/OVF metadata - #2
Closed
peytonr18 wants to merge 7 commits into
Closed
azure: add Ignition config generation from IMDS/OVF metadata#2peytonr18 wants to merge 7 commits into
peytonr18 wants to merge 7 commits into
Conversation
Add support for generating an Ignition config from Azure's Instance Metadata Service (IMDS) and OVF provisioning data. This allows VMs to be provisioned with the admin user, SSH keys, and password configured in Azure without requiring a user-provided Ignition config. This feature is opt-in via kernel cmdline parameter: ignition.config.generate=azure When enabled, Ignition will: - Fetch extended metadata from IMDS (/metadata/instance?extended=true) - Mount the provisioning CD-ROM and parse ovf-env.xml - Generate an Ignition config with: - Admin user (from IMDS osProfile.adminUsername or OVF UserName) - SSH authorized keys (from both sources, deduplicated) - Hashed password (SHA-512 crypt format) - Sudoers config for passwordless sudo - SSHD config based on DisableSshPasswordAuthentication setting Key implementation details: - Added GenerateCloudConfig to platform.Provider interface - Added --generate-cloud-config CLI flag to ignition binary - Password hashing uses github.com/GehirnInc/crypt library - OVF reading has 30-second timeout to prevent boot hangs - Fixed yes/no parsing for DisableSshPasswordAuthentication field
There was a problem hiding this comment.
Pull request overview
This PR introduces support for generating Azure-specific Ignition configurations from Azure Instance Metadata Service (IMDS) and OVF provisioning data. The feature is activated via the kernel command-line parameter ignition.config.generate=azure, enabling automatic admin user provisioning with SSH keys, password authentication settings, sudo permissions, and SSHD configuration based on Azure metadata.
Key changes include:
- Added password hashing utilities using SHA-512 crypt algorithm via the
github.com/GehirnInc/cryptlibrary - Implemented cloud config generation capability as a new provider interface method (
GenerateCloudConfig) - Enhanced kernel command-line parsing to support config generation mode with validation against command injection
Reviewed changes
Copilot reviewed 9 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
vendor/modules.txt |
Added github.com/GehirnInc/crypt dependency for password hashing |
vendor/github.com/GehirnInc/crypt/** |
Vendored password hashing library implementing SHA-512 crypt |
internal/providers/azure/crypt.go |
Password hashing wrapper functions for SHA-512 with hash detection |
internal/providers/azure/azure_test.go |
Comprehensive test suite covering config generation, password handling, username priority, and edge cases |
internal/providers/azure/azure.go |
Core generation logic: IMDS fetching, OVF parsing, config building, and device mounting refactoring |
internal/platform/platform.go |
Added GenerateCloudConfig to Provider interface and corresponding wrapper method |
internal/main.go |
Added --generate-cloud-config CLI flag for generation mode |
internal/exec/engine.go |
Implemented config generation path with platform validation and state tracking |
dracut/30ignition/ignition-generator |
Kernel cmdline parsing with regex validation to prevent command injection |
go.mod, go.sum |
Added crypt library dependency at version v0.0.0-20230320061759-8cc1b52080c5 |
docs/release-notes.md |
Documented new Azure config generation feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
Author
|
closing in favor of #4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for generating an Ignition config from Azure's IMDS and ovf provisioning data.
Usage
Enable via kernel command line:
ignition.config.generate=azureWhen enabled, Ignition generates a config that creates:
%wheel ALL=(ALL) NOPASSWD:ALL)DisableSshPasswordAuthenticationsettingKernel cmdline
ignition-generatorignition binary:ignition.config.generate=azure→IGNITION_ARGS=--generate... →GenerateCloudConfig()Changes
New Files
internal/providers/azure/crypt.go- SHA-512 password hashing utilitiesModified Files
internal/platform/platform.go- AddedGenerateCloudConfigto Provider interfaceinternal/main.go- Added--generate-cloud-configCLI flaginternal/exec/engine.go- Added generation mode handlinginternal/providers/azure/azure.go- Core generation logicdracut/30ignition/ignition-generator- Kernel cmdline parsingDependencies
github.com/GehirnInc/cryptfor SHA-512 password hashing