From 33c7a157ab2c687dcb9535eebdf49a7c6add4bf9 Mon Sep 17 00:00:00 2001 From: John R Barker Date: Mon, 11 Dec 2017 13:22:58 +0000 Subject: [PATCH] Create network_working_with_command_output.rst (#33709) Move this content to new location prior to intro_networking.rst refactor --- docs/docsite/rst/intro_networking.rst | 61 ----------------- .../network_working_with_command_output.rst | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+), 61 deletions(-) create mode 100644 docs/docsite/rst/network_working_with_command_output.rst diff --git a/docs/docsite/rst/intro_networking.rst b/docs/docsite/rst/intro_networking.rst index e619073dceb..8f924912d32 100644 --- a/docs/docsite/rst/intro_networking.rst +++ b/docs/docsite/rst/intro_networking.rst @@ -157,64 +157,3 @@ Variables are evaulated in the following order, listed from lowest to highest pr * Provider * Task arguments -.. _networking_module_conditionals: - -Conditionals in Networking Modules -`````````````````````````````````` - -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 waitfor argument can be used to evaluate the results before -returning control to the Ansible playbook. - -For example:: - - --- - - name: wait for interface to be admin enabled - eos_command: - commands: - - show interface Ethernet4 | json - waitfor: - - "result[0].interfaces.Ethernet4.interfaceStatus eq connected" - -In the above example task, the command :code:`show interface Ethernet4 | json` -is executed on the remote device and the results are evaluated. If -the path -:code:`(result[0].interfaces.Ethernet4.interfaceStatus)` is not equal to -"connected", then the command is retried. This process continues -until either the condition is satisfied or the number of retries has -expired (by default, this is 10 retries at 1 second intervals). - -The commands module can also evaluate more than one set of command -results in an interface. For instance:: - - --- - - name: wait for interfaces to be admin enabled - eos_command: - commands: - - show interface Ethernet4 | json - - show interface Ethernet5 | json - waitfor: - - "result[0].interfaces.Ethernet4.interfaceStatus eq connected" - - "result[1].interfaces.Ethernet4.interfaceStatus eq connected" - -In the above example, two commands are executed on the -remote device, and the results are evaluated. By specifying the result -index value (0 or 1), the correct result output is checked against the -conditional. - -The waitfor argument must always start with result and then the -command index in [], where 0 is the first command in the commands list, -1 is the second command, 2 is the third and so on. - diff --git a/docs/docsite/rst/network_working_with_command_output.rst b/docs/docsite/rst/network_working_with_command_output.rst new file mode 100644 index 00000000000..d4bc8fb772e --- /dev/null +++ b/docs/docsite/rst/network_working_with_command_output.rst @@ -0,0 +1,65 @@ +.. _networking_working_with_command_output: + +********************************************** +Working with Command Output in Network Modules +********************************************** + +Conditionals in Networking Modules +=================================== + +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 +returning control to the Ansible playbook. + +For example:: + + --- + - name: wait for interface to be admin enabled + eos_command: + commands: + - show interface Ethernet4 | json + wait_for: + - "result[0].interfaces.Ethernet4.interfaceStatus eq connected" + +In the above example task, the command :code:`show interface Ethernet4 | json` +is executed on the remote device and the results are evaluated. If +the path +:code:`(result[0].interfaces.Ethernet4.interfaceStatus)` is not equal to +"connected", then the command is retried. This process continues +until either the condition is satisfied or the number of retries has +expired (by default, this is 10 retries at 1 second intervals). + +The commands module can also evaluate more than one set of command +results in an interface. For instance:: + + --- + - name: wait for interfaces to be admin enabled + eos_command: + commands: + - show interface Ethernet4 | json + - show interface Ethernet5 | json + wait_for: + - "result[0].interfaces.Ethernet4.interfaceStatus eq connected" + - "result[1].interfaces.Ethernet4.interfaceStatus eq connected" + +In the above example, two commands are executed on the +remote device, and the results are evaluated. By specifying the result +index value (0 or 1), the correct result output is checked against the +conditional. + +The ``wait_for`` argument must always start with result and then the +command index in ``[]``, where ``0`` is the first command in the commands list, +``1`` is the second command, ``2`` is the third and so on. +