我有一个变量:
ok: [192.168.0.2] => {
"_ip": [
"192.168.0.3"
]}
我想把它传递给路由器上的命令
- name: Ping
community.routeros.command:
commands: 'ping {{_ip}} count 5'
register: ping但结果却是个错误
ok: [192.168.0.2] => {
"ping.stdout_lines": [
[
"p",
"",
"expected command name (line 1 column 7)"
]
]}
我查看了错误可能是什么,它给出了以下内容:
changed: [192.168.176.129] => {
"changed": true,
"invocation": {
"module_args": {
"commands": [
"ping ['192.168.176.128'] count 5"
],
"interval": 1,
"match": "all",
"retries": 10,
"wait_for": null
}
},
"stdout": [
"p\n\nexpected command name (line 1 column 7)"
],
"stdout_lines": [
[
"p",
"",
"expected command name (line 1 column 7)"
]
]}
怎么修呢?
发布于 2021-11-30 16:42:11
遵循您的错误,它似乎_ip是一个列表,所以
尝试:
commands: 'ping {{_ip.0}} count 5'https://stackoverflow.com/questions/70172381
复制相似问题