cnos_conditional_command – Execute a single command based on condition on devices running Lenovo CNOS¶
Synopsis¶
- This module allows you to modify the running configuration of a switch. It provides a way to execute a single CNOS command on a network device by evaluating the current running configuration and executing the command only if the specific settings have not been already configured. The CNOS command is passed as an argument of the method. This module functions the same as the cnos_command module. The only exception is that following inventory variable can be specified [“condition = <flag string>”] When this inventory variable is specified as the variable of a task, the command is executed for the network element that matches the flag string. Usually, commands are executed across a group of network devices. When there is a requirement to skip the execution of the command on one or more devices, it is recommended to use this module. This module uses SSH to manage network device configuration.
Parameters¶
Notes¶
Note
- For more information on using Ansible to manage Lenovo Network devices see https://www.ansible.com/ansible-lenovo.
Examples¶
Tasks : The following are examples of using the module
cnos_conditional_command. These are written in the main.yml file of the tasks
directory.
---
- name: Applying CLI template on VLAG Tier1 Leaf Switch1
cnos_conditional_command:
deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
outputfile: "./results/test_conditional_command_
{{ inventory_hostname }}_output.txt"
condition: "{{ hostvars[inventory_hostname]['condition']}}"
flag: leaf_switch2
command: "spanning-tree mode enable"
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
msg
string
|
always |
Success or failure message
Sample:
Command Applied
|
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors¶
- Anil Kumar Muraleedharan (@amuraleedhar)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.