错误!冲突的操作语句:主机,运行时的命令


- name: test
hosts: all
gather_facts: no
tasks:
#command 1
- name: ansible-test command 1
iosxr_command:
commands:
- show inventory
when: ansible_network_os == 'iosxr'
register: output
- debug:
var: output.stdout
- name: print command executed
hosts: 127.0.0.1
connection: local
command: 
- echo sh inventory
register: output1
- debug:
var: output1.stdout

这是我的剧本

ERROR! conflicting action statements: hosts, command
The error appears to be in '/root/container/playbook2.yaml': line 16, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:

- name: print command executed
^ here

我遇到此错误。
请帮我解决问题。

缩进。 您需要使用一组新的主机和新的任务列表开始新的播放。

- name: test
hosts: all
gather_facts: no
tasks:
#command 1
- name: ansible-test command 1
iosxr_command:
commands:
- show inventory
when: ansible_network_os == 'iosxr'
register: output
- debug:
var: output.stdout
- name: print command executed
hosts: 127.0.0.1
connection: local
gather_facts: no
tasks:
- command: echo sh inventory
register: output1
- debug:
var: output1.stdout

相关内容

最新更新