ansible - 错误!冲突的操作语句:主机、运行时的命令
问题描述
- 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
推荐阅读
- r - 应用`all`函数的更快方法?
- javascript - Nodejs 超出最大调用堆栈大小
- java - 在菜单中选择项目时如何更改本地语言?
- swift - 将 SwiftUI CalloutView 添加到 MapKit
- php - 如何在php中将文件转换为zip
- android - 如何跟踪 WebRTC 远程 VideoStream 的分辨率/纵横比?
- java - 身份验证后如何将用户数据存储到 Firbase 数据库中?
- spring-boot - 使用 Aspectj 指向扩展类方法的切入点
- sql - 编写单个 SQL 查询以计算具有“真”条件的多个布尔列的计数
- javascript - 如何同时使用不同的 eslint 配置 lint JS 和 TS 文件?