kubekey/docs/zh/modules/debug.md
liujian e3f2372ee0
feat: docs for modules (#2623)
Signed-off-by: joyceliu <joyceliu@yunify.com>
2025-06-17 09:40:31 +00:00

54 lines
810 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# debug 模块
debug模块允许用户打印变量
## 参数
| 参数 | 说明 | 类型 | 必填 | 默认值 |
|------|------|------|------|-------|
| msg | 原始文件或文件夹路径 | 字符串 | 是 | - |
## 使用示例
1. 打印字符串
```yaml
- name: debug string
debug:
msg: I'm {{ .name }}
```
当变量`name`为kubekey时打印内容如下
```txt
DEBUG:
I'm kubekey
```
2. 打印map
```yaml
- name: debug map
debug:
msg: >-
{{ .product }}
```
当变量`product`为map时比如`{"name":"kubekey"}`,打印内容如下
```txt
DEBUG:
{
"name": "kubekey"
}
```
3. 打印数组
```yaml
- name: debug array
debug:
msg: >-
{{ .version }}
```
当变量`version`为array时比如`["1","2"]`,打印内容如下
```txt
DEBUG:
[
"1",
"2"
]
```