我已经写了一个简单的playbook来打印Java进程ID和该PID的其他信息。
我已经写了一个简单的playbook来打印Java进程ID和该PID的其他信息
[root@server thebigone]# cat check_java_pid.yaml
---
- hosts: all
gather_facts: no
tasks:
- name: Check PID of existing Java process
shell: "ps -ef | grep [j]ava"
register: java_status
- debug: var=java_status.stdout
当我使用ansible-playbook check_java_pid.yaml
命令时,它可以正常工作。
现在,我正在尝试从另一个playbook中仅针对特定主机调用上述playbook。因此,我编写了以下第二个playbook:
[root@server thebigone]# cat instance_restart.yaml
---
- hosts: instance_1
gather_facts: no
tasks:
- include: check_java_pid.yaml
然而,当我尝试执行ansible-playbook instance_restart.yaml
时,我遇到了以下错误。
ERROR! no action detected in task. This often indicates a misspelled
module name, or incorrect module path.
The error appears to have been in
'/home/root/ansible/thebigone/check_java_pid.yaml': line 2, column 3, but
may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: all
^ here
The error appears to have been in
'/home/root/ansible/thebigone/check_java_pid.yaml': line 2, column 3,
but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: all
^ here
它显示语法错误,但据我所知并没有实际错误,因为我已经成功执行了 Playbook check_java_pid.yaml
。
请求您的帮助理解此问题。