@ -24,7 +24,8 @@ import re
import time
import time
from ansible . errors import AnsibleError
from ansible . errors import AnsibleError
from ansible . module_utils . _text import to_text , to_bytes
from ansible . module_utils . _text import to_text , to_bytes , to_native
from ansible . module_utils . common import validation
from ansible . module_utils . connection import Connection
from ansible . module_utils . connection import Connection
from ansible . plugins . action import ActionBase
from ansible . plugins . action import ActionBase
from ansible . utils . display import Display
from ansible . utils . display import Display
@ -58,9 +59,9 @@ class ActionModule(ActionBase):
file_pull_timeout = dict ( type = ' int ' , default = 300 ) ,
file_pull_timeout = dict ( type = ' int ' , default = 300 ) ,
file_pull_compact = dict ( type = ' bool ' , default = False ) ,
file_pull_compact = dict ( type = ' bool ' , default = False ) ,
file_pull_kstack = dict ( type = ' bool ' , default = False ) ,
file_pull_kstack = dict ( type = ' bool ' , default = False ) ,
local_file = dict ( type = ' str ' ) ,
local_file = dict ( type = ' path ' ) ,
local_file_directory = dict ( type = ' str ' ) ,
local_file_directory = dict ( type = ' path ' ) ,
remote_file = dict ( type = ' str ' ) ,
remote_file = dict ( type = ' path ' ) ,
remote_scp_server = dict ( type = ' str ' ) ,
remote_scp_server = dict ( type = ' str ' ) ,
remote_scp_server_user = dict ( type = ' str ' ) ,
remote_scp_server_user = dict ( type = ' str ' ) ,
remote_scp_server_password = dict ( no_log = True ) ,
remote_scp_server_password = dict ( no_log = True ) ,
@ -72,24 +73,23 @@ class ActionModule(ActionBase):
playvals [ key ] = self . _task . args . get ( key , argument_spec [ key ] . get ( ' default ' ) )
playvals [ key ] = self . _task . args . get ( key , argument_spec [ key ] . get ( ' default ' ) )
if playvals [ key ] is None :
if playvals [ key ] is None :
continue
continue
if argument_spec [ key ] . get ( ' type ' ) is None :
argument_spec [ key ] [ ' type ' ] = ' str '
option_type = argument_spec [ key ] . get ( ' type ' , ' str ' )
type_ok = False
try :
type = argument_spec [ key ] [ ' type ' ]
if option_type == ' str ' :
if type == ' str ' :
playvals [ key ] = validation . check_type_str ( playvals [ key ] )
if isinstance ( playvals [ key ] , six . string_types ) :
elif option_type == ' int ' :
type_ok = True
playvals [ key ] = validation . check_type_int ( playvals [ key ] )
elif type == ' int ' :
elif option_type == ' bool ' :
if isinstance ( playvals [ key ] , int ) :
playvals [ key ] = validation . check_type_bool ( playvals [ key ] )
type_ok = True
elif option_type == ' path ' :
elif type == ' bool ' :
playvals [ key ] = validation . check_type_path ( playvals [ key ] )
if isinstance ( playvals [ key ] , bool ) :
type_ok = True
else :
else :
raise AnsibleError ( ' Unrecognized type < {0} > for playbook parameter < {1} > ' . format ( type , key ) )
raise AnsibleError ( ' Unrecognized type < {0} > for playbook parameter < {1} > ' . format ( type , key ) )
if not type_ok :
except ( TypeError , ValueError ) as e :
raise AnsibleError ( ' Playbook parameter < {0} > value should be of type < {1} > ' . format ( key , type ) )
raise AnsibleError ( " argument %s is of type %s and we were unable to convert to %s : %s "
% ( key , type ( playvals [ key ] ) , option_type , to_native ( e ) ) )
# Validate playbook dependencies
# Validate playbook dependencies
if playvals [ ' file_pull ' ] :
if playvals [ ' file_pull ' ] :