@ -18,7 +18,7 @@ from ansible import context
from ansible . errors import AnsibleError , AnsibleParserError , AnsibleUndefinedVariable , AnsibleAssertionError
from ansible . errors import AnsibleError , AnsibleParserError , AnsibleUndefinedVariable , AnsibleAssertionError
from ansible . module_utils . six import string_types
from ansible . module_utils . six import string_types
from ansible . module_utils . parsing . convert_bool import boolean
from ansible . module_utils . parsing . convert_bool import boolean
from ansible . module_utils . common . text . converters import to_text , to_native
from ansible . module_utils . common . text . converters import to_text
from ansible . parsing . dataloader import DataLoader
from ansible . parsing . dataloader import DataLoader
from ansible . playbook . attribute import Attribute , FieldAttribute , ConnectionFieldAttribute , NonInheritableFieldAttribute
from ansible . playbook . attribute import Attribute , FieldAttribute , ConnectionFieldAttribute , NonInheritableFieldAttribute
from ansible . plugins . loader import module_loader , action_loader
from ansible . plugins . loader import module_loader , action_loader
@ -560,14 +560,14 @@ class FieldAttributeBase:
setattr ( self , name , value )
setattr ( self , name , value )
except ( TypeError , ValueError ) as e :
except ( TypeError , ValueError ) as e :
value = getattr ( self , name )
value = getattr ( self , name )
raise AnsibleParserError ( " the field ' %s' has an invalid value ( %s ), and could not be converted to %s . "
raise AnsibleParserError ( f " the field ' {name } ' has an invalid value ( { value !r} ), and could not be converted to { attribute . isa } . " ,
" The error was: %s " % ( name , value , attribute . isa , e ) , obj = self . get_ds ( ) , orig_exc = e )
obj = self . get_ds ( ) , orig_exc = e )
except ( AnsibleUndefinedVariable , UndefinedError ) as e :
except ( AnsibleUndefinedVariable , UndefinedError ) as e :
if templar . _fail_on_undefined_errors and name != ' name ' :
if templar . _fail_on_undefined_errors and name != ' name ' :
if name == ' args ' :
if name == ' args ' :
msg = " The task includes an option with an undefined variable. The error was: %s " % ( to_native ( e ) )
msg = " The task includes an option with an undefined variable. "
else :
else :
msg = " The field ' %s ' has an invalid value, which includes an undefined variable. The error was: %s " % ( name , to_native ( e ) )
msg = f " The field ' {name } ' has an invalid value, which includes an undefined variable. "
raise AnsibleParserError ( msg , obj = self . get_ds ( ) , orig_exc = e )
raise AnsibleParserError ( msg , obj = self . get_ds ( ) , orig_exc = e )
self . _finalized = True
self . _finalized = True