Skip to content

Commit

Permalink
Fixing but on version check when the "Apache/2.4.x (Distro)" regex is…
Browse files Browse the repository at this point in the history
… not met (ansible#27457)
  • Loading branch information
ansibot authored Sep 19, 2018
1 parent 36ab77d commit 534de2d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/ansible/modules/web_infrastructure/apache2_mod_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
# balancer member attributes extraction regexp:
EXPRESSION = r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)"
# 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):
Expand Down Expand Up @@ -317,10 +317,13 @@ def fetch_balancer_page(self):
self.module.fail_json(msg="Could not get balancer page! HTTP status response: " + str(page[1]['status']))
else:
content = page[0].read()
apache_version = regexp_extraction(content, APACHE_VERSION_EXPRESSION, 1)
if not re.search(pattern=r"2\.4\.[\d]*", string=apache_version):
self.module.fail_json(msg="This module only acts on an Apache2 2.4+ instance, current Apache2 version: " + str(apache_version))
return content
apache_version = regexp_extraction(content.upper(), APACHE_VERSION_EXPRESSION, 1)
if apache_version:
if not re.search(pattern=r"2\.4\.[\d]*", string=apache_version):
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):
""" Returns members of the balancer as a generator object for later iteration."""
Expand Down

0 comments on commit 534de2d

Please sign in to comment.