-
Notifications
You must be signed in to change notification settings - Fork 124
feat(azure): Add Azure Ignition fragment generation #1264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
peytonr18
wants to merge
4
commits into
coreos:main
Choose a base branch
from
peytonr18:probertson-generate-ignition-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
50a81df
feat(azure): add azure ignition config fragment generation
peytonr18 82cb241
Changing service file to run in parallel with ignition-fetch.service
peytonr18 790260d
Refactor CLI design to be compatible with existing arguments and modu…
peytonr18 b750b45
Move tests to mod.rs for clarity and fix clippy error from github CI
peytonr18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [Unit] | ||
| Description=Afterburn Ignition Config Fragment Generator | ||
| Documentation=https://coreos.github.io/afterburn/ | ||
|
|
||
| # Only run on platforms that support ignition fragment generation. | ||
| ConditionKernelCommandLine=|ignition.platform.id=azure | ||
|
|
||
| # Run after networking is available (needed for IMDS), and in parallel | ||
| # with ignition-fetch so this path can emit its own diagnostics while | ||
| # still completing before ignition-kargs merge processing. | ||
| Wants=network-online.target | ||
| After=network-online.target | ||
| Before=ignition-kargs.service | ||
|
|
||
| OnFailure=emergency.target | ||
| OnFailureJobMode=isolate | ||
|
|
||
| [Service] | ||
| ExecStart=/usr/bin/afterburn render-ignition --cmdline --render-ignition-dir /usr/lib/ignition/base.platform.d/azure/ --platform-extensions | ||
| Type=oneshot | ||
| RemainAfterExit=yes |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| //! `render-ignition` CLI sub-command. | ||
| //! | ||
| //! Generates per-feature Ignition config fragment files in an output directory. | ||
| //! Each enabled feature writes its own `.ign` file; Ignition merges them | ||
| //! natively from `base.platform.d/<platform>/`. | ||
|
|
||
| use anyhow::{Context, Result}; | ||
| use clap::{ArgGroup, Parser}; | ||
|
|
||
| /// Render Ignition config fragments from cloud provider metadata | ||
| #[derive(Debug, Parser)] | ||
| #[command(group(ArgGroup::new("provider-group").args(["cmdline", "provider"]).required(true)))] | ||
| pub struct CliRenderIgnition { | ||
| /// The name of the cloud provider | ||
| #[arg(long, value_name = "name")] | ||
| provider: Option<String>, | ||
| /// Read the cloud provider from the kernel cmdline | ||
| #[arg(long)] | ||
| cmdline: bool, | ||
| /// Directory to write Ignition config fragment files into | ||
| #[arg(long = "render-ignition-dir", value_name = "path")] | ||
| render_ignition_dir: String, | ||
| /// Include hostname in a fragment file | ||
| #[arg(long)] | ||
| hostname: bool, | ||
| /// Include platform user and SSH keys in a fragment file | ||
| #[arg(long)] | ||
| platform_user: bool, | ||
| /// Enable all platform extensions (implies --hostname --platform-user) | ||
| #[arg(long)] | ||
| platform_extensions: bool, | ||
| } | ||
|
|
||
| impl CliRenderIgnition { | ||
| /// Run the `render-ignition` sub-command. | ||
| pub(crate) fn run(self) -> Result<()> { | ||
| let provider_id = super::get_provider(self.provider.as_deref())?; | ||
|
|
||
| let hostname = self.hostname || self.platform_extensions; | ||
| let platform_user = self.platform_user || self.platform_extensions; | ||
|
|
||
| if !hostname && !platform_user { | ||
| slog_scope::warn!("render-ignition: no features specified"); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| let metadata = crate::metadata::fetch_metadata(&provider_id) | ||
| .context("fetching metadata from provider")?; | ||
|
|
||
| if hostname { | ||
| crate::providers::microsoft::azure::config::generate_hostname_fragment( | ||
| metadata.as_ref(), | ||
| &self.render_ignition_dir, | ||
| ) | ||
| .context("generating hostname ignition fragment")?; | ||
| } | ||
|
|
||
| if platform_user { | ||
| crate::providers::microsoft::azure::config::generate_user_fragment( | ||
| &provider_id, | ||
| metadata.as_ref(), | ||
| &self.render_ignition_dir, | ||
| ) | ||
| .context("generating platform-user ignition fragment")?; | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
afterburn-ignition-fragment.serviceis being linked intoignition-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 ofignition-kargs.serviceinstead ofignition-complete.target.