@ -30,6 +30,7 @@ import base64
import sys
import sys
import shlex
import shlex
import pipes
import pipes
import re
import ansible . constants as C
import ansible . constants as C
import ansible . inventory
import ansible . inventory
@ -128,7 +129,8 @@ class Runner(object):
check = False , # don't make any changes, just try to probe for potential changes
check = False , # don't make any changes, just try to probe for potential changes
diff = False , # whether to show diffs for template files that change
diff = False , # whether to show diffs for template files that change
environment = None , # environment variables (as dict) to use inside the command
environment = None , # environment variables (as dict) to use inside the command
complex_args = None # structured data in addition to module_args, must be a dict
complex_args = None , # structured data in addition to module_args, must be a dict
error_on_undefined_vars = C . DEFAULT_UNDEFINED_VAR_BEHAVIOR # ex. False
) :
) :
if not complex_args :
if not complex_args :
@ -163,6 +165,7 @@ class Runner(object):
self . is_playbook = is_playbook
self . is_playbook = is_playbook
self . environment = environment
self . environment = environment
self . complex_args = complex_args
self . complex_args = complex_args
self . error_on_undefined_vars = error_on_undefined_vars
self . callbacks . runner = self
self . callbacks . runner = self
@ -673,8 +676,16 @@ class Runner(object):
# *****************************************************
# *****************************************************
def _contains_undefined_vars ( self , module_args ) :
''' return true if there are undefined variables '''
return ' {{ ' in module_args
def _copy_module ( self , conn , tmp , module_name , module_args , inject , complex_args = None ) :
def _copy_module ( self , conn , tmp , module_name , module_args , inject , complex_args = None ) :
''' transfer a module over SFTP, does not run it '''
''' transfer a module over SFTP, does not run it '''
if self . error_on_undefined_vars and self . _contains_undefined_vars ( module_args ) :
vars = re . findall ( r ' {{ (.*?)}} ' , module_args )
raise errors . AnsibleUndefinedVariable ( " Undefined variables: %s " %
' , ' . join ( vars ) )
# FIXME if complex args is none, set to {}
# FIXME if complex args is none, set to {}