community.ciscosmb.command 模块 – 在远程 Cisco SMB 设备上运行命令
注意
此模块是 community.ciscosmb 集合(版本 1.0.9)的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.ciscosmb
。
要在 playbook 中使用它,请指定: community.ciscosmb.command
。
概要
将任意命令发送到 Cisco SMB 节点并返回从设备读取的结果。此模块包含一个参数,该参数将导致模块在返回之前等待特定条件,或者如果未满足条件则超时。
参数
参数 |
注释 |
---|---|
要通过配置的提供程序发送到远程 Cisco SMB 设备的命令列表。返回命令的输出结果。如果提供了 *wait_for* 参数,则在满足条件或重试次数过期之前,模块不会返回。 |
|
配置命令重试之间等待的秒数间隔。如果命令未通过指定的条件,则间隔指示在再次尝试命令之前要等待的时间。 默认值: |
|
*match* 参数与 *wait_for* 参数一起使用以指定匹配策略。有效值为 选项
|
|
指定在命令被认为失败之前应尝试的重试次数。命令在每次重试时都在目标设备上运行,并根据 *wait_for* 条件进行评估。 默认值: |
|
要根据命令输出评估的条件列表。任务将等待每个条件为真才能继续执行。如果在配置的重试次数内条件不为真,则任务失败。参见示例。 |
示例
- name: Run command on remote devices
community.ciscosmb.command:
commands: show version
- name: Run command and check to see if output contains PID
community.ciscosmb.command:
commands: show inventory
wait_for: result[0] contains PID
- name: Run multiple commands on remote nodes
community.ciscosmb.command:
commands:
- show version
- show system
- name: Run multiple commands and evaluate the output
community.ciscosmb.command:
commands:
- show version
- show system
wait_for:
- result[0] contains Active-image
- result[1] contains "System Up Time"
返回值
常见的返回值在 此处 有文档记录,以下是此模块特有的字段
键 |
描述 |
---|---|
已失败的条件列表。 返回:失败 示例: |
|
命令的响应集。 返回:始终返回,除了低级别错误(例如动作插件) 示例: |
|
stdout 的值拆分为列表。 返回:始终返回,除了低级别错误(例如动作插件) 示例: |