-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from cisagov/bugfix/fix-bookworm-dhcp-searh-do…
…main-issue Fix Bookworm DHCP search domain issue
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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,37 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Append the necessary DHCP options to the Netplan configuration. | ||
The Netplan configuration is created by cloud-init, but it needs to be | ||
slightly modified and reapplied. This script takes care of the | ||
modification. | ||
See these issues for more details: | ||
- cisagov/skeleton-packer#300 | ||
- canonical/cloud-init#4764 | ||
This file is a template. It should be processed by Terraform. | ||
""" | ||
|
||
# TODO: Remove this script when and if that becomes possible. See #96 | ||
# for more details. | ||
|
||
# Third-Party Libraries | ||
import yaml | ||
|
||
# Inputs from Terraform | ||
NETPLAN_CONFIG = "${netplan_config}" | ||
|
||
with open(NETPLAN_CONFIG) as f: | ||
# Load the current Netplan configuration | ||
config = yaml.safe_load(f) | ||
# Add a dhcp4-overrides section to each network | ||
config["network"]["ethernets"] = { | ||
k: v | {"dhcp4-overrides": {"use-domains": True}} | ||
for (k, v) in config["network"]["ethernets"].items() | ||
} | ||
|
||
# Write the results back out to the Netplan configuration file | ||
with open(NETPLAN_CONFIG, "w") as f: | ||
f.write(yaml.dump(config)) |
This file contains 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,10 @@ | ||
--- | ||
|
||
# There is a Python script that fixes the DHCP4 options in the netplan | ||
# configuration already generated by cloud-init. The following simply | ||
# reapplies the Netplan configuration after the modification. | ||
# | ||
# TODO: Remove this code when and if that becomes possible. See #96 | ||
# for more details. | ||
runcmd: | ||
- [netplan, apply] |