From 813d4435ca98fa6fa4592022cb003be939e0c100 Mon Sep 17 00:00:00 2001 From: Scott Butler Date: Tue, 24 May 2016 21:39:59 -0700 Subject: [PATCH 1/4] Incorporated additional tech review feedback. --- docsite/rst/intro_networking.rst | 52 ++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/docsite/rst/intro_networking.rst b/docsite/rst/intro_networking.rst index 7d771fde001..a1dd02643eb 100644 --- a/docsite/rst/intro_networking.rst +++ b/docsite/rst/intro_networking.rst @@ -145,13 +145,6 @@ Running the above task will cause an error to be generated with a message that r Overall, this provides a very granular level of control over how credentials are used with modules. It provides the playbook designer maximum control for changing context during a playbook run as needed. -.. _networking_module_types: - -Understanding Networking Module Types -````````````````````````````````````` - -TBD - .. _networking_environment_variables: Networking Environment Variables @@ -188,13 +181,48 @@ Ansible allows you to use conditionals to control the flow of your playbooks. An * contains - Object contains specified item -Conditionals used with networking command modules only evaluate results, not stdout. For example, the following example won't work:: +Conditional statements evalute 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 evalute the results before +return control to the Ansible playbook. - --- - waitfor: "stdout_lines[0][6] contains '100.00'" +For example:: -To evaluate this properly, you'll need to compare against results. 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 statisfied 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:: --- - result[0] contains '100.00' + - 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, there are two commands that 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. From 9fcb6635fabd9eeaea84786c26e129d2c1aa8001 Mon Sep 17 00:00:00 2001 From: Scott Butler Date: Tue, 24 May 2016 22:00:40 -0700 Subject: [PATCH 2/4] Typo fixes --- docsite/rst/intro_networking.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docsite/rst/intro_networking.rst b/docsite/rst/intro_networking.rst index a1dd02643eb..e9d5d9a3535 100644 --- a/docsite/rst/intro_networking.rst +++ b/docsite/rst/intro_networking.rst @@ -201,7 +201,7 @@ 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 statisfied or the number of retries has +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 @@ -217,12 +217,12 @@ results in an interface. For instance:: - "result[0].interfaces.Ethernet4.interfaceStatus eq connected" - "result[1].interfaces.Ethernet4.interfaceStatus eq connected" -In the above example, there are two commands that are executed on the -remote device and the results are evaluated. By specifying the result +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, +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. From 189ae499cf1fd1dc738583a7c10181714cdde085 Mon Sep 17 00:00:00 2001 From: Scott Butler Date: Wed, 25 May 2016 07:29:02 -0700 Subject: [PATCH 3/4] Typo fix --- docsite/rst/intro_networking.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsite/rst/intro_networking.rst b/docsite/rst/intro_networking.rst index e9d5d9a3535..f9f1fabdc69 100644 --- a/docsite/rst/intro_networking.rst +++ b/docsite/rst/intro_networking.rst @@ -184,7 +184,7 @@ Ansible allows you to use conditionals to control the flow of your playbooks. An Conditional statements evalute 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 evalute the results before -return control to the Ansible playbook. +returning control to the Ansible playbook. For example:: From 1b52acade8ca56d6c8b2c3df7efb00504767f551 Mon Sep 17 00:00:00 2001 From: Scott Butler Date: Wed, 25 May 2016 13:37:21 -0700 Subject: [PATCH 4/4] Fixed indenting in samples. --- docsite/rst/intro_networking.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docsite/rst/intro_networking.rst b/docsite/rst/intro_networking.rst index f9f1fabdc69..ce3059bf9a6 100644 --- a/docsite/rst/intro_networking.rst +++ b/docsite/rst/intro_networking.rst @@ -191,10 +191,10 @@ 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" + 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 @@ -210,12 +210,12 @@ 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" + 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