Properly upgrade Debian based systems unattended

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-07-27 13:43:12 +01:00 committed by Pedro Algarvio
parent 4a4312159c
commit a9bbfd0e47

View file

@ -52,7 +52,18 @@ def _system_up_to_date(
if grains["os_family"] == "Debian":
ret = shell.run("apt", "update")
assert ret.returncode == 0
ret = shell.run("apt", "upgrade", "-y")
env = os.environ.copy()
env["DEBIAN_FRONTEND"] = "noninteractive"
ret = shell.run(
"apt",
"upgrade",
"-y",
"-o",
"DPkg::Options::=--force-confdef",
"-o",
"DPkg::Options::=--force-confold",
env=env,
)
assert ret.returncode == 0
elif grains["os_family"] == "Redhat":
ret = shell.run("yum", "update", "-y")