1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixing but on version check when the "Apache/2.4.x (Distro)" regex is not met (#27457)

This commit is contained in:
ansibot 2018-09-19 18:10:29 -04:00 committed by GitHub
parent 36ab77d454
commit 534de2df27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,7 +201,7 @@ else:
# balancer member attributes extraction regexp: # balancer member attributes extraction regexp:
EXPRESSION = r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)" EXPRESSION = r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)"
# Apache2 server version extraction regexp: # Apache2 server version extraction regexp:
APACHE_VERSION_EXPRESSION = r"Server Version: Apache/([\d.]+) \(([\w]+)\)" APACHE_VERSION_EXPRESSION = r"SERVER VERSION: APACHE/([\d.]+)"
def regexp_extraction(string, _regexp, groups=1): def regexp_extraction(string, _regexp, groups=1):
@ -317,10 +317,13 @@ class Balancer(object):
self.module.fail_json(msg="Could not get balancer page! HTTP status response: " + str(page[1]['status'])) self.module.fail_json(msg="Could not get balancer page! HTTP status response: " + str(page[1]['status']))
else: else:
content = page[0].read() content = page[0].read()
apache_version = regexp_extraction(content, APACHE_VERSION_EXPRESSION, 1) apache_version = regexp_extraction(content.upper(), APACHE_VERSION_EXPRESSION, 1)
if not re.search(pattern=r"2\.4\.[\d]*", string=apache_version): if apache_version:
self.module.fail_json(msg="This module only acts on an Apache2 2.4+ instance, current Apache2 version: " + str(apache_version)) if not re.search(pattern=r"2\.4\.[\d]*", string=apache_version):
return content self.module.fail_json(msg="This module only acts on an Apache2 2.4+ instance, current Apache2 version: " + str(apache_version))
return content
else:
self.module.fail_json(msg="Could not get the Apache server version from the balancer-manager")
def get_balancer_members(self): def get_balancer_members(self):
""" Returns members of the balancer as a generator object for later iteration.""" """ Returns members of the balancer as a generator object for later iteration."""