Working with the cli_command module
Before we get to the practical hands-on examples, we must look at a module that has become central to network device configuration since the previous edition of this book was published.
As we discussed in the preceding section, most network devices cannot be expected to have a working Python environment on them, and as such, Ansible will use local execution – that is to say, all tasks related to network devices are executed on the Ansible control node itself, translated into the correct format for the device to receive (be that a CLI, an HTTP-based API, or otherwise), and then sent over the network to the device. Ansible 2.7 relied mostly on a communication protocol known as local
for network device automation. This worked well but suffered from several drawbacks, including the following:
- The
local
protocol does not support persistent network connections – a new connection needs to be set up and then torn down for each task...