feat(azure): Add Azure Ignition fragment generation#1264
feat(azure): Add Azure Ignition fragment generation#1264peytonr18 wants to merge 4 commits intocoreos:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for generating Azure-specific Ignition fragments. The implementation is well-structured, adding a new CLI command, a systemd service for execution, and the core logic for fetching data from IMDS and OVF. The refactoring to share SSH key parsing logic is a good improvement.
I've found one critical issue regarding the systemd service activation which would cause the feature to not work as intended, and one medium-severity suggestion to improve code efficiency and readability. Please see the detailed comments.
| mkdir -p "$initdir/$systemdsystemunitdir/ignition-complete.target.requires" | ||
| ln -s "../afterburn-hostname.service" "$initdir/$systemdsystemunitdir/ignition-complete.target.requires/afterburn-hostname.service" | ||
| ln -s "../afterburn-network-kargs.service" "$initdir/$systemdsystemunitdir/ignition-complete.target.requires/afterburn-network-kargs.service" | ||
| ln -s "../afterburn-ignition-fragment.service" "$initdir/$systemdsystemunitdir/ignition-complete.target.requires/afterburn-ignition-fragment.service" |
There was a problem hiding this comment.
The afterburn-ignition-fragment.service is being linked into ignition-complete.target.requires. This will cause it to run after all main Ignition stages are complete, which is too late for the generated fragment to be used by Ignition.
According to its own unit file, this service must run before ignition-kargs.service. To ensure correct ordering and activation, it should be made a requirement of ignition-kargs.service instead of ignition-complete.target.
| ln -s "../afterburn-ignition-fragment.service" "$initdir/$systemdsystemunitdir/ignition-complete.target.requires/afterburn-ignition-fragment.service" | |
| mkdir -p "$initdir/$systemdsystemunitdir/ignition-kargs.service.requires" | |
| ln -s "../afterburn-ignition-fragment.service" "$initdir/$systemdsystemunitdir/ignition-kargs.service.requires/afterburn-ignition-fragment.service" |
| let key_data = item | ||
| .key_data | ||
| .replace("\r\n", "") | ||
| .replace('\n', "") | ||
| .trim() | ||
| .to_string(); |
There was a problem hiding this comment.
The current string manipulation for cleaning key_data involves a chain of operations that results in an unnecessary String allocation because .to_string() is called on a temporary &str. This can be made more efficient and readable by separating the steps.
| let key_data = item | |
| .key_data | |
| .replace("\r\n", "") | |
| .replace('\n', "") | |
| .trim() | |
| .to_string(); | |
| let key_data_cleaned = item.key_data.replace("\r\n", "").replace('\n', ""); | |
| let key_data = key_data_cleaned.trim(); |
6af9c2e to
50a81df
Compare
Summary
This PR adds Azure-specific Ignition fragment generation in Afterburn so Ignition can consume platform-provided user data during merge and create/configure the target user with SSH authorized keys.
Changes
render-ignitionCLI subcommand that accepts--provider/--cmdline,--render-ignition-dir, and per-feature flags.`generate_hostname_fragment(): fetches hostname viaMetadataProvider::hostname(), writeshostname.ignwith adata:,<hostname>URI.generate_user_fragment(): reuses existing IMDS username/SSH key fetch and OVF validation for Azure, writesuser.ign.OVF / IMDS Source Rules
ovf-env.xmlisadminPassword.adminPasswordis treated as unsupported and rejected.CLI Design
The new
render-ignitionsubcommand mirrors the existingmultipattern:--render-ignition-dir <path>— directory to write.ignfragments into--hostname— generatehostname.ign(Ignitionstorage.filesentry for/etc/hostname)--platform-user— generateuser.ign(Ignitionpasswd.usersentry with username + SSH keys)--platform-extensions— enable all features (implies--hostname --platform-user)Each feature writes its own standalone fragment file. Unsupported features for a given provider warn and skip, matching existing afterburn behavior.
Existing functionality is untouched
The
multisubcommand's--hostname=<path>direct-file-write path is unchanged. Theafterburn-hostname.service(including its azure/azurestack conditions) is not modified.The CLI design is up for discussion — we would love feedback on the flag names, subcommand structure, and overall approach.