Rename argument msg to fail msg

This change make the arguments of assert less ambiguous.
This commit is contained in:
zhikangzhang 2018-06-14 13:35:15 -04:00 committed by Zhikang Zhang
parent 065d9ed6ac
commit 2333b4474c
2 changed files with 12 additions and 7 deletions

View file

@ -27,9 +27,11 @@ options:
- "A string expression of the same form that can be passed to the 'when' statement" - "A string expression of the same form that can be passed to the 'when' statement"
- "Alternatively, a list of string expressions" - "Alternatively, a list of string expressions"
required: true required: true
msg: fail_msg:
description: description:
- "The customized message used for a failing assertion" - "The customized message used for a failing assertion"
aliases:
- msg
success_msg: success_msg:
version_added: "2.7" version_added: "2.7"
description: description:
@ -53,6 +55,6 @@ EXAMPLES = '''
that: that:
- "my_param <= 100" - "my_param <= 100"
- "my_param >= 0" - "my_param >= 0"
msg: "'my_param' must be between 0 and 100" fail_msg: "'my_param' must be between 0 and 100"
success_msg: "'my_param' is between 0 and 100" success_msg: "'my_param' is between 0 and 100"
''' '''

View file

@ -38,10 +38,13 @@ class ActionModule(ActionBase):
if 'that' not in self._task.args: if 'that' not in self._task.args:
raise AnsibleError('conditional required in "that" string') raise AnsibleError('conditional required in "that" string')
msg = None fail_msg = None
success_msg = None success_msg = None
if 'msg' in self._task.args and isinstance(self._task.args['msg'], string_types): if 'fail_msg' in self._task.args and isinstance(self._task.args['fail_msg'], string_types):
msg = self._task.args['msg'] fail_msg = self._task.args['fail_msg']
elif 'msg' in self._task.args and isinstance(self._task.args['msg'], string_types):
fail_msg = self._task.args['msg']
if 'success_msg' in self._task.args and isinstance(self._task.args['success_msg'], string_types): if 'success_msg' in self._task.args and isinstance(self._task.args['success_msg'], string_types):
success_msg = self._task.args['success_msg'] success_msg = self._task.args['success_msg']
@ -65,8 +68,8 @@ class ActionModule(ActionBase):
result['evaluated_to'] = test_result result['evaluated_to'] = test_result
result['assertion'] = that result['assertion'] = that
if msg: if fail_msg:
result['msg'] = msg result['msg'] = fail_msg
return result return result