mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
- Introduced a new Chinese version of the README file (README_zh-CN.md) to enhance accessibility for Chinese-speaking users. - Updated the English README to reflect new features and installation instructions. - Added detailed documentation for project structure, playbooks, roles, tasks, and modules to improve user understanding and usability. Signed-off-by: [Your Name] <[Your Email]> Signed-off-by: redscholar <blacktiledhouse@gmail.com>
1.4 KiB
1.4 KiB
assert Module
The assert module allows users to perform assertions on parameter conditions.
Parameters
| Parameter | Description | Type | Required | Default |
|---|---|---|---|---|
| that | Assertion condition. Must use template syntax. | Array or string | Yes | - |
| success_msg | Message output to task result stdout when the assertion evaluates to true. | String | No | True |
| fail_msg | Message output to task result stderr when the assertion evaluates to false. | String | No | False |
| msg | Same as fail_msg. Lower priority than fail_msg. | String | No | False |
Usage Examples
- Assertion condition as a string
- name: assert single condition
assert:
that: eq 1 1
Task execution result:
stdout: "True"
stderr: ""
- Assertion condition as an array
- name: assert multi-condition
assert:
that:
- eq 1 1
- eq 1 2
Task execution result:
stdout: "False"
stderr: "False"
- Set custom success output
- name: assert is succeed
assert:
that: eq 1 1
success_msg: "It's succeed"
Task execution result:
stdout: "It's succeed"
stderr: ""
- Set custom failure output
- name: assert is failed
assert:
that: eq 1 2
fail_msg: "It's failed"
msg: "It's failed!"
Task execution result:
stdout: "False"
stderr: "It's failed"