1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

filter out ansible_* facts from provision callback extra_vars

related to #4358
This commit is contained in:
Chris Meyers 2016-12-15 15:37:56 -05:00
parent 7f1591361b
commit 55827611b6
2 changed files with 15 additions and 2 deletions

View File

@ -65,6 +65,9 @@ from awx.api.generics import * # noqa
from awx.conf.license import get_license, feature_enabled, feature_exists, LicenseForbids
from awx.main.models import * # noqa
from awx.main.utils import * # noqa
from awx.main.utils import (
callback_filter_out_ansible_extra_vars
)
from awx.api.permissions import * # noqa
from awx.api.renderers import * # noqa
from awx.api.serializers import * # noqa
@ -2663,7 +2666,7 @@ class JobTemplateCallback(GenericAPIView):
# Send a signal to celery that the job should be started.
kv = {"inventory_sources_already_updated": inventory_sources_already_updated}
if extra_vars is not None:
kv['extra_vars'] = extra_vars
kv['extra_vars'] = callback_filter_out_ansible_extra_vars(extra_vars)
result = job.signal_start(**kv)
if not result:
data = dict(msg=_('Error starting job!'))

View File

@ -43,7 +43,8 @@ __all__ = ['get_object_or_400', 'get_object_or_403', 'camelcase_to_underscore',
'copy_m2m_relationships' ,'cache_list_capabilities', 'to_python_boolean',
'ignore_inventory_computed_fields', 'ignore_inventory_group_removal',
'_inventory_updates', 'get_pk_from_dict', 'getattrd', 'NoDefaultProvided',
'get_current_apps', 'set_current_apps', 'OutputEventFilter']
'get_current_apps', 'set_current_apps', 'OutputEventFilter',
'callback_filter_out_ansible_extra_vars',]
def get_object_or_400(klass, *args, **kwargs):
@ -824,3 +825,12 @@ class OutputEventFilter(object):
self._current_event_data = next_event_data
else:
self._current_event_data = None
def callback_filter_out_ansible_extra_vars(extra_vars):
extra_vars_redacted = {}
for key, value in extra_vars.iteritems():
if not key.startswith('ansible_'):
extra_vars_redacted[key] = value
return extra_vars_redacted