gpt4 book ai didi

Ansible 外壳/命令模块 - "msg": "[Errno 2] No such file or directory",

转载 作者:行者123 更新时间:2023-12-05 01:16:39 24 4
gpt4 key购买 nike

我想运行命令“ll/dev/disk/by-id/scsi-*”来获取 scsi ID。我已经尝试使用 command 和 Shell 成为:是的,但没有成功。

- name: Get ISCSI Id
command: ll /dev/disk/by-id/scsi-*
register: iscsiid
become: yes

错误:

    "changed": false,
"cmd": "ll '/dev/disk/by-id/scsi-*'",
"invocation": {
"module_args": {
"_raw_params": "ll /dev/disk/by-id/scsi-*",
"_uses_shell": false,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"warn": true
}
},
"msg": "[Errno 2] No such file or directory",
"rc": 2
}

知道如何运行这个命令吗?当我以 root 用户手动运行时它有效。

谢谢,

最佳答案

尝试使用 shell 模块而不是命令,还将 ll 别名替换为类似“ls”的 shell 命令 - 我试过了并且有效:

- name: test
hosts: localhost
tasks:
- shell: ls -lstr /dev/disk/by-id/scsi-*
register: iscsiid
become: yes
- debug:
msg: "{{ iscsiid }}"

关于Ansible 外壳/命令模块 - "msg": "[Errno 2] No such file or directory",,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53026286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com