For AC-332. Added support to inventory script view, inventory script and task engine to include hostvars inline when using Ansible >= 1.3.

This commit is contained in:
Chris Church
2013-08-27 00:08:54 -04:00
parent 2bb5374685
commit 0129036b40
7 changed files with 164 additions and 4 deletions

View File

@@ -1,13 +1,17 @@
# Copyright (c) 2013 AnsibleWorks, Inc.
# All Rights Reserved.
# Python
import logging
import re
import subprocess
import sys
# Django REST Framework
from rest_framework.exceptions import ParseError, PermissionDenied
__all__ = ['get_object_or_400', 'get_object_or_403', 'camelcase_to_underscore',
'get_awx_version']
'get_ansible_version', 'get_awx_version']
def get_object_or_400(klass, *args, **kwargs):
'''
@@ -53,6 +57,18 @@ class RequireDebugTrueOrTest(logging.Filter):
from django.conf import settings
return settings.DEBUG or 'test' in sys.argv
def get_ansible_version():
'''
Return Ansible version installed.
'''
try:
proc = subprocess.Popen(['ansible', '--version'],
stdout=subprocess.PIPE)
result = proc.communicate()[0]
return result.lower().replace('ansible', '').strip()
except:
return 'unknown'
def get_awx_version():
'''
Return AWX version as reported by setuptools.