From 07738cc84807bdf4c1b4e911a36eab22b8825b1d Mon Sep 17 00:00:00 2001 From: HD650 Date: Mon, 18 Jun 2018 15:01:38 -0400 Subject: [PATCH] Improve code style --- lib/ansible/modules/utilities/logic/assert.py | 8 ++++---- lib/ansible/plugins/action/assert.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/utilities/logic/assert.py b/lib/ansible/modules/utilities/logic/assert.py index e2a515e8c92..b45bb729870 100644 --- a/lib/ansible/modules/utilities/logic/assert.py +++ b/lib/ansible/modules/utilities/logic/assert.py @@ -53,16 +53,16 @@ EXAMPLES = ''' - "'foo' in some_command_result.stdout" - "number_of_the_counting == 3" -# after version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message -- assert: +- name: after version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message + assert: that: - "my_param <= 100" - "my_param >= 0" fail_msg: "'my_param' must be between 0 and 100" success_msg: "'my_param' is between 0 and 100" -# please use 'msg' when ansible version is smaller than 2.7 -- assert: +- name: please use 'msg' when ansible version is smaller than 2.7 + assert: that: - "my_param <= 100" - "my_param >= 0" diff --git a/lib/ansible/plugins/action/assert.py b/lib/ansible/plugins/action/assert.py index b8ebcbec62e..7c958443b62 100644 --- a/lib/ansible/plugins/action/assert.py +++ b/lib/ansible/plugins/action/assert.py @@ -44,13 +44,13 @@ class ActionModule(ActionBase): fail_msg = self._task.args.get('fail_msg', self._task.args.get('msg')) if fail_msg is None: fail_msg = 'Assertion failed' - if not isinstance(fail_msg, string_types): + elif not isinstance(fail_msg, string_types): raise AnsibleError('Incorrect type for fail_msg or msg, expected string and got %s' % type(fail_msg)) success_msg = self._task.args.get('success_msg') if success_msg is None: success_msg = 'All assertions passed' - if not isinstance(success_msg, string_types): + elif not isinstance(success_msg, string_types): raise AnsibleError('Incorrect type for success_msg, expected string and got %s' % type(success_msg)) # make sure the 'that' items are a list