Skip to content
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

Edns pass config to system #6102

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion data/anaconda.conf
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ preserved_arguments =
speakup_synth apic noapic apm ide noht acpi video
pci nodmraid nompath nomodeset noiswmd fips selinux
biosdevname ipv6.disable net.ifnames net.ifnames.prefix
nosmt vga
nosmt vga rd.net.dns


[Storage]
Expand Down
14 changes: 14 additions & 0 deletions pyanaconda/modules/network/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class NetworkInstallationTask(Task):
SYSTEMD_NETWORK_CONFIG_DIR = "/etc/systemd/network"
INTERFACE_RENAME_FILE_TEMPLATE = "10-anaconda-ifname-{}.link"
NM_SYSTEM_CONNECTIONS_DIR_PATH = KEYFILE_DIR
NM_GLOBAL_DNS_RUNTIME_CONFIG = "/run/NetworkManager/conf.d/16-global-dns.conf"
NM_GLOBAL_DNS_CONFIG = "/etc/NetworkManager/conf.d/16-global-dns.conf"
INTERFACE_RENAME_FILE_CONTENT_TEMPLATE = """
# Generated by Anaconda based on ifname= installer boot option.
[Match]
Expand Down Expand Up @@ -163,6 +165,7 @@ def run(self):
self._copy_dhclient_config_files(self._sysroot, self._network_ifaces)
if self._configure_persistent_device_names:
self._copy_prefixdevname_files(self._sysroot)
self._copy_global_dns_config(self._sysroot)

def _write_sysconfig_network(self, root, overwrite):
"""Write empty /etc/sysconfig/network target system configuration file.
Expand Down Expand Up @@ -289,6 +292,17 @@ def _copy_prefixdevname_files(self, root):
config_file)
self._copy_file_to_root(root, config_file_path)

def _copy_global_dns_config(self, root):
"""Copy NM global dns configuration to target system.

:param root: path to the root of the target system
:type root: str
"""
src = self.NM_GLOBAL_DNS_RUNTIME_CONFIG
dst = os.path.normpath(root + self.NM_GLOBAL_DNS_CONFIG)
if os.path.isfile(src):
shutil.copy(src, dst)


class ConfigureActivationOnBootTask(Task):
"""Task for configuration of automatic activation of devices on boot"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,8 @@ def _mock_task_paths(self, task):
type(task).NM_SYSTEM_CONNECTIONS_DIR_PATH
task.DHCLIENT_FILE_TEMPLATE = self._mocked_root + type(task).DHCLIENT_FILE_TEMPLATE
task.SYSTEMD_NETWORK_CONFIG_DIR = self._mocked_root + type(task).SYSTEMD_NETWORK_CONFIG_DIR
task.NM_GLOBAL_DNS_RUNTIME_CONFIG = self._mocked_root + type(task).NM_GLOBAL_DNS_RUNTIME_CONFIG
task.NM_GLOBAL_DNS_CONFIG = self._mocked_root + type(task).NM_GLOBAL_DNS_CONFIG

def _create_all_expected_dirs(self):
# Create directories that are expected to be existing in installer
Expand Down Expand Up @@ -1803,3 +1805,49 @@ def test_network_instalation_task_missing_target_dir(self):
bla
"""
)

def test_network_instalation_task_global_dns_config(self):
"""Test the task for network installation and global dns configuration."""

nm_runtime_config_dir, src_file = os.path.split(
NetworkInstallationTask.NM_GLOBAL_DNS_RUNTIME_CONFIG)
nm_config_dir, dst_file = os.path.split(
NetworkInstallationTask.NM_GLOBAL_DNS_CONFIG)

self._create_all_expected_dirs()

self._create_config_dirs(
installer_dirs=[
nm_runtime_config_dir,
nm_config_dir,
],
target_system_dirs=[
nm_config_dir,
]
)

self._dump_config_files(
nm_runtime_config_dir,
((src_file, "bla"),)
)

# Create the task
task = NetworkInstallationTask(
sysroot=self._target_root,
disable_ipv6=False,
overwrite=True,
network_ifaces=["ens3", "ens7"],
ifname_option_values=[],
configure_persistent_device_names=True,
)

self._mock_task_paths(task)
task.run()

self._check_config_file(
nm_config_dir,
dst_file,
"""
bla
"""
)
Loading