Skip to content
Permalink
Browse files

[debops.apache] Fix fact script on Python3

  • Loading branch information...
drybjed committed Aug 11, 2019
1 parent df36944 commit 98e9b7915638ba66ea6ad425d7161e0edac4cdc0
Showing with 10 additions and 5 deletions.
  1. +10 −5 ansible/roles/debops.apache/templates/etc/ansible/facts.d/apache.fact.j2
@@ -15,15 +15,20 @@ output = loads('''{{ ({
}) | to_nice_json }}''')

try:
for line in subprocess.check_output(['apache2', '-v']).split('\n'):
apache_v = subprocess.check_output(
['apache2', '-v']).decode('utf-8').split('\n')

for line in apache_v:
_re = re.match(r'Server version: Apache/(?P<version>[^ ]+)', line)
if _re:
output['version'] = _re.group('version')

if output['use_if_version']:
if output['min_version'] == 'current_major_minor':
output['min_version'] = '.'.join(
output['version'].split('.')[:2])

except Exception:
pass

if output['use_if_version']:
if output['min_version'] == 'current_major_minor':
output['min_version'] = '.'.join(output['version'].split('.')[:2])

print(dumps(output, sort_keys=True, indent=2))

0 comments on commit 98e9b79

Please sign in to comment.
You can’t perform that action at this time.