|
|
@ -219,6 +219,7 @@ EXPRESSION = r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d
|
|
|
|
# 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.]+) \(([\w]+)\)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def regexp_extraction(string, _regexp, groups=1):
|
|
|
|
def regexp_extraction(string, _regexp, groups=1):
|
|
|
|
""" Returns the capture group (default=1) specified in the regexp, applied to the string """
|
|
|
|
""" Returns the capture group (default=1) specified in the regexp, applied to the string """
|
|
|
|
regexp_search = re.search(string=str(string), pattern=str(_regexp))
|
|
|
|
regexp_search = re.search(string=str(string), pattern=str(_regexp))
|
|
|
@ -227,6 +228,7 @@ def regexp_extraction(string, _regexp, groups=1):
|
|
|
|
return str(regexp_search.group(groups))
|
|
|
|
return str(regexp_search.group(groups))
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BalancerMember(object):
|
|
|
|
class BalancerMember(object):
|
|
|
|
""" Apache 2.4 mod_proxy LB balancer member.
|
|
|
|
""" Apache 2.4 mod_proxy LB balancer member.
|
|
|
|
attributes:
|
|
|
|
attributes:
|
|
|
@ -276,10 +278,10 @@ class BalancerMember(object):
|
|
|
|
|
|
|
|
|
|
|
|
def get_member_status(self):
|
|
|
|
def get_member_status(self):
|
|
|
|
""" Returns a dictionary of a balancer member's status attributes."""
|
|
|
|
""" Returns a dictionary of a balancer member's status attributes."""
|
|
|
|
status_mapping = {'disabled':'Dis',
|
|
|
|
status_mapping = {'disabled': 'Dis',
|
|
|
|
'drained':'Drn',
|
|
|
|
'drained': 'Drn',
|
|
|
|
'hot_standby':'Stby',
|
|
|
|
'hot_standby': 'Stby',
|
|
|
|
'ignore_errors':'Ign'}
|
|
|
|
'ignore_errors': 'Ign'}
|
|
|
|
status = {}
|
|
|
|
status = {}
|
|
|
|
actual_status = str(self.attributes['Status'])
|
|
|
|
actual_status = str(self.attributes['Status'])
|
|
|
|
for mode in status_mapping.keys():
|
|
|
|
for mode in status_mapping.keys():
|
|
|
@ -291,10 +293,10 @@ class BalancerMember(object):
|
|
|
|
|
|
|
|
|
|
|
|
def set_member_status(self, values):
|
|
|
|
def set_member_status(self, values):
|
|
|
|
""" Sets a balancer member's status attributes amongst pre-mapped values."""
|
|
|
|
""" Sets a balancer member's status attributes amongst pre-mapped values."""
|
|
|
|
values_mapping = {'disabled':'&w_status_D',
|
|
|
|
values_mapping = {'disabled': '&w_status_D',
|
|
|
|
'drained':'&w_status_N',
|
|
|
|
'drained': '&w_status_N',
|
|
|
|
'hot_standby':'&w_status_H',
|
|
|
|
'hot_standby': '&w_status_H',
|
|
|
|
'ignore_errors':'&w_status_I'}
|
|
|
|
'ignore_errors': '&w_status_I'}
|
|
|
|
|
|
|
|
|
|
|
|
request_body = regexp_extraction(self.management_url, EXPRESSION, 1)
|
|
|
|
request_body = regexp_extraction(self.management_url, EXPRESSION, 1)
|
|
|
|
for k in values_mapping.keys():
|
|
|
|
for k in values_mapping.keys():
|
|
|
@ -315,6 +317,7 @@ class BalancerMember(object):
|
|
|
|
|
|
|
|
|
|
|
|
class Balancer(object):
|
|
|
|
class Balancer(object):
|
|
|
|
""" Apache httpd 2.4 mod_proxy balancer object"""
|
|
|
|
""" Apache httpd 2.4 mod_proxy balancer object"""
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, host, suffix, module, members=None, tls=False):
|
|
|
|
def __init__(self, host, suffix, module, members=None, tls=False):
|
|
|
|
if tls:
|
|
|
|
if tls:
|
|
|
|
self.base_url = str(str('https://') + str(host))
|
|
|
|
self.base_url = str(str('https://') + str(host))
|
|
|
@ -359,6 +362,7 @@ class Balancer(object):
|
|
|
|
|
|
|
|
|
|
|
|
members = property(get_balancer_members)
|
|
|
|
members = property(get_balancer_members)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
""" Initiates module."""
|
|
|
|
""" Initiates module."""
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
@ -414,7 +418,7 @@ def main():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
member_exists = False
|
|
|
|
member_exists = False
|
|
|
|
member_status = {'disabled': False, 'drained': False, 'hot_standby': False, 'ignore_errors':False}
|
|
|
|
member_status = {'disabled': False, 'drained': False, 'hot_standby': False, 'ignore_errors': False}
|
|
|
|
for mode in member_status.keys():
|
|
|
|
for mode in member_status.keys():
|
|
|
|
for state in states:
|
|
|
|
for state in states:
|
|
|
|
if mode == state:
|
|
|
|
if mode == state:
|
|
|
|