mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-22 17:09:08 -07:00
Make package version comparison use globbing.
I have something like: apt: pkg={{ item }} state=present with_items: - python-pysqlite2=2.6.3-* - python-paramiko=1.7.7.1-* But due to the use of *'s in the version specifications, the apt ansible module always reports changed: true. This patch fixes that.
This commit is contained in:
parent
ff3625b0c9
commit
c7ebe44780
1 changed files with 3 additions and 2 deletions
|
@ -115,6 +115,7 @@ warnings.filterwarnings('ignore', "apt API not stable yet", FutureWarning)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
import fnmatch
|
||||||
|
|
||||||
# APT related constants
|
# APT related constants
|
||||||
APTITUDE_CMD = "aptitude"
|
APTITUDE_CMD = "aptitude"
|
||||||
|
@ -143,10 +144,10 @@ def package_status(m, pkgname, version, cache, state):
|
||||||
return False, False
|
return False, False
|
||||||
if version:
|
if version:
|
||||||
try :
|
try :
|
||||||
return pkg.is_installed and pkg.installed.version == version, False
|
return pkg.is_installed and fnmatch.fnmatch(pkg.installed.version, version), False
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
#assume older version of python-apt is installed
|
#assume older version of python-apt is installed
|
||||||
return pkg.isInstalled and pkg.installedVersion == version, False
|
return pkg.isInstalled and fnmatch.fnmatch(pkg.installedVersion, version), False
|
||||||
else:
|
else:
|
||||||
try :
|
try :
|
||||||
return pkg.is_installed, pkg.is_upgradable
|
return pkg.is_installed, pkg.is_upgradable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue