-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ensure to disable RHUI in cdn package
The redhat-cloud-client-configuration-cdn binary package will ensure that the system does not get content via RHUI by default, in case it is installed, as that is what the automatic registration of subscription-manager will provide. Because of that: - create /var/lib/rhui/disable-rhui on installation (removing it on removal) to tell RHUI to not enable any repository; this happens during the upgrade of the RHUI packages - create a boot systemd service that runs a script which tries to disable all the non-public RHUI repositories available (typically the RHEL repositories) - both the systemd service and the script should work also when RHUI is not installed - the service will run only once when /etc/rhccc-firstboot-run is available Signed-off-by: Pino Toscano <[email protected]>
- Loading branch information
Showing
4 changed files
with
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enable rhccc-disable-rhui-repos.service |
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,42 @@ | ||
#!/usr/bin/python3 | ||
|
||
import configparser | ||
import pathlib | ||
import sys | ||
|
||
|
||
def process_repo(p): | ||
config = configparser.ConfigParser(interpolation=None) | ||
try: | ||
with p.open() as f: | ||
config.read_file(f, str(p)) | ||
changed = 0 | ||
for section in config.sections(): | ||
try: | ||
url = config.get(section, "mirrorlist", fallback=None) or config.get( | ||
section, "baseurl" | ||
) | ||
if "/rhui/" in url and config.getboolean( | ||
section, "enabled", fallback=True | ||
): | ||
config.set(section, "enabled", "0") | ||
changed += 1 | ||
except configparser.NoOptionError as e: | ||
print(f"Warning when processing {p}: {e}", file=sys.stderr) | ||
if changed > 0: | ||
with p.open("w") as f: | ||
config.write(f, space_around_delimiters=False) | ||
print(f"Disabled {changed} repositories in {p}") | ||
except Exception as e: | ||
print(f"Error when processing {p}: {e}", file=sys.stderr) | ||
|
||
|
||
if __name__ == "__main__": | ||
for arg in sys.argv[1:]: | ||
p = pathlib.Path(arg) | ||
if p.is_file(): | ||
process_repo(p) | ||
elif p.is_dir(): | ||
for child in p.iterdir(): | ||
if child.suffix == ".repo": | ||
process_repo(child) |
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,14 @@ | ||
[Unit] | ||
Description=Run disable-rhui-repos on first boot | ||
ConditionPathExists=/etc/rhccc-firstboot-run | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/rm /etc/rhccc-firstboot-run | ||
ExecStart=-/usr/bin/touch /var/lib/rhui/disable-rhui | ||
ExecStart=@libexecdir@/rhccc-disable-rhui-repos.py /etc/yum.repos.d/ | ||
|
||
[Install] | ||
WantedBy=multi-user.target |