Local connections and facts

Ansible modules are Python code that's executed on the remote host by default. Because of the fact that most network equipment does not expose Python directly, or they simply do not contain Python, we are almost always executing the playbook locally. This means that the playbook is interpreted locally first and commands or configurations are pushed out later on as needed.

Recall that the remote host facts were gathered via the setup module, which was added by default. Since we are executing the playbook locally, the setup module will gather the facts on the localhost instead of the remote host. This is certainly not needed, therefore when the connection is set to local, we can reduce this unnecessary step by setting the fact gathering to false.

Because network modules are executed locally, for those modules that offer a backup option, the files are backed up locally on the control node as well.

One of the most important changes in Ansible 2.5 was the introduction of different communication protocols (https://docs.ansible.com/ansible/latest/network/getting_started/network_differences.html#multiple-communication-protocols). The connection method now includes network_cli, netconf, httpapi, and local. If the network device uses CLI over SSH, you indicate the connection method as network_cli in one of the device variables. However, due to the fact that this is a relatively recent change, you might still see the connection stated as local in many of the existing playbooks. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset