Note
This plugin is part of the cisco.ios collection (version 2.3.0).
To install it use: ansible-galaxycollectioninstallcisco.ios
.
To use it in a playbook, specify: cisco.ios.ios_command
.
Cisco IOS Technologies. Cisco IOS® Software is the world's leading network infrastructure software, delivering a seamless integration of technology innovation, business-critical services, and hardware platform support. Currently operating on millions of active systems, ranging from the small home office router to the core systems of the world. Fortunately for us, Cisco IOS keeps a history of syslog messages. We can see these with the show logging command: R1# show logging Syslog logging: enabled (0 messages dropped, 3 messages rate-limited, 0 flushes, 0 overruns, xml disabled, filtering disabled) No Active Message Discriminator.
Cisco Osi
Sends arbitrary commands to an ios node and returns the results read from the device. This module includes an argument that will cause the module to wait for a specific condition before returning or timing out if the condition is not met.
This module does not support running commands in configuration mode. Please use ios_config to configure IOS devices.
Note
This module has a corresponding action plugin.
Parameter | Choices/Defaults | Comments | |
---|---|---|---|
commands list / elements=raw / required | List of commands to send to the remote ios device over the configured provider. The resulting output from the command is returned. If the wait_for argument is provided, the module is not returned until the condition is satisfied or the number of retries has expired. If a command sent to the device requires answering a prompt, it is possible to pass a dict containing command, answer and prompt. Common answers are 'y' or 'r' (carriage return, must be double quotes). See examples. | ||
interval integer | Default: | Configures the interval in seconds to wait between retries of the command. If the command does not pass the specified conditions, the interval indicates how long to wait before trying the command again. | |
match string |
| The match argument is used in conjunction with the wait_for argument to specify the match policy. Valid values are all or any . If the value is set to all then all conditionals in the wait_for must be satisfied. If the value is set to any then only one of the values must be satisfied. | |
provider dictionary | Starting with Ansible 2.5 we recommend using connection: network_cli .For more information please see the IOS Platform Options guide. A dict object containing connection details. | ||
auth_pass string | Specifies the password to use if required to enter privileged mode on the remote device. If authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead. | ||
authorize boolean |
| Instructs the module to enter privileged mode on the remote device before sending any commands. If not specified, the device will attempt to execute all commands in non-privileged mode. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTHORIZE will be used instead. | |
host string | Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport. | ||
password string | Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead. | ||
port integer | Specifies the port to use when building the connection to the remote device. | ||
ssh_keyfile path | Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead. | ||
timeout integer | Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. | ||
username string | Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead. | ||
retries integer | Default: | Specifies the number of retries a command should by tried before it is considered failed. The command is run on the target device every retry and evaluated against the wait_for conditions. | |
wait_for list / elements=string | List of conditions to evaluate against the output of the command. The task will wait for each condition to be true before moving forward. If the conditional is not true within the configured number of retries, the task fails. See examples. |
Note
Tested against IOS 15.6
For more information on using Ansible to manage network devices see the Ansible Network Guide
For more information on using Ansible to manage Cisco devices see the Cisco integration page.
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
failed_conditions list / elements=string | failed | Sample: |
stdout | always apart from low level errors (such as action plugin) | The set of responses from the commands ['...', '...'] |
stdout_lines list / elements=string | always apart from low level errors (such as action plugin) | Sample: |
Authors¶
Peter Sprygada (@privateip)
Collection version 2.3.0
Cisco Ios Xe
Plugin Index¶
These are the plugins in the cisco.ios collection
Cliconf Plugins¶
ios – Use ios cliconf to run command on Cisco IOS platform
Cisco Ios Upgrade
Modules¶
ios_acl_interfaces – ACL interfaces resource module
ios_acls – ACLs resource module
ios_banner – Manage multiline banners on Cisco IOS devices
ios_bgp – Configure global BGP protocol settings on Cisco IOS.
ios_bgp_address_family – BGP Address family resource module
ios_bgp_global – Global BGP resource module
ios_command – Run commands on remote devices running Cisco IOS
ios_config – Manage Cisco IOS configuration sections
ios_facts – Collect facts from remote devices running Cisco IOS
ios_interface – (deprecated, removed after 2022-06-01) Manage Interface on Cisco IOS network devices
ios_interfaces – Interfaces resource module
ios_l2_interface – (deprecated, removed after 2022-06-01) Manage Layer-2 interface on Cisco IOS devices.
ios_l2_interfaces – L2 interfaces resource module
ios_l3_interface – (deprecated, removed after 2022-06-01) Manage Layer-3 interfaces on Cisco IOS network devices.
ios_l3_interfaces – L3 interfaces resource module
ios_lacp – LACP resource module
ios_lacp_interfaces – LACP interfaces resource module
ios_lag_interfaces – LAG interfaces resource module
ios_linkagg – Manage link aggregation groups on Cisco IOS network devices
ios_lldp – Manage LLDP configuration on Cisco IOS network devices.
ios_lldp_global – LLDP resource module
ios_lldp_interfaces – LLDP interfaces resource module
ios_logging – (deprecated, removed after 2023-06-01) Manage logging on network devices
ios_logging_global – Logging resource module
ios_ntp – Manages core NTP configuration.
ios_ospf_interfaces – OSPF_Interfaces resource module
ios_ospfv2 – OSPFv2 resource module
ios_ospfv3 – OSPFv3 resource module
ios_ping – Tests reachability using ping from Cisco IOS network devices
ios_prefix_lists – Prefix Lists resource module
ios_route_maps – Route maps resource module
ios_static_route – (deprecated, removed after 2022-06-01) Manage static IP routes on Cisco IOS network devices
ios_static_routes – Static routes resource module
ios_system – Manage the system attributes on Cisco IOS devices
ios_user – Manage the aggregate of local users on Cisco IOS device
ios_vlan – (deprecated, removed after 2022-06-01) Manage VLANs on IOS network devices
ios_vlans – VLANs resource module
ios_vrf – Manage the collection of VRF definitions on Cisco IOS devices
See also
List of collections with docs hosted here.