community.network.aruba_command 模块 – 在运行 Aruba 移动控制器的远程设备上运行命令

注意

此模块是 community.network 集合(版本 5.1.0)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.network

要在 playbook 中使用它,请指定:community.network.aruba_command

注意

community.network 集合已弃用,将从 Ansible 12 中删除。有关更多信息,请参阅讨论主题

已弃用

在以下版本中删除:

版本 6.0.0

原因:

此集合及其中的所有内容均未维护且已弃用。

替代方案:

未知。

概要

  • 将任意命令发送到 Aruba 节点,并返回从设备读取的结果。此模块包含一个参数,该参数将使模块等待特定条件,然后再返回,如果条件不满足,则超时。

  • 此模块不支持在配置模式下运行命令。请使用 community.network.aruba_config 来配置 Aruba 设备。

别名:network.aruba.aruba_command

参数

参数

注释

commands

字符串 / 必需

通过配置的提供程序发送到远程 Aruba 设备的命令列表。返回命令的结果输出。如果提供了 wait_for 参数,则在满足条件或重试次数过期之前,模块不会返回。

interval

字符串

配置命令重试之间等待的秒数间隔。如果命令未通过指定条件,则该间隔指示在再次尝试该命令之前等待多长时间。

默认值: 1

match

字符串

match 参数与 wait_for 参数结合使用,以指定匹配策略。有效值为 allany。如果该值设置为 all,则必须满足 wait_for 中的所有条件。如果该值设置为 any,则只需满足其中一个值。

选择

  • "any"

  • "all" ← (默认)

retries

字符串

指定在被视为失败之前应尝试命令的重试次数。每次重试都在目标设备上运行该命令,并根据 wait_for 条件进行评估。

默认值: 10

wait_for

别名:waitfor

字符串

要针对命令输出进行评估的条件列表。该任务将等待每个条件为真,然后再继续。如果在配置的重试次数内条件不为真,则任务将失败。请参阅示例。

示例

tasks:
  - name: Run show version on remote devices
    community.network.aruba_command:
      commands: show version

  - name: Run show version and check to see if output contains Aruba
    community.network.aruba_command:
      commands: show version
      wait_for: result[0] contains Aruba

  - name: Run multiple commands on remote nodes
    community.network.aruba_command:
      commands:
        - show version
        - show interfaces

  - name: Run multiple commands and evaluate the output
    community.network.aruba_command:
      commands:
        - show version
        - show interfaces
      wait_for:
        - result[0] contains Aruba
        - result[1] contains Loopback0

返回值

通用返回值记录在此处,以下是此模块特有的字段

描述

failed_conditions

列表 / 元素=字符串

失败的条件列表

返回值: 失败

示例: ["...", "..."]

stdout

列表 / 元素=字符串

来自命令的一组响应

返回值: 始终

示例: ["...", "..."]

stdout_lines

列表 / 元素=字符串

拆分为列表的 stdout 的值

返回值: 始终

示例: [["...", "..."], ["..."], ["..."]]

状态

  • 此模块将在版本 6.0.0 中删除。[已弃用]

  • 有关更多信息,请参阅已弃用

作者

  • James Mighion (@jmighion)