From 18581adbb5406737dbba0e14e878f921bc93c6f0 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 24 May 2018 09:27:38 +0200 Subject: [PATCH] Backport: apt: don't markmanual if apt-mark is not installed (#40605) (cherry picked from commit a3cfe0d72f1d206aed9895be322625c7595ef71d) --- changelogs/fragments/40600-apt-mark-availability.yml | 2 ++ lib/ansible/modules/packaging/os/apt.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/40600-apt-mark-availability.yml diff --git a/changelogs/fragments/40600-apt-mark-availability.yml b/changelogs/fragments/40600-apt-mark-availability.yml new file mode 100644 index 00000000000..ddbca0e26a6 --- /dev/null +++ b/changelogs/fragments/40600-apt-mark-availability.yml @@ -0,0 +1,2 @@ +bugfixes: +- skip marking packages as manually installed when apt-mark is not available (https://github.com/ansible/ansible/pull/40600) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index dbf8b09d077..cd0d99dc5c4 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -473,7 +473,13 @@ def mark_installed_manually(m, packages): if not packages: return - apt_mark_cmd_path = m.get_bin_path("apt-mark", required=True) + apt_mark_cmd_path = m.get_bin_path("apt-mark") + + # https://github.com/ansible/ansible/issues/40531 + if apt_mark_cmd_path is None: + m.warn("Could not find apt-mark binary, not marking package(s) as manually installed.") + return + cmd = "%s manual %s" % (apt_mark_cmd_path, ' '.join(packages)) rc, out, err = m.run_command(cmd)