retries: Configures the number of retries for a command before it is
considered failed.
wait_for: Specifies a list of conditions that have to be evaluated
against the output of the command. In this example, it could be defined
as wait_for: result[0] contains IOS-XE, which verifies that the
output of the show version command contains the value IOS-XE
before going further with the execution of the playbook.
The playbook can be run from a terminal with the
following command:
Click here to view code image
$ ansible-playbook -i hosts site.yml -u admin -k
The -i option specifies the name of the inventory file, the
-u option specifies the username that will be used to
connect to the device, and the -k option specifies that the
user should be asked for the connection password when
the playbook is executed. Connection credentials can also
be included in the inventory file but in this example they
are passed in as parameters of the ansible-playbook
command. The output of this command looks as shown
in Example 15-2.
Example 15-2 Output of ansible-playbook
Command
Click here to view code image
$ ansible-playbook -i hosts site.yml -u admin -
k
SSH password:
PLAY [Test Ansible ios_command on Cisco IOS XE]
************************************
******************************************
TASK [show version and ip interface brief]
*****************************************
*************************************
ok: [10.10.30.171]