Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ base64 = "0.22"
cfg-if = "1.0"
clap = { version = "4", "default-features" = false, "features" = ["std", "cargo", "derive", "error-context", "help", "suggestions", "usage", "wrap_help"] }
ipnetwork = ">= 0.17, < 0.22"
libc = "0.2"
libflate = "2.1"
libsystemd = ">= 0.2.1, < 0.8.0"
mailparse = ">= 0.13, < 0.17"
maplit = "1.0"
nix = { version = ">= 0.19, < 0.31", "default-features" = false, "features" = [ "mount", "user"] }
openssh-keys = ">= 0.5, < 0.7"
openssl = ">= 0.10.46, < 0.11"
percent-encoding = "2.3.2"
pnet_base = ">= 0.26, < 0.36"
pnet_datalink = ">= 0.26, < 0.36"
reqwest = { version = ">= 0.10, < 0.13", features = [ "blocking" ] }
Expand All @@ -54,6 +56,7 @@ serde-xml-rs = ">= 0.4, < 0.9"
serde_json = "1.0"
serde_yaml = ">= 0.8, < 0.10"
slog = { version = "2.7", features = ["max_level_trace", "release_max_level_info"] }
xml-rs = "0.8"
slog-async = ">= 2.5, < 3"
slog-scope = "4.3"
slog-term = ">= 2.6, < 3"
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nav_order: 8
Major changes:

- KubeVirt: Add support for static and dynamic IP configuration from cloud-init
- Azure: Add `render-ignition` subcommand to generate Ignition config fragments from IMDS metadata
- Hetzner: Add support for network configuration

Minor changes:
Expand Down
26 changes: 26 additions & 0 deletions dracut/30afterburn/afterburn-ignition-fragment.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[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 the Azure IMDS call). Use
# network.target (not network-online.target) to match ignition-fetch.service
# and avoid stalling on multi-NIC DHCP; IMDS is link-local and afterburn
# has its own retry logic.
#
# Run between fetch and disks so writes don't race the fetch stage's parse
# of base.platform.d (Ignition re-reads it every stage; applied at files).
After=network.target
Comment thread
peytonr18 marked this conversation as resolved.
After=ignition-fetch.service
Before=ignition-disks.service

OnFailure=emergency.target
OnFailureJobMode=isolate

[Service]
ExecStartPre=/usr/bin/mkdir -p /etc/ignition/base.platform.d/azure
ExecStart=/usr/bin/afterburn render-ignition --cmdline --render-ignition-dir /etc/ignition/base.platform.d/azure/
Type=oneshot
RemainAfterExit=yes
4 changes: 4 additions & 0 deletions dracut/30afterburn/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ install() {
inst_simple "$moddir/afterburn-network-kargs.service" \
"$systemdutildir/system/afterburn-network-kargs.service"

inst_simple "$moddir/afterburn-ignition-fragment.service" \
"$systemdutildir/system/afterburn-ignition-fragment.service"

# These services are only run once on first-boot, so they piggyback
# on Ignition completion target.
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"
}
56 changes: 56 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use slog_scope::trace;

mod exp;
mod multi;
mod render_ignition;

/// Path to kernel command-line (requires procfs mount).
const CMDLINE_PATH: &str = "/proc/cmdline";
Expand All @@ -19,6 +20,7 @@ pub(crate) enum CliConfig {
Multi(multi::CliMulti),
#[clap(subcommand)]
Exp(exp::CliExp),
RenderIgnition(render_ignition::CliRenderIgnition),
}

impl CliConfig {
Expand All @@ -27,6 +29,7 @@ impl CliConfig {
match self {
CliConfig::Multi(cmd) => cmd.run(),
CliConfig::Exp(cmd) => cmd.run(),
CliConfig::RenderIgnition(cmd) => cmd.run(),
}
}
}
Expand Down Expand Up @@ -231,4 +234,57 @@ mod tests {

parse_args(t3).unwrap();
}

#[test]
fn test_render_ignition_cmd() {
let args: Vec<_> = [
"afterburn",
"render-ignition",
"--provider",
"azure",
"--render-ignition-dir",
"/tmp/fragments",
"--disable-hostname-fragment",
"--disable-user-fragment",
]
.iter()
.map(ToString::to_string)
.collect();

let cmd = parse_args(args).unwrap();
match cmd {
CliConfig::RenderIgnition(_) => {}
x => panic!("unexpected cmd: {x:?}"),
};
}

#[test]
fn test_render_ignition_defaults() {
let args: Vec<_> = [
"afterburn",
"render-ignition",
"--cmdline",
"--render-ignition-dir",
"/tmp/fragments",
]
.iter()
.map(ToString::to_string)
.collect();

let cmd = parse_args(args).unwrap();
match cmd {
CliConfig::RenderIgnition(_) => {}
x => panic!("unexpected cmd: {x:?}"),
};
}

#[test]
fn test_render_ignition_requires_render_ignition_dir() {
let args: Vec<_> = ["afterburn", "render-ignition", "--provider", "azure"]
.iter()
.map(ToString::to_string)
.collect();

parse_args(args).unwrap_err();
}
}
Loading
Loading