law*_*per 12
我最近也打了这个,并找到了一个很好的方法。
在 Ubuntu 中,您可以使用以下方法来验证文件解析是否正确。
cloud-init devel schema --config-file bob.txt
Run Code Online (Sandbox Code Playgroud)
如果文件有效或无效,这将给您以下通知
:~$ sudo cloud-init devel schema --config-file bob.txt
Valid cloud-config file bob.txt
$ nano bob.txt #edited the yaml to make it invalid
:~$ sudo cloud-init devel schema --config-file bob.txt
Cloud config schema errors: format-l2.c1: File bob.txt is not valid yaml. while parsing a block mapping
in "<byte string>", line 2, column 1:
package_upgrade: true
^
expected <block end>, but found '-'
in "<byte string>", line 6, column 1:
- 'curl -fsSL https://get.docker ...
^
Run Code Online (Sandbox Code Playgroud)
虽然您使用云初始化文件cloud-init status --wait和许多其他命令cli非常有用。
嗯,经过进一步检查,它似乎没有发现许多类型的错误,但Cloud Init 文档将其列为正在进行的工作。
cloud-init 开发模式:#cloud-config 格式和模式验证器。它接受一个 cloud-config yaml 文件并在不需要部署的情况下在本地注释潜在的架构错误。架构验证正在进行中,并支持云配置模块的子集。
从版本22.2开始,用于验证配置文件的 cloud-init 命令现在为:
cloud-init schema --config-file conf.yaml
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5171 次 |
| 最近记录: |