From dcf95a3adc70abebef44e2005698ed85cf0d3ff7 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 3 Jul 2018 21:01:36 +0200 Subject: [PATCH] Backport 2.5: apt: fix apt-mark on debian6 (#41724) * apt: fix apt-mark on debian6 (#41530) (cherry picked from commit 2e68811c34c382c8f8f5d6223b30a79e9fbd8e67) * Add changelog/fragment --- changelogs/fragments/41530-apt-mark-deb6.yaml | 2 ++ lib/ansible/modules/packaging/os/apt.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/41530-apt-mark-deb6.yaml diff --git a/changelogs/fragments/41530-apt-mark-deb6.yaml b/changelogs/fragments/41530-apt-mark-deb6.yaml new file mode 100644 index 00000000000..43ab5c57f26 --- /dev/null +++ b/changelogs/fragments/41530-apt-mark-deb6.yaml @@ -0,0 +1,2 @@ +bugfixes: + - apt: fix apt-mark on debian6 (https://github.com/ansible/ansible/pull/41530) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index cd0d99dc5c4..9c06d0347d8 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -275,6 +275,7 @@ APTITUDE_ZERO = "\n0 packages upgraded, 0 newly installed" APT_LISTS_PATH = "/var/lib/apt/lists" APT_UPDATE_SUCCESS_STAMP_PATH = "/var/lib/apt/periodic/update-success-stamp" APT_MARK_INVALID_OP = 'Invalid operation' +APT_MARK_INVALID_OP_DEB6 = 'Usage: apt-mark [options] {markauto|unmarkauto} packages' HAS_PYTHON_APT = True try: @@ -483,7 +484,7 @@ def mark_installed_manually(m, packages): cmd = "%s manual %s" % (apt_mark_cmd_path, ' '.join(packages)) rc, out, err = m.run_command(cmd) - if APT_MARK_INVALID_OP in err: + if APT_MARK_INVALID_OP in err or APT_MARK_INVALID_OP_DEB6 in err: cmd = "%s unmarkauto %s" % (apt_mark_cmd_path, ' '.join(packages)) rc, out, err = m.run_command(cmd)