community.openwrt.command module – Execute commands on OpenWrt targets
Note
This module is part of the community.openwrt collection (version 0.5.0).
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.openwrt.
To use it in a playbook, specify: community.openwrt.command.
Synopsis
The community.openwrt.command module runs a command on the remote OpenWrt device.
The command is executed directly or through a shell depending on the
uses_shellparameter.This module does not support check mode.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
|---|---|
Change into this directory before running the command. |
|
The command to execute. |
|
A filename or glob pattern. If it already exists, the command does not run. |
|
The shell to use when Default: |
|
A filename or glob pattern. If it does not exist, the command does not run. |
|
Whether to execute the command through a shell. If If Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: none |
Can run in |
|
Support: none |
Returns details on what has changed (or possibly needs changing in |
|
Platform: OpenWrt |
Target platform for this module. |
Examples
- name: Run a simple command
community.openwrt.command:
cmd: uptime
- name: Run a command with arguments
community.openwrt.command:
cmd: ls -la /etc
- name: Change directory before running command
community.openwrt.command:
cmd: pwd
chdir: /tmp
- name: Only run if file does not exist
community.openwrt.command:
cmd: touch /tmp/myfile
creates: /tmp/myfile
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The command executed. Returned: always Sample: |
|
The command execution time. Returned: always Sample: |
|
The command end time. Returned: always Sample: |
|
The command return code. Returned: always Sample: |
|
The command start time. Returned: always Sample: |
|
The command standard error. Returned: always Sample: |
|
The command standard output. Returned: always Sample: |