community.network.edgeos_command module – Run one or more commands on EdgeOS devices

Note

This module is part of the community.network collection (version 5.0.2).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.network.

To use it in a playbook, specify: community.network.edgeos_command.

Synopsis

  • This command module allows running one or more commands on a remote device running EdgeOS, such as the Ubiquiti EdgeRouter.

  • This module does not support running commands in configuration mode.

  • Certain show commands in EdgeOS produce many lines of output and use a custom pager that can cause this module to hang. If the value of the environment variable ANSIBLE_EDGEOS_TERMINAL_LENGTH is not set, the default number of 10000 is used.

  • This is a network module and requires connection: network_cli in order to work properly.

  • For more information please see the Network Guide.

Aliases: network.edgeos.edgeos_command

Parameters

Parameter

Comments

commands

string / required

The commands or ordered set of commands that should be run against the remote device. The output of the command is returned to the playbook. If the wait_for argument is provided, the module is not returned until the condition is met or the number of retries is exceeded.

interval

string

The number of seconds to wait between retries of the command.

Default: 1

match

string

Used in conjunction with wait_for to create match policy. If set to all, then all conditions in wait_for must be met. If set to any, then only one condition must match.

Choices:

  • "any"

  • "all" ← (default)

retries

string

Number of times a command should be tried before it is considered failed. The command is run on the target device and evaluated against the wait_for conditionals.

Default: 10

wait_for

string

Causes the task to wait for a specific condition to be met before moving forward. If the condition is not met before the specified number of retries is exceeded, the task will fail.

Notes

Note

  • Tested against EdgeOS 1.9.7

  • Running show system boot-messages all will cause the module to hang since EdgeOS is using a custom pager setting to display the output of that command.

Examples

tasks:
  - name: Reboot the device
    community.network.edgeos_command:
      commands: reboot now

  - name: Show the configuration for eth0 and eth1
    community.network.edgeos_command:
      commands: show interfaces ethernet {{ item }}
    loop:
      - eth0
      - eth1

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

stdout

list / elements=string

The set of responses from the commands

Returned: always apart from low level errors (such as action plugin)

Sample: ["...", "..."]

stdout_lines

list / elements=string

The value of stdout split into a list

Returned: always

Sample: [["...", "..."], ["..."], ["..."]]

Authors

  • Chad Norgan (@beardymcbeards)

  • Sam Doran (@samdoran)