DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
tasks:


  • name: show version and ip interface brief
    ios_command:
    commands:

  • show version

  • show ip interface brief


YAML files start with --- (and so do Ansible playbooks).
A playbook contains one or multiple plays. The plays are
logical groupings of tasks and modules. The playbook in
this example contains only one play that is marked by the
hyphen (-) character at the leftmost position. The name
of the play is optional, but it should contain an arbitrary
string describing the actions that the play will perform.
The name is displayed on the screen when the playbook
is executed. The hosts keyword specifies which hosts or
machines the play will be executed against. In Example
15-1, the play is executed against the iosxe group of
devices. The value for the hosts parameter in the
playbook must match the names of the groups, as
defined in the inventory file. Tasks are executed on the
hosts that are defined in the play definition. For each
task, a name value should contain an arbitrary
description of the task. Like the name of the play, the
name of the task is optional, but it should contain
pertinent description text, as it is displayed to the screen
when the playbook is executed. ios_command is the
name of the Ansible module that is part of the task in this
example. The ios_command module takes in multiple
parameters, but only one of them is mandatory: the
actual commands that will be sent to the IOS device. The
two commands that will be sent to the [iosxe] device are
show version and show ip interface brief.


Some of the other optional parameters for the
ios_command module are the following:


interval: Specifies the interval of time, in seconds, to wait between
retries of the command.
Free download pdf