From a3cfe0d72f1d206aed9895be322625c7595ef71d Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Wed, 23 May 2018 14:43:18 +0200 Subject: [PATCH] apt: don't markmanual if apt-mark is not installed (#40600) * apt: don't markmanual if apt-mark is not installed * Add warning --- lib/ansible/modules/packaging/os/apt.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index 2bb6712d816..717403be943 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -492,7 +492,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)