Группа :: Система/Настройка/Прочее
Пакет: ansible
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: ansible-alt.patch
Скачать
Скачать
diff --git a/Makefile b/Makefile
index 99bbb6bd5b..3941098473 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ else
ASCII2MAN = @echo "ERROR: rst2man from docutils command is not installed but is required to build $(MANPAGES)" && exit 1
endif
-PYTHON=python
+PYTHON?=python
GENERATE_CLI = hacking/build-ansible.py generate-man
SITELIB = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
diff --git a/lib/ansible/modules/packaging/os/apt_rpm.py b/lib/ansible/modules/packaging/os/apt_rpm.py
index 9c5e8e1d59..26be917c3f 100644
--- a/lib/ansible/modules/packaging/os/apt_rpm.py
+++ b/lib/ansible/modules/packaging/os/apt_rpm.py
@@ -68,6 +68,12 @@ import json
import os
import shlex
import sys
+# md5.py is deprecated since python2.5
+try:
+ import hashlib as md5
+except ImportError:
+ # but we need to be compatible with >= python2.4
+ import md5 as md5
from ansible.module_utils.basic import AnsibleModule
@@ -92,6 +98,15 @@ def query_package_provides(module, name):
return rc == 0
+def query_packages_digest(module):
+ # compute hashsum of all installed package names
+ # returns None on exception
+ rc, out, err = module.run_command("%s -qa" % RPM_PATH, encoding=None)
+ if rc:
+ return None
+ return md5.md5(out).hexdigest()
+
+
def update_package_db(module):
rc, out, err = module.run_command("%s update" % APT_PATH)
@@ -125,11 +140,11 @@ def install_packages(module, pkgspec):
packages = ""
for package in pkgspec:
- if not query_package_provides(module, package):
- packages += "'%s' " % package
+ packages += "'%s' " % package
if len(packages) != 0:
+ chksum = query_packages_digest(module)
rc, out, err = module.run_command("%s -y install %s" % (APT_PATH, packages))
installed = True
@@ -141,7 +156,14 @@ def install_packages(module, pkgspec):
if rc or not installed:
module.fail_json(msg="'apt-get -y install %s' failed: %s" % (packages, err))
else:
- module.exit_json(changed=True, msg="%s present(s)" % packages)
+ if chksum:
+ newchksum = query_packages_digest(module)
+ if chksum != newchksum:
+ module.exit_json(changed=True, msg="Some packages installed/upgraded")
+ else:
+ module.exit_json(changed=False, msg="No packages installed/upgraded")
+ else:
+ module.exit_json(changed=True, msg="%s present(s)" % packages)
else:
module.exit_json(changed=False)