cisco.radkit.command module – Execute commands on network devices via Cisco RADKit
Note
This module is part of the cisco.radkit collection (version 2.0.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 git+https://wwwin-github.cisco.com/scdozier/cisco.radkit-ansible.git
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: cisco.radkit.command
.
New in cisco.radkit 0.2.0
Synopsis
Executes one or more commands on network devices managed by Cisco RADKit
Supports execution on single devices or multiple devices using filter patterns
Returns structured command output with execution status and optional prompt removal
Provides comprehensive error handling and logging for troubleshooting
Requirements
The below requirements are needed on the host that executes this module.
cisco-radkit-client
Parameters
Parameter |
Comments |
---|---|
Alternate path to client ca cert for RADKIT If the value is not specified in the task, the value of environment variable RADKIT_ANSIBLE_CLIENT_CA_PATH will be used instead. |
|
Alternate path to client cert for RADKIT If the value is not specified in the task, the value of environment variable RADKIT_ANSIBLE_CLIENT_CERT_PATH will be used instead. |
|
Client certificate password in base64 If the value is not specified in the task, the value of environment variable RADKIT_ANSIBLE_CLIENT_PRIVATE_KEY_PASSWORD_BASE64 will be used instead. |
|
Alternate path to client key for RADKIT If the value is not specified in the task, the value of environment variable RADKIT_ANSIBLE_CLIENT_KEY_PATH will be used instead. |
|
List of commands to execute on the target device(s) Each command will be executed sequentially Commands should be valid for the target device OS |
|
Name of a specific device as it appears in RADKit inventory Mutually exclusive with filter_pattern and filter_attr |
|
Maximum time in seconds to wait for individual command execution Set to 0 for no timeout (default behavior) Can be set via environment variable RADKIT_ANSIBLE_EXEC_TIMEOUT Default: |
|
Inventory attribute to match against the filter_pattern Common values include ‘name’, ‘hostname’, ‘ip_address’ Must be used together with filter_pattern |
|
Pattern to match against RADKit inventory for multi-device operations Use glob-style patterns (e.g., ‘router*’, ‘switch-*’) Must be used together with filter_attr |
|
Identity to authentiate with RADKit (xxxx@cisco.com). If the value is not specified in the task, the value of environment variable RADKIT_ANSIBLE_IDENTITY will be used instead. |
|
Remove first and last lines from command output (typically CLI prompts) Helps clean up output for parsing and display Choices:
|
|
Radkit service serial If the value is not specified in the task, the value of environment variable RADKIT_ANSIBLE_SERVICE_SERIAL will be used instead. |
|
Maximum time in seconds to wait for RADKit task completion Set to 0 for no timeout (default behavior) Can be set via environment variable RADKIT_ANSIBLE_WAIT_TIMEOUT Default: |
Examples
# Execute a single command on a specific device
- name: Get version information from router-01
cisco.radkit.command:
device_name: router-01
commands: show version
register: version_output
delegate_to: localhost
# Execute multiple commands on a single device
- name: Get system information from router-01
cisco.radkit.command:
device_name: router-01
commands:
- show version
- show ip interface brief
- show running-config | include hostname
register: system_info
delegate_to: localhost
# Execute commands on multiple devices using filter pattern
- name: Get version from all routers
cisco.radkit.command:
filter_attr: name
filter_pattern: router*
commands: show version
register: all_versions
delegate_to: localhost
# Execute with custom timeouts and without prompt removal
- name: Long running command with custom settings
cisco.radkit.command:
device_name: core-switch-01
commands: show tech-support
exec_timeout: 300
wait_timeout: 600
remove_prompts: false
register: tech_support
delegate_to: localhost
# Display command output
- name: Show command results
debug:
msg: "{{ version_output.stdout }}"
# Process multiple device results
- name: Process results from multiple devices
debug:
msg: "Device {{ item.device_name }} version: {{ item.stdout | regex_search('Version ([0-9.]+)', '\1') | first }}"
loop: "{{ all_versions.ansible_module_results }}"
when: all_versions.ansible_module_results is defined
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
List of results when executing on multiple devices or multiple commands Each item contains device_name, command, stdout, exec_status, and exec_status_message Returned: when multiple devices or commands are involved Sample: |
|
Whether any changes were made (always false for command execution) Returned: always Sample: |
|
The command that was executed Returned: success Sample: |
|
Name of the device where the command was executed Returned: success Sample: |
|
Execution status from RADKit Returned: always Sample: |
|
Detailed status message from RADKit Returned: always Sample: |
|
Command output from the device Returned: success Sample: |