我是Ansible的新手,我试图从my_plybk.yml。
my_playbk.yml的内容如下:
---
- hosts: localhost
gather_facts: no
tasks:
- include my_tasks.yml
my_task.yml的内容如下。
- hosts: localhost
tasks:
- name: Run the below script
command: sh myscript.sh
myScript.sh
的内容echo "Hello"
以下是我遇到的错误。
ERROR! A malformed block was encountered while loading a block
我想问题可能是您的my_plybk.yaml
文件中的额外间距。
应该像这样安排它:
---
- hosts: localhost
gather_facts: no
tasks:
- include: my_tasks.yml
此外,"包括"后也缺少结肠。
适用于my_tasks.yml
文件的相同:
- name: Run the below script
command: sh myscript.sh
另外,请在上面的文本中注意到,您随附的文件应仅包含任务列表,而没有"主机"或"任务"关键字。
请注意,一般而言,Ansible和Yaml-Files对您安排排和空格的方式非常敏感。