Ansible allows you to use conditionals to control the flow of your playbooks. Ansible networking command modules use the following unique conditional statements.
*``eq`` - Equal
*``neq`` - Not equal
*``gt`` - Greater than
*``ge`` - Greater than or equal
*``lt`` - Less than
*``le`` - Less than or equal
*``contains`` - Object contains specified item
Conditional statements evaluate the results from the commands that are
executed remotely on the device. Once the task executes the command
set, the ``wait_for`` argument can be used to evaluate the results before
Network devices may require that you answer a prompt before performing a change on the device. Individual network modules such as :ref:`cisco.ios.ios_command <ansible_collections.cisco.ios.ios_command_module>` and :ref:`cisco.nxos.nxos_command <ansible_collections.cisco.nxos.nxos_command_module>` can handle this with a ``prompt`` parameter.
``prompt`` is a Python regex. If you add special characters such as ``?`` in the ``prompt`` value, the prompt won't match and you will get a timeout. To avoid this, ensure that the ``prompt`` value is a Python regex that matches the actual device prompt. Any special characters must be handled correctly in the ``prompt`` regex.
- "Do you want to change that to the standby image"
answer:
- 'y'
- <password>
- 'y'
You must list the prompt and the answers in the same order (that is, prompt[0] is answered by answer[0]).
In the above example, ``check_all: True`` ensures that the task gives the matching answer to each prompt. Without that setting, a task with multiple prompts would give the first answer to every prompt.
In the following example, the second answer would be ignored and ``y`` would be the answer given to both prompts. That is, this task only works because both answers are identical. Also notice again that ``prompt`` must be a Python regex, which is why the ``?`` is escaped in the first prompt.