我有一个用于创建和调整逻辑卷大小的 Ansible 剧本
# playbook lvol.yml
- hosts: step
tasks:
- name: 'create /dev/sdb1 -> 20GB (of 35GB)'
community.general.parted:
device: /dev/sdb
number: 1
state: present
# fs_type: ext4
- name: "resize vgsys by /dev/sdb1"
community.general.lvg:
vg: vgsys
pvs: /dev/sdb1
- name: "extend lv 'name' to 10GB from /dev/sdb (35GB)"
community.general.lvol:
vg: vgsys
lv: name
size: 10g
yaml 语法似乎不错(通过 onlineyamltools.com 检查)但我在执行时出现此错误:
ERROR! conflicting action statements: community.general.parted, device
The error appears to be in '/path/to/lvol.yml': line 4, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: 'create /dev/sdb1 -> 20GB (of 35GB)'
^ here
如果我注释掉第一个(community.general.parted)任务,第二个(lvol)任务也会出现同样的错误。
有人能告诉我如何解决这个问题吗?
答案1
您的 yaml 没有正确缩进。
您需要将参数缩进模块的下一个级别:
- hosts: step
tasks:
- name: 'create /dev/sdb1 -> 20GB (of 35GB)'
community.general.parted:
device: /dev/sdb
number: 1
state: present
# fs_type: ext4
- name: "resize vgsys by /dev/sdb1"
community.general.lvg:
vg: vgsys
pvs: /dev/sdb1
您对lvol
模块所做任务已经正确了。
在线验证器无法检测到这一点,因为它只能检查语法正确的 yaml,而不能检查功能正确的键和值。